Jeremy D. Miller -- The Shade Tree Developer

Sponsors

The Lounge

Syndication

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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;-)


Posted Tue, Nov 11 2008 10:15 PM by Jeremy D. Miller

[Advertisement]

Comments

Dave Newman wrote re: Don't Check in Spike Code...
on Tue, Nov 11 2008 11:38 PM

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

Jeremy D. Miller wrote re: Don't Check in Spike Code...
on Tue, Nov 11 2008 11:39 PM

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

Madhur wrote re: Don't Check in Spike Code...
on Wed, Nov 12 2008 12:16 AM

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

Spike Code vs. Reference Architecture | Lambert on Development wrote Spike Code vs. Reference Architecture | Lambert on Development
on Wed, Nov 12 2008 12:33 AM

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

Jeremy D. Miller wrote re: Don't Check in Spike Code...
on Wed, Nov 12 2008 12:50 AM
J.P. Hamilton wrote re: Don't Check in Spike Code...
on Wed, Nov 12 2008 9:13 AM

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.

Kerry MacLean wrote re: Don't Check in Spike Code...
on Wed, Nov 12 2008 9:41 AM

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.

Mike Moore wrote re: Don't Check in Spike Code...
on Wed, Nov 12 2008 1:26 PM

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.

Sagum wrote re: Don't Check in Spike Code...
on Thu, Nov 13 2008 2:04 AM

What's a spike code

Colin Jack wrote re: Don't Check in Spike Code...
on Thu, Nov 13 2008 4:32 PM

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.

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… wrote FreePress Blog » GR Shared Link - Don’t Check in Spike Code…
on Sat, Nov 15 2008 12:10 AM

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

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… wrote FreePress Blog » GR Shared Link - Don’t Check in Spike Code…
on Sat, Nov 15 2008 12:20 AM

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

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… wrote FreePress Blog » GR Shared Link - Don’t Check in Spike Code…
on Sat, Nov 15 2008 12:50 AM

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

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… wrote FreePress Blog » GR Shared Link - Don’t Check in Spike Code…
on Sat, Nov 15 2008 2:00 AM

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

FreePress Blog » GR Shared Link - Don’t Check in Spike Code… wrote FreePress Blog » GR Shared Link - Don’t Check in Spike Code…
on Sat, Nov 15 2008 3:00 AM

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

Add a Comment

(required)  
(optional)
(required)  
Remember Me?