S.O.L.I.D. principles
To understand why design patterns work, we need to understand the principles that underpin good code. Let’s run a whistle-stop tour through most people’s first experience with code.
The universal Hello World program and the beginner exercises that follow are all made up of linear code. Linear code executes each line sequentially through a single file in which the whole program is written. Loops, selections, and statements make up literally everything.
As each program gets larger, the code becomes unsustainable. The solution is object orientation. Object-oriented programming (OOP) adds a lot, primarily classes and objects, as the name would suggest. With OOP’s added complexity, it becomes quite easy to accidentally build in fundamental issues with systems that make it impossible to expand them. Having a set of rules to follow greatly simplifies the process of building code that works for you and the next person to maintain it. These rules...