Part IV. Behavioral Design Patterns

Great discoveries and improvements invariably involve the cooperation of many minds. I may be given credit for having blazed the trail, but when I look at the subsequent developments I feel the credit is due to others rather than to myself.

Alexander Graham Bell

When new turns of behavior cease to appear in the life of the individual, its behavior ceases to be intelligent.

Thomas Carlyle

Societies have always been shaped more by the nature of the media by which men communicate than by the content of the communication.

Marshall McLuhan

Behavioral design patterns make up the plurality of design patterns offered by the Gang of Four. This section covers one class example (Template Method) and one object example (State), but Part V shows more behavioral patterns used with PHP/MySQL examples. All in all, Gamma, Helm, Johnson, and Vlissides provide eleven behavioral patterns:

  • Chain of Responsibility

  • Command

  • Interpreter (class type)

  • Iterator

  • Mediator

  • Memento

  • Observer

  • State

  • Strategy

  • Template Method (class type)

  • Visitor

The key to understanding behavioral design patterns is communication. The focus shifts from the objects and classes that make up a design pattern to the communication between objects and classes. In the truest form of composition, behavioral patterns are best understood in terms of how objects work together to perform tasks.

Behavioral patterns focus on communication between pattern participants

Figure 50. Behavioral patterns ...

Get Learning PHP Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.