Observer/Observable in codegen, Improved Java class builder XSLT Template

Today I dramatically refactored codegen again. I removed the Hashtables from the Package and Project classes and replaced it with IList’s. I also
replaced all ArrayList references with IList’s and added a Add and a Clear method for every many-relation in the classes. So make sure you update your checkout.

I did this because I wanted to implement Observer/Observable. If you don’t know what Observer/Observable is, read about it at wikipedia. You can’t easily observe the Add method of the ArrayList (unless you
extend that class, of course). However, now it’s possible to be Observer of the Package, Project, Interface, Class, Operation,
Attribute and Parameter instances. This means that if they change, you can get notified about it (and, for example, regenerate your code).

This doesn’t yet have a use-case because the sample application uses the ISourceParser for parsing the UML class diagram source file and the IGenerator
for generating the entire project in two steps. The idea is to some day create an IGenerator that plays the role of an observer of
those instances. This would allow for regeneration of code on-the-fly when deep integrating codegen with a integration development
environment or code editing application. For example regenerating code when your diagram changes.

Perhaps someday regeneration or redrawing on-the-fly of the diagram if the code changes (this ain’t current, it’s a futuristic idea). I’m
still experimenting with my own ideas here. I got inspired about all this after reading this blog.

I’d like to point out that this is indeed in the scope of this project. I’m indeed attempting to build a code generation framework, not just a simple code generator. Of course is the only end-user use of codegen at this moment “a simple code generator that is a little bit fancy because it can already handle multiple input formats and generate multiple programming languages. I’m, however, (in future) planning to do much cooler things with the concept of code generation. Mainly integration with integrated development environments and really making Model Driven Development much more easy and pleasant. But for all those cool idea’s, you first need to get the basics right. Right?

The first contribution from somebody other than me comes from my colleague Marien Johan who greatly improved the
Java class builder XSLT Template. He basically rewrote the stylesheet and added a huge amount of comments and documentation. Check it out if you’re planning to add support for other languages.

Short term plans for codegen: Create some NUnit tests, create PHP 5 and Python XSLT Templates. Also redoing the current Observable/Observer infrastructure. A.t.m. it’s junk. But I need to get some sleep now. Feel free to contact me if you’d like to help with these or any other subjects related to codegen.

Codegen and PHP5

I just committed a very simple set of XSLT Templates that will let codegen generate PHP5 classes and interfaces. I haven’t yet done it the way Marien Johan did it for Java. I know this is a better way of creating xsl’s. I will improve this soon.