Interesting article.
Although I don't think build-time code-generation should be promoted and I don't think its a good trade-off against code complexity. I think its a very bad trade-off and I think it should be strictly avoided. Maintenance is the main reason.
* Complex applications have complex code anyway, you don't want to have a complex build process on top of that. * You still have to javadoc complex code more than simple code, and having it generated won't change that in any way. * Simple applications don't need to be made complex with a complex build process. * What executes is the code I see. No hidden "magic". We're not talking about AOP here. Even provided by a well-known tool, so-called "magic" has proven itself being barely maintainable because, over time, nobody remembers what it does. * Another well-known idiom is this: the complexity of the code-generation grows cubic to the complexity of the generated code. You end-up having to maintain your code-generation tool as well.
The only viable trade-off I see is One-shot code generation, because it doesn't add complexity to anything and the whole build process is simpler to maintain over time. This is very simple to achieve using your favorite IDE's code template features.
Note: readers might find the sample classes being a performance bottleneck due to the extensive use of the synchronized modifier.
|