Code-Generation Techniques for Java
Subject:   Generation allows domain level description
Date:   2003-09-19 09:19:26
From:   anonymous2
A big advantage of code generation is it allows you to describe the problem at the level of the domain, rather than the code. You're basically creating a domain-specific language, which is compiled into Java (or something else), which is compiled into byte code.

We went from microcode to assembly to gain better abstraction, from assembly to high level languages, and code generation is just going up another level.

It only makes sense though if you have lots of somewhat similar objects (EJB's are good candiates) that you can describe. If you have lots of domain objects, but they're all relatively unique then code generation isn't going to help on that project.

Another advantage is that it's easier for non-programmers to review a domain-level description. Programmers review the the code generator, other folks review (or perhaps even write) the description that the code generator uses. It's also relatively easy to write lots of test cases descriptions to pass to the code generator and excercise those tests, often much easier than trying to write at the code level to create tests.