1. A method of generating code in a model-based development environment comprising: modeling a system using graphical modeling entities; attaching a modular code generator routine directly to at least one of the graphical modeling entities; traversing through the graphical modeling entities to access the code generator routine; and, executing the accessed code generator routine so as to generate code for the system.