Clean Code Clinic: Refactoring Fest
Intent
Provide the participants with a hands-on-experience of real world refactoring by taking an open source project and refactoring it.
Summary
Refactoring is a very well established practice not just in the Agile Community, but outside as well.
This session is an attempt to help the development community understand refactoring a little better. It will provide a hands-on opportunity for developers to explore these concepts in action. This session will try to amplify the participant’s learning process by pairing them with other practitioners and peers.
Outline Section 1 – 90 Minutes
Iteration 0 / Overview : 45 mins
- 20 mins: Quick overview about refactoring with some examples.
- 10 mins: High level overview of the open source project‘s design
- 05 mins: The participants form pairs and each pair picks up a module/package of the open source project.
- 10 mins: The participants spend time understanding the functionality of the module/package picked up by the individual pairs.
Iteration 1 : 45 mins
- 10 mins: I’ll show 2-3 simple code smells, explain associated refactoring techniques.
- 15 mins: Each pair identifies one or more classes from the module/package, which has these code smells. They try and understand what it does, in the process they might do some basic refactorings like extract method and rename variables/methods. Eventually the goal is to writes one or more unit tests around it. Once they have sufficient passing unit tests [safety net], they start cleaning up code by applying some advanced refactoring techniques. In some cases, sufficient unit tests might not be required to do simple refactoring like extract method, rename variable, etc. Sometimes internally restructuring the code, can help us understand it better. Hence the participants will have to constantly switch between ‘understanding’, ‘unit testing’ and ‘refactoring’ hat.
- 20 mins: The pairs stops refactoring. Couple of pairs connect to a central project and demonstrates their accomplishment to the rest of the group. We can break into a discussion about each team‘s refactorings.
Break – 30 Minutes
Section 2 – 90 Minutes
Iteration 2: 40 mins
- The pairs swap partners so that each team gets a new member and one old member continues on the selected module/package.
- 10 mins: I’ll show 2-3 little more complicated code smells and explain associated refactoring techniques.
- Pairs try to apply these refactoring techniques for the next 15 mins.
- At the end of 15 mins we have another 15 mins demo and refactoring discussion.
Iteration 3: 40 mins
- The pairs swap partners again.
- 10 mins: I’ll show 2-3 more complicated code smells and explain associated refactoring techniques.
- Pairs try to apply these refactoring techniques for the next 15 mins.
- At the end of 15 mins we have another 15 mins demo and refactoring discussion.
10 Minutes - Retrospective
- What worked? The participants indicate what they learned.
- What did not work?
- What to do differently next time? Suggestions from participants on how to improve the session.
Infrastructure Required
- U shaped table setup with a projector at the center of the table which can connect to all the computers.
- Each participant need to get their own laptops with required software setup.
- 10-15 flip charts, one per team.
Pre-requisites for attending the session
- Object Oriented Programming
- Experience using a real world IDE
- Please bring your laptops with your favorite IDE
I’ll provide a code base (Java and .Net) on which we’ll do our refactoring exercise.
- Build a common vocabulary in the refactoring space
- Identify code smells
- Eliminate code smells by applying the simple refactoring techniques explained in Martin Fowler‘s “Refactoring”
- Write better unit/functional tests for legacy code
- Understand some of the techniques and pitfalls in refactoring legacy code in the absence of unit and functional tests [”Working effectively with legacy code “]
- Take existing code and refactor it to standard design patterns [Refactoring to patterns]
- Learn about the internals of the open source project chosen to refactor
- Know where to look to continue learning the techniques of refactoring

Add to calendar