Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Are You Missing Out on Code Generation? : Page 2

Writing EJBs by hand is a waste of effort and time; using the passive wizards in today's IDEs is just as bad. The solution is to use active code generation. Learn why code generation is a good idea despite all the FUD against it.


advertisement
The Advantages of Code Generation
Having addressed the issues engineers have with generators, let's talk about the positives behind generation—the things that show the value of a generated code base over its hand-coded equivalent.

Quality
The quality of generated source code is directly related to the quality of the templates. This is a big advantage because as you increase the quality of the templates over time you will also increase the quality of the entire code base. You can start out with a relatively lightweight pass at the templates and then make them more robust in an iterative process as your gain understanding of the framework and proper error handling. Contrast this process with hand-written code, which will have unreliable quality over time as interest in the project ebbs and flows.

There's another quality advantage, too. Let's face it, bug fixing is always about effort vs. reward. Fixing 300 hand-coded classes one by one is a lot harder than fixing one template and generating the 300 classes again. Systemic bugs are much more likely to get fixed in generated code bases. In addition, optional enhancements to increase the stability or functionality of the code base are much more likely to happen. For all of these reasons, a generated code base is much more agile and robust than its hand-coded equivalent.



Consistency
Generated code bases are extremely consistent in interface definition. This make it easier to hand-write code on top of generated APIs. It also makes it easier to build other layers of generated code on top of them.

The advantage of componentization and APIs is to create complexity barriers. The interior of a component may be extremely complex but its interface should present the abstraction of the component in as simple and consistent a manner as possible. Code generation does not guarantee that a set function will set things and that a get will get things, but it does guarantee that all the sets and gets will work the same way. This means fewer surprises for the engineers, which equates to more productivity and fewer bugs.

Once code is hand-written by an engineer he turns his attention to something else and the old code starts to atrophy until someone gives it some more attention. Generated code is continuously maintained by the generator. Every generation cycle replaces the entire generated code base with fresh code. When bugs are fixed in the templates they are propagated across all of the code consistently. So the output code is always better maintained than its hand-coded equivalent.

Productivity
The productivity of the engineering group is unquestionably enhanced by code generation. On its face a generator that builds hundreds of cookie cutter EJBs in seconds will outperform any human attempting the same task. But that's just the initial productivity increase.

The more important productivity increases are tied to the morale improvement you'll see in the engineers working on the project. They'll be happier because they will be making much more intelligent use of their time. Working smarter rather than harder is a clich



Jack Herrington is a senior software engineer with 20 years of experience. He is currently working for Macromedia on the next generation of Dreamweaver. His first book, Code Generation in Action (Manning Press) is due out in July. He is the editor of the Code Generation Network. Reach him by e-mail .
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap