XPday London

Succeed With Large Refactorings - The Mikado Method

Session Title: Succeed with large refactorings - The Mikado Method

Submitters: Ola Ellnestam & Daniel Brolund

Abstract:
For any code-base, ill- or well-structured, there usually comes a time when you must change large portions of it to meet new functional requirements, a new business model, or just refactor it to make it read better. But when these change become too extensive, it is easy to get lost in a jungle of dependencies, or on a sea of broken code.

This session will present The Mikado Method, a systematic approach to create a map to your changes, using just pen-and-paper. It helps you visualize, plan and perform business-value-focused refactorings over several iterations, without ever having a broken code-base in the process. It enhances communication, collaboration and learning on a software development team, and it helps any individual stay on track.

The Mikado Method:
Code almost always depend on other pieces of code, hence one change often requires another in an entangled web. When working with software, one usually has to perform a series of refactorings before making the core change to the software, be it to enable adding a new feature or just making a part of the code read better.

This works like the game Mikado (pick-up sticks), where you have to pick up lower scoring sticks in a certain order to reach the higher scoring Mikado stick.

You can build your map of changes using analysis. We would like to present a less demanding way to build the map: 'The Naive Approach':

  1. You set up a goal for your change.
  2. Naively implement that goal, as you would wish it to be.
  3. Compilers, tests, analysis and common sense will then show you immediate problem areas with your naive solution.
  4. Resolutions to those immediate problems are noted as prerequisites to the goal.
  5. The current changes are reverted using e.g. a versioning system or undo.
  6. The prerequisites are now new goals. Repeat 2)-6) for each goal until you find no prerequisites.
  7. Continue perform changes that have no prerequisites. You will eventually have cleared the prerequisites of other changes that now can be performed. Repeat this step until done, or continue from 2) if you find new prerequisites.


This can be described as a depth-first recursion of refactoring dependencies.

A more extensive description can be found here http://bit.ly/bVa13.

Contents and time line:
This session contains some theory, but focuses mostly on hands-on working with code.

Part 1: Tutorial (30 min)
    * Introduction to the method and to refactorings (10 min)
    * The presenters demonstrates the method on an example problem, using Eclipse and Java (15 min)
    * Q&A (5 min)

Part 2: Dojo: Practice in pairs (60-90 min)
    * Repeating the same problem in pairs
    * Breaks for reflection and discussion
   
Part 3: Dojo: Free form (45-90 min)
    * Working on code in pairs or randori, using own code or repeating the example
    problem
    * Breaks for reflection and discussion

Part 1 is essential, part 2 will give hands-on practice and a deeper understanding. Part 3 can be an open space event.

TODO: What are the timeslots available?
   
Intended audience:
Developers that need to work their way out of messy code while continuously delivering new functionality. 
 
Prerequisites:
Ability to read and understand Java code. Intermediate programming skills in some language. Basic knowledge of refactorings.

Expected benefits:
Participants will get an easy-to-use tool to perform large and focused changes to their code bases. The tool helps to stay on track both over time and in coordinating a team.

Comments

From Ola Ellnestam [82.182.132.19] - 2009-09-28

We have a Java example prepared. It can be done in .Net (C#) as well. We currently don't have that prepared though. But it might be a good idea.

From Rob Bowley [84.233.151.226] - 2009-09-28

What language/s will be used for the code examples for the hands on part?

From Daniel Brolund [80.217.241.43] - 2009-09-12

Hi Mike,

We can shorten the introduction to 30 min (proposal updated), demonstrating the core of the method. It requires attendees to have some idea of what refactorings are, but I think that is fine.

 

From Mike Hill [82.23.4.132] - 2009-09-07

Hi Ola and Daniel,

This sounds interesting and fun. I like the interactive nature of your proposal. I wonder if you could shorten the demo part (just show first step, rather than continuation to end) and then let people try it for themselves. It would be interesting to reflect on different approaches without having seen the full solution. I think part 3 of the session could be a separate, follow-on open space session (if people wanted it).

From Ola Ellnestam [82.182.132.19] - 2009-09-06

The Mikado Method is pretty agnostic about underlying practices. However, what you're asking for will be covered, in an implicit way.

 

We will show a way to plan your refactorings and when carrying out the refactorings we lean a lot on tools, methods and patterns described by others. Among those Michael Feathers, Kent Beck, Marting Fowler and more.

Was that clarifying or more confusing? ;-)

From Luca Minudel (submitter) [87.5.185.37] - 2009-09-05

I'm interested in this topic to improve technical skills required to deal with large/legacy/complex code-base. I like to ear more on how other experienced programmers deal with this.

Some questions that I would like to be answered in this session:

- how is the Mikado method related to the coding techniques described in the WELC by Michael Feathers ?
- how is the Mikado method related to the responsive design and the design strategy of the safe steps of Kent Beck ( http://www.infoq.com/news/2009/06/responsive-design , http://www.slideshare.net/deimos/kent-beck-effective-design )
- how to plan the refactoring when using the Mikado method ?

 

 

From Luca Minudel (submitter) [87.5.185.37] - 2009-09-05

I'm interested in this topic to improve technical skills required to deal with large/legacy/complex code-base. I like to ear more on how other experienced programmers deal with this.

Some questions that I would like to be answered in this session:

- how is the Mikado method related to the coding techniques described in the WELC by Michael Feathers ?
- how is the Mikado method related to the responsive design and the design strategy of the safe steps of Kent Beck ( http://www.infoq.com/news/2009/06/responsive-design , http://www.slideshare.net/deimos/kent-beck-effective-design )

 

From 80.217.247.129 - 2009-08-24

Robert,
Often when working with software one has to perform a series of refactorings before making the core change to the software. This works much like the game Mikado (pick-up sticks), where you have to pick up lower scoring sticks in a certain order to reach the higher scoring Mikado stick, hence the name. (We will have a giant Mikado game to illustrate this)

The Mikado Method is a systematic way to examine software to find that critical path of refactorings. I have blogged shortly about it here http://bit.ly/bVa13. We are also in the process of writing a book on the method.

The example we use can be used in a dojo as well, and it is likely we will use it for the dojo to get it going quickly. The example can be brought home for more practice.

The walkthrough takes about 30 min. The dojo should probably be 45 min or more, depending on the schedule. I.e. we can do this session in 45 min (presentation and example), 90 mins incl a 45 min dojo, 180 min incl a longer dojo/working on own code.

We have good experience on running dojos from our monthly coding dojo at our Agical office. We haven't run this particular "kata" in public, but a lot of times when preparing the example.

 

 

 

From Ola Ellnestam [82.182.132.19] - 2009-08-21

Elevator-pitch: Mikado-method is a dependency graph of improvements. Where the root is the goal. Preferrably a business goal.

Depending on how much time we can use, we'd like the participants to bring their computers and real (refactoring)problems. Problems they feel are too large or too complex to easily get a view over.

We'd like to do it like this:

- Present the method.

- Then walk through a small, made up, problem together with the participants.

- (If time permits have) A mikado/coding session.

We have done this before. But then only step 1 and 2

 

 

From RobertChatley [94.194.205.196] - 2009-08-21

This sounds like an interesting topic. Can you explain a bit more about what the Mikado Method is, and how the session would proceed. Is there a presentation? Are there exercises for the attendees to do? Will they work on laptops or on paper? How much time would the session take?

Page

New
Edit
Rename
Versions

Menu

Edit Menu
Versions

Site

Changes
Index
Search
Templates

User

Log In

 
 

Last Modified 2009-09-28