Refactor Lessons Learned From The Bowling Game Kata (2/2)

It’s time to close it with the big finally, a technique that allows to refactor almost any code safely.

David Rodenas PhD

--

Learning to crush the old code with the Bowling Game Kata.

Probably the best contribution of the Bowling Game Kata is showing how we can replace a big part of code, gradually, step by step, without stopping delivery. Although the example is small, the concept is applicable to a development of any size. Just look for what you want to fix, no matter how big it is, and use this guide to make a plan to rewrite it.

On the previous article…

On the previous article, I have shown five lessons to improve refactors learned from the Bowling Game Kata:

  • Lesson 1: Refactor once it works. Prioritize making code functional before refactoring, as multitasking hinders the brain’s ability to simultaneously solve problems and optimize architecture.
  • Lesson 2: Add new code before removing old. Introduce new code before removing old to ensure stability; this step validates the new code’s functionality and avoids unintended side-effects.
  • Lesson 3: Remove the minimal amount of old code. Remove old code incrementally to easily identify issues; smaller changes minimize debugging time and cost, promoting efficient coding practices.
  • Lesson 4: Refactor only one aspect at a time. Focus on refactoring one aspect at a time; even with multiple improvements in mind, tackle them individually to maintain clarity and ensure effective changes.
  • Lesson 5: Leverage on the IDE. Use your IDE for smart refactoring. Its tools can automate tasks, reduce errors, and simplify complex coding processes.

Why the Bowling Game Kata? Introduced by Robert C. Martin, it is distinct from typical katas. Instead of solving a problem, it emphasizes replicating steps to grasp every detail. So, instead of coming up with our own way to refactor code, we can adopt Martin’s approach for his design…

--

--

David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.