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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access