Refactoring: Improving the Design of Existing Code

Refactoring: Improving the Design of Existing Code

Martin Fowler

📅 Finished on: 2022-02-20

💻 IT
⭐️⭐️⭐️⭐️

It is easy to write code that a machine understands. What is hard is writing code that a human understands

Recommended by Mr. Rip; it uses JavaScript. I agree: an excellent book on refactoring, with very clear examples and step-by-step explanations, and it reinforced the importance of tests.

I will apply these ideas in practice; it is hard to discuss them without examples, but the approach is:

  • Work in small steps, saving and committing often to make sure you do not break the code
  • Make everything more readable by working on function names and removing repetition; it does not matter if loops run more times. Optimization is a different concern
  • It clarified the use of classes for me; it is helpful to see what you can do with encapsulation and inheritance
  • I now understand getters and setters in JavaScript better
  • As for the rules, it offers many recipes, such as extracting blocks of code into functions or classes, reorganizing, removing redundant code. Familiar techniques, but the clear examples made them easier to see

Overall, a useful and well-written book, relevant and important as a strategy to apply. I already knew some of this, but I found interesting ideas.