August 2003
Intermediate to advanced
1104 pages
19h 27m
English
Observer is one of the most useful design patterns for developing large-scale object-oriented applications. It allows you, with the use of messages, to interconnect objects without their having to know anything about each other. At the heart of the Observer pattern are two main actors: observers and subjects. Observer objects find subject objects interesting and need to know when the subject changes. Typically, multiple observers monitor a single subject.
Listing 29.3 contains a simple implementation of the Observer pattern.
<?php interface Message { static function getType(); }; interface Observer { function notifyMsg(Message $msg); }; class Subject { private $observers = array(); function registerObserver(Observer ... |
Read now
Unlock full access