Robert McLaws: FunWithCoding.NET

Public Shared Function BrainDump(ByVal dotNet As String) As [Value]

News

<script type="text/javascript"><!-- google_ad_client = "pub-4330602465258980"; google_hints = "ASP.NET, VB.NET, C#, C#.NET, WindowsForms, .NET Framework, VS2005, Visual Studio, XAML, WinFX, Windows Workflow, WPF, WCF, Atlas, NetFX3, Visual Studio Orcas"; google_ad_width = 120; google_ad_height = 240; google_ad_format = "120x240_as"; google_ad_type = "text_image"; google_ad_channel ="4997399242"; google_color_border = "B6C9E7"; google_color_bg = "EFEFEF"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "002C99"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<!--
-->

You should feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever. That said, I will most likely only delete abusive, profane, rude, or annonymous comments, so keep it polite, please.

Blogroll

Cool .NET Articles

My .NET Tools

My Builder.com Articles

My MSKB Articles

Blogging the AZDNUG: CodeSmith - Part 2

[7:15pm]

Generating Business Logic
CodeSmith generates classes for each table. These classes have relationships just like the tables have relationships. Each class' properties directly correspond to the fields in the DB table. These classes can be generated to either generate SPROCS or inline SQL. Ish was smart and avoided the Sproc/DA Query argument entirely, mostly for fear of igniting a war in the room. Good thing Rob Howard and Frans Bouma weren't here.

Right now, Ish is showing us how to add XML comments to each template. It's really cool how the CodeSmith IDE picks up the properties automatically and drops them into the properties window. That's pretty cool. The template that he's showing us even adds the execute permissions for the current user.

I'll tell you what, this guy knows CodeSmith cold. He even generated templates that add NUnit fixtures, methods, and namespaces. Thanks to Jamie Cansdale, I'm getting started into the Unit Testing world, so that ought to be interesting.

The biggest problem with code generators IMO is your inability to customized the code if you have to regenerate. Ish gave us a very common sense solution to that problem, by generating everything as base classes, and make your modifications to inherited classes. I had never thought of that, but I probably should have. It totally makes sense.

So far I'm liking how this thing works. I'm not sure how I feel about it in regards to other systems that I've seen/used (XHEO|Enterprise, LLBLGenPro, Etc), but it's been great. Gotta run, time for Pizza.

Posted: Jan 20 2004, 07:19 PM by interscape | with 2 comment(s)
Filed under:

Comments

Eric J. Smith said:

Wow! Sounds like a very nice presentation. I wish I could've been there to hear it. I need someone like Ish Singh here in Dallas. The local DNUG people have been begging me to do a presentation, but I am deathly afraid of public speaking. :-( Did you happen to catch Ish's email address? I would love to get in contact with him.

Thanks,
Eric J. Smith
http://www.ericjsmith.net/codesmith/
# January 20, 2004 11:36 PM

Frans Bouma said:

"The biggest problem with code generators IMO is your inability to customized the code if you have to regenerate. Ish gave us a very common sense solution to that problem, by generating everything as base classes, and make your modifications to inherited classes. I had never thought of that, but I probably should have. It totally makes sense."
True, that's called the strategy pattern: generate common code as base classes, offer abstract methods where details have to be filled in and if you can, generate those details. I use that too: I have a generic library which is customized by generated code (which fills in the blanks).

The real problem with code generators is the construction of the templates :) LLBLGen Pro also uses a template based generator system (which uses a NAnt structure so you can add your own code generating assemblies as well to produce code/alter things) and what I found out was that the most efficient way of writing templates is from existing code: thus first write the code in full (for example the code for 3/4 classes) then write the templates using that code. So, if there aren't templates which fit your needs, you have to get your hands dirty and have to spend a lot of time getting it right.
# January 21, 2004 4:17 AM