Tuesday, January 24, 2012

Walking Skeletons and TODO Outlines

These days, applications are so complicated and contain so many layers that it's difficult to know where to start. Should you work bottom up or top down? How much should you work on one layer before starting to work on the next layer? How can you ensure that the layers work properly together? Building a walking skeleton and managing a TODO document in outline format are two techniques that work well together to conquer complex problems, even ones involving multiple layers. Best of all, you don’t have to worry about trying to get things right the first time or getting lost along the way.
A Walking Skeleton is a tiny implementation of the system that performs a small end-to-end function. It need not use the final architecture, but it should link together the main architectural components. The architecture and the functionality can then evolve in parallel. -- Alistair Cockburn
Building a walking skeleton is a great way to handle the complexity of dealing with multiple layers. Start with the simplest possible feature, and implement it top down. Ideally, the feature should force you to work your way all the way down the stack. The goal is to make sure the layers work together.

As you’re building the walking skeleton, you may think of many things that you need to add, test, or in general worry about. It's helpful to maintain a TODO document in outline format so that you can organize and plan your attack, especially when you’re working with multiple layers at the same time. Eventually, each TODO item can be transferred into a test, a piece of code, an issue in the bug tracking system, or perhaps just an email to someone else.

Once you’ve built a walking skeleton, should you go back to developing one layer at a time? For most applications where the cost of change is low, probably not. Actively building one layer at a time is frequently very inefficient. A more efficient approach is to focus on one feature at a time. Sketch out the feature using a set of TODOs and build it top-down, managing the TODOs as you go. If you focus on one feature at a time instead of one layer at a time, you won’t end up building a lot of code in different layers that never actually gets used. The time saved by only building what you need and only building it when you have all the information you need more than compensates for the refactoring time.

Thanks go to Chris Lopez for his help with this post.

3 comments:

Sam Rushing said...

I use that technique for pretty much any large project, but it works especially well with compilers... usually you start with a really small, toy version of the language, then put just enough meat on it to follow all the way through to the end. Not only does it give you a place to start hacking, and a framework, but more importantly it lets you find and fix any misunderstandings you may have earlier rather than later.

Shannon -jj Behrens said...

Yep. I've done a couple small interpreters, and I can't imagine doing it any other way.

killy said...

I've known that technique from the gaming industry, where it's called a "vertical slice". The name is taken from a piece of cake - when you get a slice of cake it contains a little bit of every layer for you to taste :)