Video Script

In this chapter, we’re going to cover some basic software design patterns. A design pattern is a reusable structure or solution to a common problem that we can use in our code. By making use of these design patterns, we can build software in a way that is familiar to other developers who know the pattern. Instead of having to describe the overall structure of the code, we can simply say that it follows a particular pattern, which greatly simplifies things. Finally, by using these patterns, we can avoid reinventing the wheel and designing a structure to solve a problem when that problem has already been solved countless times before.

The concept of software design patterns really came to prominence with the publication of this book, Design Patterns: Elements of Reusable Object-Oriented Software in 1994. Even today, over 25 years after its publication, this book is still one of the most commonly used references for classic design patterns that we use today.

In fact, the four original authors, shown here, have been called the “Gang of Four” online, and many times you’ll see references to the “Gang of Four’s Patterns” when discussing this work with other developers or reading documentation online.

The original book contained three different categories of design patterns. The first are the creational patterns, which typically deal with creating or instantiating other objects that are used in our code. In this chapter, we’ll cover three of these patterns: the factory method pattern, the builder pattern, and the singleton pattern.

Next are the structural patterns, which are overall structures we may find in parts of our code to solve a particular problem. In this chapter, we’ll look a bit at the adapter pattern, which allows us to adapt one existing interface to match another interface.

Finally, we have the behavioral patterns, which are used to build specific operations or actions into our code. We’ll review the iterator and template method patterns in this chapter, which both allow our programs to perform some interesting and useful actions.

Overall, understanding some of these patterns is an important part of being a professional programmer. This will help you see how others have solved the same problems that you may face when writing your own applications, and you’ll be able to more directly communicate with other programmers who know the same patterns. Hopefully this information will be useful for you as you work on your projects in this class.