At
CodeMash I attended the precompiler event, 'Putting the D&D Back Into TDD' by
Guy Royse (@guyroyse) and
George Walters II (@walterg2). Now I'm an old school D&D player at heart so this abstract was right up my ally.
Abstract: Are you tired of TDD workshops that make you do boring things like calculate bowling scores and prime factors or demonstrate how to win at the game of life? If so, this is the session for you! In this TDD workshop we will be building the domain model for EverCraft -- a new MMORPG from Blizzards of the Coast. We have lots of story cards prepared covering features from combat to magic, classes to spells, and races to items. Plus, we'll be defining some of these cards during the session in case you want that +9 knife of ogre slaying or enjoy casting magic missile at the darkness. This workshop is language agnotisic and for all levels of developers. The focus is on TDD and emergent design but pair programming will be covered as well. The only requirement is that you bring a laptop and that you be able to test-drive you code with your language of choice. When you are done you will emerge a better programmer for the experience but there is small chance you will have a craving for Cheetos and Mountain Dew.
Early in the session George said something that had a huge part in the development of this blog. While talking about agile practices and paired programming in particular he said, "Let's be honest, programming alone is scary." I laughed a little and then the thought kept coming back to me throughout the day and ever since.
"Let's be honest, programming alone is scary."
~ George Walters II
As promised we were given a sheet of features then instructed to team up with another dev who was using the same language. Then we started. The workflow was simple. One of us would write a failing test, the other would implement the code to make the test pass, and then the first dev would refactor the implemented code.
At first we were unsure of ourselves and decided that maybe we knew better. We would take and write two tests; one each. Then we would switch and implement the other's test at the same time. Then we would refactor together and this seemed to work out alright for us. After our first iteration we had a retrospective and talked about our workflow. Guy and George talked us into doing it the more purer way, so after lunch we did and realized some major benefits.
Benefits of TDD & Ping Pong Pairing:
- Focusing on the acceptance test stopped me from over designing the solution.
- Writing the failing test makes you think about how you would like to use a class and its methods.
- Implementing code to make the test pass kept me focused on the test at hand vs. stuff we are probably not going to need. YAGNI
- Watching each other program and discussing the problems together helped each of us learn.
- We both had intimate knowledge of the codebase when we were done.
- Working on things together kept us from becoming distracted by outside influences (email, phone calls, day dreaming etc). We continued to code for almost 8 hours with only a few breaks.
- We knew when we were done with our feature.
Something that I came away with is that Test Driven Development is less about testing and more about designing. I watched a video about TDD that used the analogy of tests being like a carpenter's jig for the woodworker. There is a difference in that the developer only writes his/her test right before coding it while the carpenter starts with a complete jig.
This event motivated me to get back into
Luncht with Brian. We have been using Google Hangouts to do our ping pong pairing and have done three sessions so far. It's been very cool learning the workflow together and I'm hoping that we will be writing more about this as life permits.