Follow @PDSAInc Code Generation - Paul Sheriff's Blog for the Real World

Paul Sheriff's Blog for the Real World

This blog is to share my tips and tricks garnered over 25+ years in the IT industry

Paul's Favorites

Code Generation

I have been speaking at a lot of user groups lately and I always ask how many people are generating code. It is astounding to me just how many people DO NOT do this! Programmers are still writing CRUD (Create, Read, Update, Delete) logic by hand! Code generation has been around for years. Why not take advantage of it? You could use the built-in tools in .NET or go out and purchase an excellent code generation tool like CodeSmith (http://www.codesmithtools.com/).

 If you have not tried generating code yet for your basic stored procedures and classes to call those stored procedures, what are you waiting for? Jump in! The water is fine! We all need ways to speed up our development cycle, code generation is one way to do it.

There are a lot of reasons for using Code Generation, here are a few:

·        Generation of INSERT, UPDATE and DELETE statements

·        Generation of stored procedures to do INSERT, UPDATE and DELETE

·        Bullet proof code for doing the Create, Read, Update, Delete (CRUD) logic

·        Ability to regenerate CRUD classes if schema changes

·        Consistency of code from one application to another

·        Moves SQL out of the UI tier and into a middle tier where it belongs

·        Moves the dependence on a particular database provider out of the UI

·        Reduces code complexity in the UI layer

·        Ability to map columns to properties in a class

·        Provide IntelliSense of tables, stored procedures, views and columns

·        Provides strong-typing of data in one location

·        Ability to customize templates to fit “your” style

·        Abstracts and encapsulates all data access code

·        Ability to separate programmers working on UI and data access

 

Comments

Balachandar said:

Hi,

MyGeneration is much better and is free too!!!

Though I liked codesmith well, it is costly.

So MyGeneration became a choice for code generation.

# January 4, 2007 11:41 PM

Evoluteur said:

There is also Evolutility CRUD framework.

http://www.evolutility.org

# February 24, 2009 8:27 AM