[Typo3-dev] Code generation library

dan frost dan at danfrost.co.uk
Sat Nov 19 14:42:48 CET 2005


Hi,

I have been working on a code generation and 
maintainance library which I've published at:
http://www.danfrost.co.uk/index.php?id=15

This creates and updates code from a UML model. 
You create the model in (at the moment) MagicDraw 
and generate the code using the "johnny5" 
command-line tool. (Johnny 5 from the film short 
circuit... the robot rebuilds itself, so does this 
code!)

The code generated has markers in it - you code 
between the markers... E.g.

<code>
class elCodeGen_phpClass extends 
elCodeGen_phpInterface {

     /**
      * @desc Adds a new property object to the class
      * @return void
      * @param _b6f02df_1129057505642_613285_339 
$propertyObject Name of the property.
      */
     function addProperty($propertyObject) {

         // 
evLibStartMarker_DONOTEDIT_b6f02df_1129067221417_896322_426
         $this->methods[$propertyObject->name] = 
$propertyObject;
         // 
evLibEndMarker_DONOTEDIT_b6f02df_1129067221417_896322_426

     }
}
</code>

After adding hand-coded lines you can still edit 
the model in the UML program and run the johnny5 
code generation tool - anything between markers 
will be kept; anything outside is lost. There are 
also some pretty cool side-effects - you can drag 
methods around between classes and when you 
regenerate the methods are moved for you!!!

The library only works with MagicDraw's rich XMI 
format but I'm working to support formats from 
other programs.

The point of this is that all the things I've been 
talking about on the lists - refactoring, cleaner 
architecture etc.. - are much easier with a tool 
like this because (i) you don't have to make each 
file/class/function when you change the 
architecture and (ii) you can't change the 
architecture when you're working on lines of code. 
I find this allows me to concentrate on the model 
instead of playing around with code.

The library is already pwerful enough to create 
itself - the next steps are to rebuild the 
command-line interface and extend its XMI support 
to other programs. The library is self-contained - 
it isn't dependent on TYPO3 or any other 
libraries. The reason for this is that I want the 
whole thing to be based on generated code (which 
is maintained as generated code) from the ground up.

Cheers,
dan




More information about the TYPO3-dev mailing list