Please note: this project is inactive since early 2006

 
3.1.1.2 Separating the generated code from your own work

During development, especially at early stages, the model is likely to change at a high rate, and so does the code which is automatically derived from the model. In such situations (and, in fact, each time the model change), it is quite easy to see that the so-called ``compact scheme'' used in the paragraph above is not very convenient: the script does not overwrite any existing file, so integrating the new changes consists in, for example, moving the python file elsewhere, regenrate the code, then integrate any code you may have written by hand from the previsouly moved python file to the new one...

That's why the script mdl_generate_python_code.py has an other option: -B or --base-generation-scheme, which is specially designed to keep the generated code separated from the business logic you add, so that you'll never have to worry mixing your own logic with automatically derived portions of code.

As an example, let's see the generated files by this scheme:

AuthorBooks/
|-- Book.py
|-- MDL
|   |-- * Book.py
|   |-- * Writer.py
|   |-- * __init__.py
|   |-- * model_AuthorBooks.py
|   `-- * model_AuthorBooks.xml
|-- Writer.py
|-- __init__.py
`-- setup.py

As you can see, a new subpackage MDL is created, where the files are always overwritten when regenerating the code -and more: the files within that directory are the only ones that can be overwritten by the script.

The modules Book and Writer in the top-level directory are the place where you'll put your own code; the classes within directly inherit from the ones in the MDL subpackage, keeping the automatically generated portion of codes completely separated from your own code.

Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted by:SourceForge.net Logo