PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

C H A P T E R 7


■ ■ ■


What Are Design Patterns?


Why Use Them?


Most problems we encounter as programmers have been handled time and again by others in our
community. Design patterns can provide us with the means to mine that wisdom. Once a pattern
becomes a common currency, it enriches our language, making it easy to share design ideas and their
consequences. Design patterns simply distill common problems, define tested solutions, and describe
likely outcomes. Many books and articles focus on the details of computer languages, the available
functions, classes and methods. Pattern catalogs concentrate instead on how you can move on from
these basics (the “what”) to an understanding of the problems and potential solutions in your projects
(the “why” and “how”).
In this chapter, I introduce you to design patterns and look at some of the reasons for their
popularity.
This chapter will cover



  • Pattern basics: What are design patterns?

  • Pattern structure: The key elements of a design pattern.

  • Pattern benefits: Why are patterns worth your time?


What Are Design Patterns?


In the world of software, a pattern is a tangible manifestation of an organization’s tribal
memory.

—Grady Booch in Core J2EE Patterns

[A pattern is] a solution to a problem in a context.

—The Gang of Four, Design Patterns: Elements of Reusable Object-Oriented Software

As these quotations imply, a design pattern is a problem analyzed with good practice for its solution
explained.

Free download pdf