SPA Conference session: Dirty Jobs

One-line description:Add a new feature to our deliciously smelling legacy code. But... you have to write a test.
 
Session format: Tutorial (150 mins) [read about the different session types]
 
Abstract:When you start unit testing on an existing project, you are often confronted with code that is initially difficult to test. Dependencies are poorly managed and even writing the first unit test seems a sheer impossible task. Where and how do you start? Why is it your dirty job? Can you still leave before it is too late? Can anybody help?

In this hands on lab we will define the legacy problem code without tests and discuss the risks of making changes in such a code base. Then you can practice on real dirty legacy code, where we will guide you in some techniques to add features safely, avoiding pitfalls like task-scope creep.
 
Audience background:Developers. Experience with a curly brackets language (Java or C#)

Participants should bring laptops. We will work in pairs, only 1 laptop per pair is required. We will provide bootable USB sticks with a complete Java environment and exercises. We also have the exercise available in C#.
 
Benefits of participating:Get some concrete ideas to start doing test driven development and unit testing in existing code; practice some basic techniques for getting a first test in. When you succeed, the unshakable belief that anything is possible ;)
 
Materials provided:Handouts with some (UML :) ) diagrams of how the major pieces fit together. We will provide bootable USB sticks with a complete Java environment and exercises. Participants can choose to install on their own machine (and risk losing time. to each their own).
 
Process:Participants work in pairs. We'll have pairs explain their work on the projector.

Participants should bring laptops. We will work in pairs, only 1 laptop per pair is required. We also have the exercise available in C#.
 
Detailed timetable:15 Introduction
20 Inspect code
25 Debrief
5 Story 1 intro
25 Pairs work on story
10 Debrief, with some theory about seams & enabling points
25 Pairs continue working on the story
25 Debrief & closing

total:
150 minutes

We did this in 90 minutes once, wasn't a big succes. To be able to have a majority of the participants complete the first exercise 120 min. is needed at least. 150 minutes gives a nice amount of time for quality debriefing.
For those rare people who go fast, we have an additional exercise.
 
Outputs:Posters with code smells identified by the participants.
Participants can take their code home, but we don't publish it, as that may spoil it for future participants.
 
History:Rob Bowley remarked at Software Craftsmanship last year "why don't you run this at SPA". I thought we already had, but it seems not. Ran at Agile Cambridge (the too short version), xp days benelux, in open space at xp days london and we do this exercise in courses.
We are thinking of creating a new exercise (Dirty Jobs, the Next Generation), so that people who have been before can participate again (suggestion by Gojko Adzic). Suggestions for a topic welcome (current one is distribution and threading with both not separated in the code :) . Thinking of doing a small legacy rails 2 app with rspec, refuctoring it to make it more database dependent with some nice code in templates and monkeypatching for #goodmeasure, and giving the challenge to migrate it to rails3.2 (rspec api and rails api changed. #painful) after adding a feature. Will change session description as appropriate.
 
Presenters
1. Willem van den Ende
Living Software B.V.
2. Rob Westgeest
Westgeest Consultancy
3.