Design patterns
Now we have had a look at clean code, the next thing to learn about in this chapter is design patterns. As explained previously, these are tried and true code patterns that you can use to solve common problems. They provide well-used structure and nomenclature that makes your code clear in terms of what it does and also provides you with a scaffold to build upon when solving common problems.
Design patterns are generally grouped into four categories. The following sections detail the four categories, with some examples of each. Rather than trying to provide full code examples for each pattern (which would take up way too many pages), I am simply going to describe the pattern and then link to examples within open source code bases. For Model, View, Controller (MVC) and Dependency Injection (DI), we have a chapter dedicated to each.
Creational patterns
Creational patterns are used when creating class instances. These make sense when the process of building or...