Spike Solutions

AUDIENCE

Programmers

We perform small, isolated experiments to inform our decisions.

You’ve probably noticed how much Agile teams value concrete data over speculation. Whenever you’re faced with a question, don’t speculate about the answer—conduct an experiment! Figure out how you can use real data to make progress.

That’s what spike solutions are for, too. A spike solution, or spike, is a technical investigation. It’s a small experiment, in code, to research the answer to a problem. It usually takes less than a day. When you have the answer, the spike is discarded.

NOTE

People often confuse spike solutions with walking skeletons: bare-bones code that demonstrates an idea from end-to-end. It’s the beginnings of a production implementation. In contrast, a spike is narrowly focused on a specific technical problem, and it’s thrown away afterward.

Spike solutions use code because nothing is more concrete. You can read as many books, tutorials, or online answers as you like, but to truly understand a solution, write working code. It’s important to work from a practical point of view, not just a theoretical one. The best way to do so depends on what you want to learn.

Design Experiments

If you have an idea for a design improvement, but you’re not sure how it will work out, you can spike the design. I’ll use this approach when I’m not sure if my design ideas will work as well as I think.

To spike a design, create a temporary, throwaway branch in your repository. In that temporary branch, you can experiment without having to worry about safe refactorings or passing tests. You don’t even need the code to work properly. The purpose of the spike is just to experiment with your design idea and see how it works in practice.

If your design idea doesn’t work out, delete the branch. If it does work out, you can keep it for reference, temporarily, but don’t merge it into your real code. Redo the change from scratch, this time taking care with your refactorings and updating tests as needed. When you’re done, delete the branch.

Avoid overusing design spikes. Although you’re welcome to create a design spike whenever it will help you understand your design options, they shouldn’t be necessary for every story. You should also be able to create new designs by starting with a simple, obvious approach that incrementally becomes more sophisticated, and you should be able to modify existing designs using reflective design.

Making Time for Spikes

Small, “quick question” spikes are usually performed on the spur of the moment. You see a need to clarify a small technical issue, you write and delete a quick spike, you move on.

Dependency and design spikes can happen in several ways. Sometimes, they’re planned intentionally, either with a spike story or a task. At other times, you won’t realize a story needs a spike until you’re in the middle of working on it. When that happens, you can either add a task to your planning board, or just work on the spike as part of your current task. Either way, your slack absorbs the cost.

Questions

What’s the difference between a prototype and a spike?

“Prototype” doesn’t have a strict definition, but it usually refers to incomplete or nonfunctioning software that’s made to mimic the final product. They’re often used to demonstrate UIs or to learn by building a throwaway version of the application.

Spikes are much more focused. They’re created to answer a narrow technical question, not to mimic the final product.

Should we pair or mob on spikes?

It’s up to you. Because spikes don’t need to be maintained, even teams with strict pair programming rules don’t require writing spikes in pairs.

One very effective way to pair or mob on a spike is to have one person research the technology while another codes. Another option is for people to work independently on separate approaches, each doing their own research and coding, then coming together to review progress and share ideas.

Should we really throw away our spikes?

Unless you think someone will refer to it later, toss it. Remember, the purpose of a spike solution is to give you the information and experience needed to solve a problem, not to produce the code that solves it. The real production code usually ends up being a better reference than the spike.

When should we create a spike?

Whenever it helps. Perform a spike whenever the constraints of writing production-grade code get in the way of figuring out a solution.

What if the spike reveals that the problem is more difficult than we thought?

That’s good; now you have information you needed to know. Perhaps your on-site customers will reconsider the value of the story you’re working on, or perhaps you need to think of another way to accomplish your goal.