News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Label Media Blog:
Design Patterns in PHP - Observer Pattern
February 11, 2011 @ 11:03:21

Tom Rawcliffe has posted the latest in his design patterns series covering some of the most common patterns and how they would work in PHP. In this new post he looks at the observer pattern.

So far in my series of articles on design patterns in PHP we've looked at a creational pattern, a structural pattern and a behavioral pattern. Today I'll be taking a closer look at another behavioral pattern - the observer. The observer pattern (also known as the Subscribe/Publish Pattern) is used to notify one object, the observer, about a change of state from another object, the subject.

He gives the layout of the pattern in a simple UML diagram before moving into the description and code. His sample builds a Users object that has a set of observers on it. His custom observer is a logger that, when a change is made on the Users, it writes out a value of the current object.

1 comment voice your opinion now!
observer design pattern tutorial series


blog comments powered by Disqus

Similar Posts

HowTo Forge: Fedora 8 Server Setup - LAMP, Email, DNS, FTP, ISPConfig - Page 6

IBM developerWorks: Introduction to MVC programming with Agavi (Parts 4 & 5)

NetTuts.com: Build Ajax Data Grids with CodeIgniter and jQuery

PHPMaster.com: Implement Two-Way SMS with PHP

SpinDrop.us: Using Zend Search Lucene in a symfony app


Community Events

Don't see your event here?
Let us know!


library series introduction conference php7 extension opinion voicesoftheelephpant podcast community example symfony2 release laravel application api interview framework version performance

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework