WHAT'S IN THIS CHAPTER?
No code is perfect. For developers, accepting this fact is very freeing. There will always be something you could have done better, although maybe you don't realize it at the time. Looking at code you've written in previous years, you may sometimes find small, subtle things you would like to change to make the code faster, more aligned with the business, or simply easier to maintain. Other times you may say, “If only I knew then what I know now, I would have done this completely different.”
Refactoring is the act of changing the internal implementation of a class or method with the aim of making the code more readable and maintainable. Refactoring also reduces the code's overall complexity without changing the external behavior of the class or method. These alterations can be as simple as changing the name of a method or variable to moving methods from one class to another or even splitting large classes into several smaller ones. Refactoring allows you to continuously change and improve your code.
This chapter explains why refactoring your code is important. It reviews object-oriented programming and the SOLID Principles. It also shows you some common coding and design problems, colloquially ...