Geeks With Blogs
Jonathan Starr's Blog Thoughts on C#, Ajax, WCF, LINQ, Agile et al.
Leonardo da Vinci, when he painted Il Cenacolo, or as we call it here in the US, The Last Supper, produced studies for the work before he began to paint.  Later, when the painting was restored in the 1970s, researchers used infrared reflectoscopy to look underneath the outer coats of paint to find that the original work of art was in fact very different from what tourists had seen for the past few generations - mostly because of the poor showing conditions for the painting, but partly because Leonardo da Vinci painted in layers, and modified the painting in its creation.

Il Cenacolo - First Sketch
The 'First Sketch' of Il Cenacolo

Programming is not very different.  Many modern practitioners (and I count myself among them) believe that good production code is never created on the first try.  To facilitate this process, we write 'spikes' or trial applications to quickly flush out a good design that we can use for the final version.

Another modern software development methodology is (Test Driven Development).  TDD adherents believe that no code should be written without first writing a test that describes a software requirement, and only the minimum code needed to satisfy the test is written to make the test pass. 

The reasons provided for writing code this way are manifold:

- The lines of code needed for the application are minimized.
- By virtue of the process used for development, the code will have very few bugs as long as the correct requirements are used for the tests and the tests are written well.

So here is my conundrum:  Should we use TDD when we write spikes?

After all, I am throwing out the spike when I am done!  So...

- I am not concerned with minimizing lines of code, as I am not maintaining the code for a spike. 
- Also, I am not concerned if there are bugs in the spike.  It's never going into production.

In fact - and here's a major point - when I use TDD when I write spikes, invest so much time into writing the tests, and mocking or injecting dependencies, etc...  well it's easy to fall in love with your little TDD spike and keep it instead of buckling down to redesign the component into a thing of beauty.

On the other side, I know that TDD is a wonderful habit - and I should be writing using TDD as much as possible. Perhaps the extra TDD writing experience will do this coder some good.

What do you think?

Happy coding!

Jonathan Starr

improve my => 'code' Add to Google

Posted on Monday, August 4, 2008 7:54 PM Software Design , Software Development , Agile Development , TDD , Spike | Back to top


Comments on this post: Agile: Spikes With TDD - My Conundrum

# re: Agile: Spikes With TDD - My Conundrum
Requesting Gravatar...
Hi, Jonathan.
A spike is only there to test out something that you don't know if will work or not.
I have worked on some agile projects using Scrum, and I have never written tests when trying out something new in a spike.
I always time box the spike and want to try out as much as possible in that limited time. TDD works best when you know the technology you are working with well. As you say, a spike is always thrown away when you have tested the stuff you want to test, so using TDD in this scenario is meaningless in my point of view.
Left by Pål on Aug 05, 2008 2:36 AM

# re: Agile: Spikes With TDD - My Conundrum
Requesting Gravatar...
Maintainability is never a bad thing. Never forget that "today's prototype is tomorrow's production code." A perfect case in point for this is the Merchant Boarding subsystem at our work. It was put together as a "proof of concept" which when shown to management was met with the question "great, when can we roll it out?" So even if *you* plan to throw away your spike code, your customer/manager may have very different ideas.
Left by matt on Aug 10, 2008 7:13 PM

# re: Agile: Spikes With TDD - My Conundrum
Requesting Gravatar...
I bought this book on a whim and have bought 15 more for my 8th grade students and their families. I can't tell you how many parents have called to say what a great tool this has been to connect to their adolescent children.
Left by Giocare ai giochi del casinò on Feb 25, 2010 5:53 AM

# re: Agile: Spikes With TDD - My Conundrum
Requesting Gravatar...
I really like the metaphor used comparing Davincis painting to coding, the same steps apply to get the final product ready for use or visual. So do I think that TDD should be used when writing spikes? Definitely.
Left by make internet money on Feb 17, 2011 6:18 PM

Your comment:
 (will show your gravatar)


Copyright © Jonathan Starr | Powered by: GeeksWithBlogs.net