Typed Data Objects - Code Generation

  • I could not read the article (http://qa.sqlservercentral.com/articles/articlesexternal.asp?articleid=1296) since it was in Italian but I gathered a little bit of what it was about. I have been trying to promote more code generation her at SQLServerCentral based on my personal experience but I wanted to reach a wider audience this time. If you identify one or more repetative patterns in your regular development routine, consider using or building a tool to generate the code for you.

    Here are some of the benefits of code generation that I have personally seen:

    • Reduced coding time for common situations. How often do you write the same stored procedure, particular CRUD procedures, for a different table? Sure, it will take a few hours to write and test a code generator that can do this but the long term time savings really do add up.
    • Reduced testing time! That's right, if you have built a code generator and tested the output thoroughly, why would you continue to test it or the code it creates?
    • Reduced boredom. Is this not the bane of a developer's existence? It sure is mine. I hate writing the same code patterns all the time, so I don't any more. The second time I need the same piece of code I look at the likelihood of needing to write it a third time. If it looks like there is a good chance that I will need to do it again, I write a code generator instead. It usually takes the same or less time to write a code generator than it does to write the code twice if you have a good generator framework (See below). You should always write it the first time by hand so you have defined the pattern you want created by the code generator.

    And finally, here are some code generation resources I have mentioned in other forums:

    • Code Generation Network - great big site dedicated to its namesake including books, architectures, etc. The web site is http://www.codegeneration.net.
    • CodeSmith - A solid generator for .NET and T-SQL or just about anything else. If you need to write your own scripts you will need to know ASP .NET and will want to fork out $80 to get the Professional edition that enables the use of the CodeSmith Studio IDE which is indispensible for debugging the scripts. Many common scripts are included in the free version and can be executed through a command line interface or through a Visual Studio .NET 2003 add-in. The CodeSmith web site is http://www.ericjsmith.net/codesmith/

    [font="Tahoma"]Bryant E. Byrd, BSSE MCDBA MCAD[/font]
    Business Intelligence Administrator
    MSBI Administration Blog

  • I know my friend Jon Winer (columnist) likes CodeSmith, havent had a chance to try it. Code generation is indeed worth doing in places. I use the VB6 stored procedure add in a LOT for ADO work, very worthwhile.

  • I will try to write an article for the site if you're interested. I have been meaning to write several articles for some time now but can rarely find the time to sit down and pen one. This is a topic that is very near to my heart as a developer and I have a lot more information to share.

    [font="Tahoma"]Bryant E. Byrd, BSSE MCDBA MCAD[/font]
    Business Intelligence Administrator
    MSBI Administration Blog

  • We'll definitely take you up on that! I've forwarded article standards to your email address.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply