Friday, September 03, 2004

Code Generation

I know there are lot of developers with mixed reactions about code generators.Ok,I'll speak for myself...I used to hate code generators and always looked at them with a doubt in my eye.But are code generators so bad? Well nowadays I am starting to trust them a little bit more than i usually do and use them in my day to day work a lot more...So recently came across an open source project in C# called Data Tier Generator available at http://sourceforge.net/projects/csharpdatatier/. Once your database is created in SQL server with all the relationships between tables, you can use the generator to generate stored procedures for accessing your tables and cSharp code for calling the generated stored procedures.The Data Tier Generator will generate stored procedures for common data access code such as insert,update,delete by primary key,select by primary key, delete by foreign key and select by foreign key.This is a very good example of how much work can be cut down by code generators.With the data tier generated you can quickly start coding the business classes and use the generated data tier to persist your business objects.
So if you are interested in writing your own code generators check out the book Code Generation in Microsoft.NET by Kathleen Dollard which uses a XSLT based approach for generating code.
And if you are not interested in code generators think again, there are a lot of areas in software development where you can cut out development time by automating repetitive tasks through code generation.This will allow you to focus more on tasks very specific for your business domain such as business rules.

No comments: