CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeremy D. Miller -- The Shade Tree Developer

Under the hood and working with .Net, TDD, Software Design, and Agile Stuff

Don't Check in Spike Code...

...into the trunk.

Just like the title says, do NOT check “spike” code into the source control trunk.  When you do an exploratory spike, you’re generally throwing good coding practices completely out the window.  You’re on a focused mission to “figure out how this gosh durned thing is supposed to work.”  The code that you write in a spike probably sucks anyway. 

Do spike whenever you’re unsure how to work with some new library or technology or to try out a new object structure – but put that code in a branch.  As soon as the spike has achieved its purpose, put that code aside, and write all new code in the trunk using TDD and your normal coding standards.  You know, the coding and design standards that you've adopted as a team because you think those standards lead to sustainable quality.  But Jeremy, I could just retrofit some unit tests around the spike code and call it good!  Maybe, but you better ask yourself, am I really going to put decent tests around this code?  Retrofitting unit tests never results in the same quality of tests as real test first development.  Besides, as I said earlier, spike code generally sucks anyway;-)



Comments

Dave Newman said:

I'm sure i'd do this in a branch more often if if SVN didn't make it so painful!

# November 11, 2008 11:38 PM

Jeremy D. Miller said:

Um, making a new branch in Subversion takes 5-10 seconds with Tortoise SVN?

# November 11, 2008 11:39 PM

Madhur said:

And the definition of spike code is ? Couldn't find online anything ..

# November 12, 2008 12:16 AM

Spike Code vs. Reference Architecture | Lambert on Development said:

Pingback from  Spike Code vs. Reference Architecture | Lambert on Development

# November 12, 2008 12:33 AM

Jeremy D. Miller said:

# November 12, 2008 12:50 AM

J.P. Hamilton said:

If TFS has one feature that is decent, it might be shelving. I've used it a couple of time for some spikes on my current project.

# November 12, 2008 9:13 AM

Kerry MacLean said:

An obvious corollary to this is to treat all code written in an active (non-throw away) branch as if it was to to go to production - that is, get your tests around it first, properly documented, etc. etc.

It seems like an obvious thing, but the amount of stuff that should be "spike" code embedded in production branches is scary.

# November 12, 2008 9:41 AM

Mike Moore said:

1) Use git

2) git stash

3) Reimplement your spike using TDD

Git allows you to stash your changes in such a way that you don't lose them and you don't have to commit them to your central repository. Even if you are using SVN, you should be using the git client because of situations like this. Better tooling FTW.

# November 12, 2008 1:26 PM

Sagum said:

What's a spike code

# November 13, 2008 2:04 AM

Colin Jack said:

Good reminder, I've been doing a lot of spiking recently and its difficult not to resist the urge to "just" add a few tests and use it in the main code base. As you say though its probably a bad idea.

# November 13, 2008 4:32 PM

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… said:

Pingback from  FreePress Blog » GR Shared Link - Don’t Check in Spike Code…

# November 15, 2008 12:10 AM

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… said:

Pingback from  FreePress Blog » GR Shared Link - Don’t Check in Spike Code…

# November 15, 2008 12:20 AM

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… said:

Pingback from  FreePress Blog » GR Shared Link - Don’t Check in Spike Code…

# November 15, 2008 12:50 AM

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… said:

Pingback from  FreePress Blog » GR Shared Link - Don’t Check in Spike Code…

# November 15, 2008 2:00 AM

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… said:

Pingback from  FreePress Blog » GR Shared Link - Don’t Check in Spike Code…

# November 15, 2008 3:00 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Jeremy D. Miller

Jeremy began his IT career writing "Shadow IT" applications to automate his engineering documentation, then wandered into software development because it looked like more fun. Jeremy previously worked as a systems architect building mission critical supply chain software for a Fortune 100 company and learned agile development practices as a .Net consultant at ThoughtWorks, one of the pioneers of agile development. Jeremy is the author of the open source StructureMap (http://structuremap.sourceforge.net) tool for Dependency Injection with .Net and the forthcoming StoryTeller (http://storyteller.tigris.org) tool for supercharged FIT testing in .Net. Jeremy's thoughts on just about everything software related can be found on his weblog "The Shade Tree Developer" at http://codebetter.com/blogs/jeremy.miller, part of the popular CodeBetter site. Jeremy is a Microsoft MVP for C#. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News

All opinions expressed here constitute my (Jeremy D. Miller's) personal opinion, and do not necessarily represent the opinion of any other organization or person, including (but not limited to) my fellow employees, my employer, its clients or their agents.

About Me

"Best Of" Compendium

StructureMap (Dependency Injection for .Net)

StoryTeller (Supercharged Fit)

Build your own Cab

TestDriven

MVP