About   Slides   Home  

Managed Chaos
Naresh Jain's Random Thoughts on Software Development and Adventure Sports
RSS Feed
Recent Thoughts
Recent Comments

Refactoring Fest


Provide the participants with a hands-on-experience of real world refactoring by taking an open source project and refactoring it.


Refactoring is a very well established practice not just in the Agile Community, but outside as well. Following are some of the books that have been published on this subject:

Unfortunately, in-spite of such great knowledge available, there are lots of misconceptions around refactoring. The word “refactoring” is often used in a broad context where “enhancement” or “rewrite” would be a better term, and can cause nightmares to project stakeholders.

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.



Intended Audience

This session is suited for developers and architects who are interested to learn how to refactor real projects.


After attending this session, the participants should be able to:

  • 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

Content Outline

Section 1 – 90 Minutes

Iteration 0 / Overview : 45 mins

  1. 20 mins: Quick overview about refactoring with some examples.
  2. 10 mins: High level overview of the open source project’s design
  3. 05 mins: The participants form pairs and each pair picks up a module/package of the open source project.
  4. 10 mins: The participants spend time understanding the functionality of the module/package picked up by the individual pairs.

Iteration 1 : 45 mins

  1. 10 mins: I’ll show 2-3 simple code smells, explain associated refactoring techniques.
  2. 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.
  3. 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

  1. The pairs swap partners so that each team gets a new member and one old member continues on the selected module/package.
  2. 10 mins: I’ll show 2-3 little more complicated code smells and explain associated refactoring techniques.
  3. Pairs try to apply these refactoring techniques for the next 15 mins.
  4. At the end of 15 mins we have another 15 mins demo and refactoring discussion.

Iteration 3: 40 mins

  1. The pairs swap partners again.
  2. 10 mins: I’ll show 2-3 more complicated code smells and explain associated refactoring techniques.
  3. Pairs try to apply these refactoring techniques for the next 15 mins.
  4. 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.
  • Either the participant get their own laptops with required software setup or we provide the participants with computers. We’ll need 10-15 computers for the participants. Each computer is set up for a pair [2 chairs]. The presenters will set up the computers with the required software a day in advance of their session.
  • 10-15 flip charts, one per team.

Pre-requisites for attending the session

  1. Object Oriented Programming
  2. Java and Servlets knowledge [don’t worry too much about this, pairing can save you]
  3. You need the following software setup on your machine before you come:
  1. Latest Eclipse IDE for Java Developers
  2. Latest Sun JDK
  3. Latest Apache Tomcat Web Server
  4. Latest Very Quick Wiki

Set up instructions:

  1. After downloading, JDK, install it
  2. Set the JAVA_HOME env variable is not already set
  3. Unzip eclipse and try running eclipse executable [eclipse.exe]
  4. Unzip tomcat and try running startup.bat or startup.sh from the bin folder
  5. Take the vqwiki war and drop it into tomcat/webapps folder. Depending on the version of vqwiki you have downloaded, there will be a folder created under tomcat/webapps called vqwiki-x.x.x Where x.x.x represents the version number. For the purpose of these set up instructions, please replace x.x.x with your correct version number. Example if you have downloaded vqwiki version 2.7.8, then replace x.x.x with 2.7.8
  6. Start your favorite browser and go to [http://localhost:8080/vqwiki-x.x.x] Make sure the vqwiki page shows up
  7. Go to tomcat/webapps/vqwiki-x.x.x/WEB-INF/classes folder. Copy all the files expect the vqwiki folder to WEB-INF/src folder
  8. In Eclipse, create a new project called vqwiki. While creating the new project select the option “create project from existing source” and point it to the tomcat\webapps\vqwili-x.x.x folder
  9. Project would have compile time issues, since it needs the servlet.jar which is under the tomcat/common/lib folder. Add it to the libraries under the Java Build Path tab. Make sure that the code compiles without any problems.
  10. If you don’t want to start and stop tomcat from command prompt, there is Sysdeo/SQLI Eclipse Tomcat Launcher plugin for eclipse which can simplify some of those issues. Please note that this is optional.
  11. If you want changes to your classes being automatically detected by Tomcat, add the following line to tomcat/conf/server.xml

<Context path=”/vqwiki-x.x.x” reloadable=”true” docBase=”vqwiki-x.x.x” />

Note: Some of you might already have lots of these set up. Use your judgment if you want to skip some steps.

    Licensed under
Creative Commons License