O'Reilly logo

PHP Objects, Patterns, and Practice, Second Edition by Matt Zandstra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 10Patterns for Flexible Object Programming

With strategies for generating objects covered, we're free now to look at some strategies for structuring classes and objects. We will focus in particular on the principle that composition provides greater flexibility than inheritance. The patterns we examine in this chapter are once again drawn from the Gang of Four catalog.

This chapter will cover

  • The Composite pattern: Composing structures in which groups of objects can be used as if they were individual objects
  • The Decorator pattern: A flexible mechanism for combining objects at runtime to extend functionality
  • The Facade pattern: Creating a simple interface to complex or variable systems

Structuring Classes to Allow Flexible Objects

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required