Are Code Generators incompatible with Agile Development?

Blogged under Code Generation, Software by Mark Dalgarno on Wednesday 22 November 2006 at 8:29 am

I recently asked a question over on cgn-talk (a Yahoo group associated with The Code Generation Network (note membership required)):

“Agile methods, such as eXtreme Programming, advocate doing the simplest thing that could possibly work when it comes to designing software. Does anyone have any thoughts on whether this means agile developers should avoid building their own code generators?”

Some interesting answers came up that I’ll try and paraphrase here:

  • Agile developers would advocate code generators as targets of refactorings much like patterns
  • Duplicate code in C++ can sometimes be refactored to C++ templates - a form of in-built code generator.
  • Code generation & reflection-based tools can enable more Agile development
  • Database access … is almost always better started with generators
  • Agile modelling and Code Generation are a perfect fit
  • I think the answer is no, or at least it should not be. A logical approach to code generation is to create the first prototype by hand. When it comes to the second, you refactor (as someone else pointed out, code generation can be perceived as refactoring). The third, etc are free.
  • Some agile shops prefer to do OR/M runtime mappers instead of code generation. I think the benefit could be achieved equally well with better long term consequences (for many projects) with code generation.
  • Where I think code generation really shines in agile is in refactoring / overcoming fear of bad code / architecture.
  • Code generators are part of the tools that we use every day for java development, tools like castor, hibernate, wsdl2java, XDoclet and other tools are or use code generators. The only difference is that we don’t think of them as code generation tools.

So, the answer seems to be that agile developers will use code generation tools if appropriate and will also consider creating a code generator, or refactoring to a generator, if that is appopriate.

Proudly powered by Wordpress - Theme Triplets Identification Band, the girlish style by neuro