In the last chapter, we took a look at the different elements involved in refactoring. In this chapter, we dive into the technical details to form a solid foundation of what refactoring is and why it is important from a technical perspective.
We start by reiterating the definition of refactoring that we use in this book: refactoring is making code better without changing what it does. Let’s break down the two main components of this definition: making code better and without changing what it does.
We already saw that better code excels in readability and maintainability and why that matters. But we did not discuss what readability and maintainability are, or how refactoring affects them.
Readability is the code’s aptitude for communicating its intent. This means that if we assume the code works as intended, it is very easy to figure out what the code does. There are many ways to communicate intent in code: having and following conventions; writing comments; variable, method, class, and file naming; using whitespace; and so on.