CodeSmith Today. 02.22.2006

This isn’t a newsy bit on CodeSmith, though there is a pretty new 3.2.5 version of CodeSmith available if you’re still using 3.2.4 or earlier.  This post is more an example to serve as a nudgie for .NET developers who may not think in terms of Code Generation in everyday development.  I used this template a couple of days ago.  It’s a Data Layer oldie but goodie I wrote probably about two years ago to generate data update and entry methods for both a primary and secondary SQL table.

I don’t want to get sidetracked in the details of the CodeSmith Template (located here) or the generated code.  The point is that I was able to create a Data Layer Class that entered data into four different SQL tables in a matter of minutes using CodeSmith.  I passed a business object (also created in CodeSmith in a couple of minutes) to each method and had to edit some of the properties of that object generated from CodeSmith, but with full intellisense that was a snap.

Below is the Data Layer Class, minimized to demonstrate the amount of code generated.  An individual method is shown in the pull-out. To be able to knock out a utility class like this in such a short amount of time is a tribute to the power of CodeSmith and thinking in terms of Code Generation in everyday development. 

The result of course is more quality dog walking time.  A guy’s gotta have priorities.


Technorati Tags:

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.