To Generate or Not to Generate

Although code generators are extremely handy, they also lend themselves to code abuse. There are cases when it's better to make a good class library than it is to generate new classes. For example, you might create a code generator to make a mapping between an SQL database and a Java class. You are probably better off writing a library that does the mapping, however. Many times, you can put all the important information into a file or a small set of files rather than generating it into separate Java classes.

For example, when you deploy the application, you might want to change some of the database mappings. Do you really want to regenerate code when you could just edit a data file? When you use code generation, ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.