Editorials

Code Generation

In 1990 I was told that by the year 2000 there would not be a need for trained software developers anymore. Software development would no longer require complicated code writing and the likes. Instead, software development would simply be the process of plugging together different software modules in the form of objects. There would be a few software developers creating new custom objects; but the majority of the objects would already be defined.

Lately I heard another similar assertion that software development would be replaced by more sophisticated computers that were able to automatically create software. They would take our requirement as inputs, and output operating code following well know traditional software development patterns.

In a way we are closer to reality with the robot like generated code. We have a lot of code generators today for those things that follow a common pattern. For example, Telerik has code generator that can take a database first approach and generate an entire software solution with basic input screens, and database access following a repository pattern.

In the Dot Net world Code Smith came up with Net Tiers as a template driven code generator. It also produces a data access layer following a repository pattern. Additionally it creates stored procedures for all your database CRUD methods, and handles collections for complex objects based on database relationships.

More recently we have been introduced to the T4 templates. They follow the same technique as Net Tier templates. However, they are able to use definitions from either the database or the domain model as the basis for writing the data access layer. If using the Domain Model it generates the database tables. If using database first it generates a domain model.

Clearly these code generation tools can save a lot of time. But how do they work in the long run? Are you able to modify your domain objects? Do they provide interfaces? Do they following principles such as Open/Closed? Is there a point where your software becomes mature enough that it is no longer feasible to generate change through templates?

What has been your experience with code generation? Share your insights here or drop an email to btaylor@sswug.org.

Cheers,

Ben