About Me

Training

Nothin But .Net Developer Bootcamp

Navigation

Search

Categories

On this page

From CodeGen To TDD

Archive

Blogroll

 Agile Developer Venkat's Blog
 Ayende @ Blog
 B#
 Barry Gervin's Software Architecture Perspectives
 Boy Meets World
 Brad Abrams
 Canadian Developers
 Christopher Steen
 Claritude Software News
 Clemens Vasters: Enterprise Development and Alien Abductions
 Coding Horror
 Coding in an Igloo
 Dare Obasanjo aka Carnage4Life
 Darrell Norton's Blog [MVP]
 David Hayden [MVP C#]
 Don Box's Spoutlet
 Eric Gunnerson's C# Compendium
 EZWeb guy: Jeffrey Palermo [C# MVP]
 Fear and Loathing
 Generalities & Details: Adventures in the High-tech Underbelly
 Greg Young [MVP]
 Greg's Cool [Insert Clever Name] of the Day
 IanG on Tap
 Ingo Rammer's Weblog
 ISerializable - Roy Osherove's Blog
 James Kovacs' Weblog
 Jason Haley
 Jean-Luc David
 Jeremy D. Miller -- The Shade Tree Developer
 JetBrains .NET Tools Blog
 Jimmy Nilsson's weblog
 John Bristowe's Weblog
 John Papa [MVP C#]
 Jon Skeet's Coding Blog
 JonGalloway.ToString()
 Jump the Fence or Walk Around
 Lambda the Ultimate - Programming Languages Weblog
 Larkware News
 Lutz Roeder
 Marquee de Sells: Chris's insight outlet
 Martin Fowler's Bliki
 Mike Nichols - SonOfNun Technology
 MSDN Magazine - .NET Matters
 MSDN Magazine - All Articles
 OdeToCode Blogs
 Onion Blog
 Planet TW
 Raymond Lewallen [MVP]
 Rockford Lhotka
 RodMan's Corner
 Roger Johansson's blog
 Sahil Malik - blah.winsmarts.com
 Sam Gentile's Blog
 Scott Bellware [MVP]
 Scott Hanselman's Computer Zen
 ScottGu's Blog
 secretGeek
 Service Station, by Aaron Skonnard
 Signum sine tinnitu--by Guy Kawasaki
 Stephen Toub
 Steve Eichert's Blog
 Steven Rockarts
 The Blog Ride
 The Coding Hillbilly
 The Daily WTF
 TheServerSide.net: News
 Tim Gifford
 Vance Morrison's Weblog
 you've been HAACKED

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 407
This Year: 132
This Month: 3
This Week: 0
Comments: 1082

 Sunday, April 08, 2007
Sunday, April 08, 2007 8:46:39 PM (Mountain Standard Time, UTC-07:00) ( Agile )

One of my readers asked me a question that I thought I would share the answer to publicly. I have omitted his name to maintain his privacy:

Question:

I have been reading your blog for quite sometime now and had a quick question on TDD. I saw your screencasts and saw that you develop your tests first and then your actual classes. I use CodeSmith to generate most of my code although I tweak it to not be modeled exactly around my tables. Given this how do I make the jump to TDD? Using the method you showed, wouldn't it take a very long time to finish the project as you are hand coding each class one by one. I basically hand coded one module (from ASPX to all the way upto the backend) and then designed my CodeSmith templates around it.

 

My Answer:

 

The first step for you to make the jump to TDD properly is to drop the code gen tools for a while. The whole premise of TDD is to design your code using tests as the design artifact to help drive out the solution incrementally. Most code gen tools do a big bang approach of code gen which you as the developer then need to go in an tweak to make work for your scenario. Utilizing code gen will not help you get into the habit of:

 

·         Writing a failing test for a requirement.

·         Getting the test to compile

·         Coding up the necessary behavior to make the test pass.

·         Cleaning up

·         Continuing

 

One of the main reasons people have a hard time getting into TDD is that it is a radical departure from the way most people normally develop. In the beginning you will walk slowly, stumbling and falling often. The tests that you initially write may not be overly good. This is because you are now crafting your skills in a new art. Over time, what initially seemed alien and uncomfortable will seem normal, rapid, and welcoming.

 

“Wouldn’t it take a very long time to finish the project as you are hand coding each class one by one?”

 

One of the things that is hard to appreciate from the small video that I showed on DNRTV, is the tools and techniques that come into play when you become a proficient test driven developer. In the class that I just finished teaching in Richmond,VA, we built a full portion of an enterprise e-commerce application with a Rich Domain Model, O/R Mapping Layer etc all over the course of a week using Test Driven Development, Design Patterns etc. One of the comments that someone made was the fact that not once during the course of the week did I use studio to either compile or run the project!

 

Again, that might seem like something out of the blue, but it is the little things that make you much more proficient as you get more accustomed to TDD. Once you are into the swing of it, you can bring your CodeGen tools back into the mix where they make sense. More often than not, most people who get swallowed up by TDD start to seriously question the value of Code Gen tools. It’s not to say that they don’t have their place, their use just becomes considerably diminished to how you may be using it right now.

 

I hope this answers your question.