The Rules of Code Generation

Couple of days ago, I and Rob were discussing merits and pitfalls of template based code generation in llbgen and codesmith. Also, that it's a fallacy code generation has become somewhat synonym to ORM (Object Relational Modelling) and ORM faces several challenges when it comes to support legacy systems.

This reminded me of Kathleen Dollard, author of  “Code Generation on Microsoft.NET“ in August's INETA LA.NET developers group meeting on Code Generation listed the following six rules of code generation.

She said that initially it started with five rules as in her book.

  1. Generation is under your control.
  2. Metadata is a distinct morph-able entity.
  3. Generation is a repeatable, single click process.
  4. Handcrafted code is sacred and protected.
  5. Quality equals or exceeds manual apps in all areas.

Later on, she added the following.

5 1/2. Code generation should pay back on the first project.
5 3/4. There is no free lunch.
6. Code Generation should not be too complex.

By experience, I believe these rules stand correct if you are considering automated code generation. If interested, check out Raptier, LLBGEN, CodeSmith and Kathleen's website for further information.

Kathleen will also be speaking to Dev Connections.


One thought on “The Rules of Code Generation

Comments are closed.