How to distinguish generated code from non-generated code
It is a well-known fact that for most real-life applications, you canot use full code generation - some bits have to implemented in the source, not in the model. I sometimes find it funny to hear us software developers talk about business logic. If the business logic really would be logical in a mathematical sense, we'd be able to do full code generation. Alas, it is not, thus we are required to write some source code.
Over the last years, quite a number of patterns have evolved for integrating generated and non-generated code. Some of them are protected regions, generation gap, recipe frameworks, particial classes and annotated models.
In this post, I want to concentrate on protected regions and the generation gap pattern, as these two have turned out to be used most often in model driven software development.
The question is, how do you distinguish generated code from non-generated code. Looking at average enterprise / JEE applications, one can see that the amount of generated code is much larger than the amount of manually crafted code. The developers working on your projects need to quickly be able to navigate to the places in the source code where they may insert hand crafted code.
Here are two things you can do.
Use Eclipse Color Decorators
If you use the generation gap pattern (illustrated below), you should set aside a source directory for all generated code, e.g. src-gen. Hand-crafted code (particularly the classes derived from the generated base classes) go to the src directory as usual.
Since all generated code is generated by your code generator, there is no need to check in generated code. You only have to version your model and the manually crafted code. To ensure developers do not accidentally check in generated code, you should add the src-gen directory to your .cvsignore (or .svnignore) file. Having the ignore file, you can now turn on Eclipse color decorators, which is the corner stone of this tip. Here's how:
- Open the preference dialog (Window > Preferences)
- Navigate to Team > CVS > Label Decorations
- Tick the Enable font and color decorations checkmark
- Navigate to General > Appearance > Colors and Fonts by clicking on the Colors and Fonts hyperlink below the check box
- In this dialog, change the color for Ignored Resource (Foreground) to silver or light gray
As a result, all ignored resource will appear in light gray (or any other color you might have chosen):

Use MINT
If you use protected regions, you need a way to decorate the parts in your code that won't be touched by the generator. The Eclipse Modeling Framework Technology project (EMFT) has a subcomponent which was written with this in mind - MINT.
Using MINT, you can highlight the parts of the source code which have been changed by you:

Today @ 18:00: Eclipse DemoCamp + Soccer in Hamburg
A friendly reminder to everybody who signed up for the Eclipse DemoCamp in Hamburg: the DemoCamp will start today at 18:00 - one hour earlier than originally announced!
The reason for starting at 18:00 is.... soccer! At 20:45, the German and Austrian soccer teams will meet in a critical play. Both Martin and I didn't think of this, until Matthias Lübken reminded us of the fact. Since we couldn't rearrange dates and / or rooms, we decided to just start earlier and finish early enough to watch the game together.
So, if you like socer, this is the perfect chance to combine Eclipse and soccer.
If you haven't heard of the DemoCamp before and would like to join - do not hesitate to add yourself to the list of attendees (you need a bugzilla account to do so), or drop me short mail so I can add you to the list.
So far, we've got 48 registrations, so this will be a nice crowd
We're looking forward to seeing you tonight!



