1 Refactoring refactoring

 

This chapter covers

  • Understanding the elements of refactoring
  • Incorporating refactoring into your daily work
  • The importance of safety for refactoring
  • Introducing the overarching example for part 1

It is well known that high code quality leads to cheaper maintenance, fewer errors, and happier developers. The most common way to get high code quality is through refactoring. However, the way refactoring is usually taught—with code smells and unit testing—imposes an unnecessarily high barrier to entry. I believe that anyone can execute simple refactoring patterns safely with a little practice.

In software development, we place problems somewhere on the diagram shown in figure 1.1, indicating a lack of sufficient skills, culture, tools, or a combination of those. Refactoring is a sophisticated endeavor and therefore lies right in the middle. It requires each component:

1.1 What is refactoring?

1.2 Skills: What to refactor?

1.2.1 An example code smell

1.2.2 An example rule

1.3 Culture: When to refactor?

1.3.1 Refactoring in a legacy system

1.3.2 When should you not refactor?

1.4 Tools: How to refactor (safely)

1.5 Tools you need to get started

1.5.1 Programming language: TypeScript

1.5.2 Editor: Visual Studio Code

1.5.3 Version control: Git

1.6 Overarching example: A 2D puzzle game

1.6.1 Practice makes perfect: A second codebase

1.7 A note on real-world software

Summary

sitemap