News Feed
Sections




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

Cormac' PHP Blog:
Practical example php implementation of the Observer pattern
October 14, 2010 @ 08:36:35

New from Cormac's blog there's a post looking at an implementation of the Observer design pattern in a bit more practical scenario than some other examples out there.

Observer is a pattern where an object called the subject maintains a list of dependents (observers) and notifies them of any state changes. I implemented this recently to log changes to an Account object, and to notify the account holder if their account had expire - here's the basics of the code, hopefully it'll help someone else figure out how the pattern works

The basis of the Observer pattern is that you attach these "observer" objects to a main object. These watch the object and see if something changes (like a property value) and react accordingly. For their example, they create a setup that extends the main Observer class to have some or the detection functionality built-in.

0 comments voice your opinion now!
practical example observer pattern


blog comments powered by Disqus

Similar Posts

Padraic Brady's Blog: An Example Zend Framework Blog Application - Part 1: Introductory Planning

Mark Brady's Blog: Closures in PHP 5.3

Zend Developer Zone: Data Migration and Import Examples

Jonathan Street's Blog: Book Review: "Practical Web 2.0 Applications with PHP" by Quentin Zervaas

JellyandCustard.com: Using DirectoryIterator to List Files in PHP


Community Events





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


podcast library composer interview symfony language artisanfiles laravel release opinion voicesoftheelephpant series conference tool version security list framework introduction community

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