This chapter offers a brief introduction to the topic of software design patterns. Throughout this book you informally encountered several design patterns including the Singleton, Factory, and the Façade. Here I will explain the meaning of the term design pattern, why they are considered to be a form of knowledge reuse, and how they can help you write better software.
Too many design patterns exist to offer them complete treatment in the limited space of this chapter. However, I feel it is important for you to at least understand how design patterns came to be and to learn a few of them to keep in your back pocket for use on your next project. To this end I will focus the discussion in this chapter on the purpose and use of the Singleton, Factory, Model-View-Controller, and Command patterns. I will show you how to combine these patterns to create robust, flexible application architectures. I will also show you how to separate business logic from presentation logic with the help of the Model-View-Controller pattern. Along the way you will also learn how to process application commands polymorphically using the Command pattern.
An understanding of design patterns will forever change the way you approach the task of building software architectures.