The Team is struggling to pay off the Technical Debt (or mess) that they’ve spent the last six months accumulating. They’ve started to institutionalize writing Unit Tests (by adding it to “Done”) and they’re using Sonar to help track Code Coverage, PMD warnings, et al. (Ed: Don’t take Sonar or any other measure as more than a first order view of the code. It hints where you need to look, no more).
During the Standup Ian reports that he is starting his third day of refactoring, a monster class called BuyABook. ScrumMaster Steve’s antenna goes up immediately, after all the team had split all tasks in one day or less. After standup he stops to have a quick chat with Ian to find out what is up. Ian explains that this class depends on many other classes and as a result it is very difficult to test. He continues that he’s been reading the Feathers book: “Working Effectively with Legacy Code” but it’s a struggle to put the ideas into practice. When he’s finished, Steve talks to Doug and Martin finding that they’re having similar problems.
Steve puts on his thinking cap. He knows the team needs practice and knows that they need a safe place to do it before they use the ideas in the main stream code. After a few minutes Goggling, he stumbles on the idea of coding dojos and, based on the experience of others, TDD Randori Session, TDD Randori Workshop and My First Coding Dojo. The idea behind a Coding Dojo is taken from the world of Martial Arts. It is just a safe place to practice. In this case Steve imagines the team would like to be able to practice the ideas that Feathers proposed, either on an artificial problem or on a small problem in their own code base. He sees them getting together in a meeting room with a projector and solving a small problem as a team.
Reading the experience posts, Steve learns:
- It’s best to start with small problems
- Bring a real mouse, not just a laptop trackpad
- Pair Programming is best – one driver and one navigator
- Ask the pair to explain their decisions, making it clear to the audience what is happening. In addition it keeps the audience engaged.
- Rotate the pair partners every 5-7 minutes
- Get enough Pizza for everyone
- 90-120 minutes is about the right length
- Small steps
- Ask questions if you don’t know what’s going on
- Hold a retrospective at the end
Steve gathers the team together and proposes the idea. They agree instantly, but Ian points out that “BuyABook” class is awfully large to get their heads wrapped around in 90 minutes. Instead they agree to tackle a smaller problem and get the “ChargeBookToMasterCard” under test. They agree to run the Dojo the next day at lunch.
They gather in a meeting room with a projector, a laptop, and a couple of other developers from a sister team that is also working on the bookstore. Steve had invited everyone to spend a few minutes preparing for the session by studying the code beforehand. After a brief introduction to Coding Dojos (see Wouter Lagerweij’s presentation via Slideshare), Ian frames the problem. ChargeBookToMasterCard is difficult to test because all the existing constructors require access to the MasterCard processing server.
After a few minutes of struggling to understand the myriad of methods on the Mastercard, they realize that “ChargeBookToMasterCard” really only uses three of those of methods. They conclude that using a Facade to wrap the MasterCardProcessor is the simplest way to go. With the Facade they can either pass in the real MasterCard processor, or a fake that can be used for testing. (Ed: Yes, this essentially manual mocking and real Mock tool would be faster to use). Once they’re able to construct a “ChargeBookToMasterCard”, now they can start trying to test the public methods and refactor the ones which are complex. At the end of 90 minutes they’ve got a good start at refactoring a previously challenging class. If they’re happy with the code quality they could check it in, otherwise a developer can use the work as inspiration to do the actual tidy up. Since Coding Dojos invite us to take risk, they usually don’t result in code that you can use.
During the retrospective, Ian says that the exercise has helped him see a way of biting off smaller chunks of work when paying down technical debt. In addition, Doug says he now has a much better understanding of the payment system. The team agree to hold another Coding Dojo next week.
For a couple hours of time and the price of some pizza the team members have gained a little confidence at doing something that had previously seemed hard and risky. While there are still many more hills to climb, knowing that it’s possible is often one of the biggest barriers to paying down Technical Debt. When we see just how small some problems are, it becomes a bit easier. In addition, all the developers on the team have learned some new ideas today. It will take months to get the team to the place that we see as possible, but they will only get there one step at a time.
 I always take exception to this misuse of the word “refactoring”. Refactoring is “a series of small behavior preserving transformations”. When we have to talk about a multi-day refactoring it’s long past the point of small. If they must happen, I call them rework or rebuilding.
 Serendipity. Just after inventing “ChargeBookToMasterCard” I grabbed Feathers’ Legacy Code book of the shelf, opened a random page, and found a very detailed example of the problem we will tackle on pages 106-113 The Case of the Irritating Parameter (link to Google Books)
Scrum by Example is a narrative-style blog series designed to help people new to Scrum, especially new ScrumMasters. If you are new to the series, we recommend you check out the introduction to learn more about the series and discover other helpful articles.
Mark Levison has been helping Scrum teams and organizations with Agile, Scrum and Kanban style approaches since 2001. From certified scrum master training to custom Agile courses, he has helped well over 8,000 individuals, earning him respect and top rated reviews as one of the pioneers within the industry, as well as a raft of certifications from the ScrumAlliance. Mark has been a speaker at various Agile Conferences for more than 20 years, and is a published Scrum author with eBooks as well as articles on InfoQ.com, ScrumAlliance.org an AgileAlliance.org.
Ryan Cromwell says
I organize two groups in which we generally practice through Katas: https://cincycleancoders.com and https://daytoncleancoders.com. We most often use Randori katas at the Cincy group.
This came out of similar problems and exercises with a few teams I worked with as a coach. Great stuff.
Mark Levison says
Thanks Ryan – its great to hear of your success. I hope eventually to hear that many companies adopt this simple way of learning so people don’t to take time outside of work do improve.
Ilan Kirschenbaum says
It takes some courage to setup the dojo the first time. But after one positive experience, the team will not go back
I also liked the use of design patterns – design patterns should be means, not goals in their own right. there is great advantage to know design patterns. but one must appreciate that they are not a solution in their own right
Thanks for an encouraging post!
Mark Levison says
Ilan – thanks for taking the time to comment. One of the key things is making the first dojo a great experience for all involved.
Ashish Gupta says
Very Useful post. Thanks
“The Team are struggling to payoff the Technical Debt (or mess) that they’ve spent the last six months accumulating. ”
Why did team accumulate the technical debt (or mess)? What could have we done to prevent accumulating that debt in first place?
Mark Levison says
Thanks for the comment Ashish – obviously the team is newer to Scrum. In this case I don’t think they were ready to improve their engineering techniques. For a team that was ready I suspect that learning Test Driven Development and Acceptance Test Driven Development would have helped a great deal.