Code smells are essentially bits of bad practice that make your code needlessly harder to understand, bad code may be refactored away using the techniques expressed in this chapter. Code smells can usually violate somewhat fundamental software design principles and accordingly, can negatively impact design quality of the overall code.
Martin Fowler defined code smell by stating the following:
"a code smell is a surface indication that usually corresponds to a deeper problem in the system".
At the start of this book we discussed the term technical debt, in this sense, code smells can contribute to technical debt as a whole.
Code smell may not necessarily constitute a bug, it won't stop the execution of a program, but it can aid the process of introducing bugs later on and make it harder to refactor code to an appropriate design.
Let's cover some fundamental code smells that you may encounter when dealing with legacy PHP projects.
We will address some code smells and how to address...