On Code Generators.

AngryCoder: "...the myth of the code generator."

.Avery Blog: "What he misses is that there are code generation tools out there like CodeSmith which make it very easy to generate select parts of your application."

Frans Bouma: "...the article misses the advantages of code generation and how it can benefit you in your daily life. I'd say: the article is totally wrong."

The last company I worked for (back in 1999-2000) produced a code generator. We took a UML model from Rational Rose and generated DB schema (complete with foreign key RI, auto-generated primary keys, etc...), stored procedures and VB business objects. We also had a rudimentary DHTML form designer which could look at one of our business objects and generate a basic UI with query/add/update/delete business logic. We could go to a prospect, create a couple of UML classes, generate all three tiers and demo a working app in about 10 minutes. Sure the UI was pretty ugly, but it was the time savings that our clients liked.

The Angry Coder dismissed the time saving idea because "You've got to pore through the code and figure out what the heck the tool just produced. That takes time." As much time as it takes to start from scratch? I don't think so. And what about templates? He never even addressed that issue and that's one of the things that can negate the "what did the tool just produce" issue. Tools like CodeSmith use ASPX style templates. Our generator integrated with the VBScript engine to do the generation. And you could create your own scripts to tailor the code generation to your liking. That's value.

Is code generation for everybody? Definitely not. I'm not going to try and sell a code generator to a Sam Gentile or an Ingo Rammer. Where we had success was internal IT shops that had to crank out utility apps for departments all the time. Simple DB add/update/delete/query code was 80% of their work. You give them a tool that reduces that time and frees them up to do other things and you've helped them out.

I think code generators are an extension of frameworks. With a framework (like .NET, Java, etc...) you've got a bunch of functionality pre-built for you -- this saves you time. With a code generator, you've got the ability to customize pre-built functionality. And you do it in a lot less time and with less debugging required. That's value.

3 Comments

  • Nail on the head. :)

  • The problem is not the marketplace that is described in the post, the problem with code generators is that marketing people sell this as a be-all end-all for development and will solve all development probloms. It takes too long to figure out what is wrong with the code when there is a problem. That is why code generators are bad (wish I could use a better word to describe it).

  • Wally,





    Bad marketing <> Bad product. I agree with your view of a lot of code-generator marketing. They claim to be able to solve all sorts of problems.





    If properly marketed as the tool they are (like an IDE or an add-on), they can be effective.

Comments have been disabled for this content.