[ACCEPTED]-Coding Katas for practicing the refactoring of legacy code-legacy-code

Accepted answer
Score: 95

I don't know of a site that catalogs them 13 directly, but one strategy that I've used 12 on occasion is this:

  1. Find an old, small, unmaintained open source project on sourceforge
  2. Download it, get it to compile/build/run
  3. Read the documentation, get a feel for the code
  4. Use the techniques in Working Effectively with Legacy Code to get a piece of it under test
  5. Refactor that piece, perhaps fixing bugs and adding features along the way
  6. Repeat steps 4 through 6

When you find a part 11 that was especially challenging, throw away 10 your work and repeat it a couple times to 9 reinforce your skills.

This doesn't just 8 practice refactoring, but other skills like 7 code reading, testing, and dealing with 6 build processes.

The hardest problem is finding 5 a project that you're interested enough 4 in to keep working in. The last one I worked 3 on was a python library for genetic programming, and 2 the current one I'm working on is a IRC 1 library for Java.

Score: 21

I feel like necromancer replying to such 22 an old thread, but there is one thing that 21 would make for a worthy addition - Legacy Code Retreat.

Idea 20 is to have a Code Retreat with legacy code and try to 19 practice the very techniques for dealing 18 with such, but I can't see anything that 17 would ban you from simply using the code 16 prepared and practicing with it by yourself. Just 15 using it for creating a Golden Master makes 14 for an hour of work, and there's a lot more 13 you can do. If your kata usually last around 12 2 hours, I'd say just by splitting what 11 usually happens on LCR into kata gives you 10 four different things to work on.

There's 9 a GitHub repository by idea's author, J.B. Rainsberger, that 8 contains a simple legacy system that you 7 are to work with, Trivia Game.

From my experience 6 as organizer/participant, folks really liked 5 this and it was illuminating to see what 4 can be a problem in a legacy code and where 3 your refactoring can lead you astray (and 2 how!). Here's yet another account of how 1 it looks like, by Andreas Leidig.

Score: 21

Emily Bache has a github repository with 8 some refactoring katas: Emily Bache's Refactoring Kata Repo. There are variants 7 of KataYahtzee and KataTennis to refactor. Also, she 6 has a variant of the Gilded Rose Kata, which 5 was designed as a refactoring kata.

Also, she 4 has the Racing Car Katas in her repo: Racing Car Kata. The 3 Race Car Katas also include good exercises 2 for refactoring.

Those kata have the code 1 in multiple langauages:

  • C++
  • C#
  • Java
  • Javascript
  • Python
  • Ruby

More Related questions