What is a design pattern?
Let's look a little deeper into what a design pattern is before we dive into the specific patterns. As you may have begun to understand, there are virtually unlimited ways to write a program that does a simple thing. A design pattern is a solution to solve a recurrent and common problem. These problems are often so ubiquitous that even if you don't use a pattern deliberately, you will almost certainly be using one or more patterns inadvertently; especially, if you use third-party code.
To better evaluate the use of design patterns, we will look at three high-level measurements: coupling, cohesion, and complexity.
Coupling is the degree to which individual code components depend on other components. We want to reduce coupling in our code so that all of our code components operate as independently as possible. We want to be able to look at, and understand, each component on its own without needing a full understanding of the entire system. Low coupling also allows us...