views:

60

answers:

1

I work on an EMF project. One of the design decisions was not to touch the generated code and not to check it in. Instead, whenever something needs to be changed, a sub-class is created that contains the changes. The framework is flexible enough to deal with this. However, I experience some work overhead.

The design decision was made on the base of bad experiences with other code generation frameworks were re-generation let to problems.

Being new to the project I would like to challenge that design decision but would like to hear the general opinion first. I know that the EMF project team recommends the in-code changes. But what are your experiences? How well does EMF handle manual code changes in the generated code? Did you ever come to a point where you lost manual written code? Did the code ever get into a non-maintainable state?

Many thanks in advance!

+2  A: 

But what are your experiences?

I've implemented two separate projects, both of which involved models with 50 or more model classes, and in both cases the models evolved throughout the lifetime of the project; i.e. lots of model changes. In both cases, I modified the generated code to typically to implement computed attributes, validation and to customize the editors in various ways.

How well does EMF handle manual code changes in the generated code?

It works well. Occasionally the generator produces code the doesn't compile due to some model change, but the fixes are typically simple; e.g. deleting Java classes/interfaces, dead imports, etc.

Did you ever come to a point where you lost manual written code?

Only very occasionally. Once in a while you forget to remove the "generated" marker comment and your method gets clobbered when you regenerate the model.

(I suppose if it was a major concern you could modify the EMF generator to always backup the source tree before merging in changes.)

I guess that the most irritating thing was that the generated code had to be formatted. Unfortunately, the Eclipse code formatter is pretty crass, but if you manually reformat, your formatting changes get clobbered next time you regenerate. But that's just irritating ... not something that is worth jumping through hoops to avoid.

Did the code ever get into a non-maintainable state?

Nope. Not ever.

Stephen C