Do you have a question? Post it now! No Registration Necessary. Now with pictures!
August 27, 2006, 9:49 pm
rate this thread
5 with the Bridge Pattern, Flyweight Pattern, and Proxy Pattern. Here
now is my 20th PHP 5 design pattern example, the Interpreter Pattern.
In the Interpreter Design Pattern you define a language syntax, and
parse requests that use that syntax, and call the correct classes and
methods to handle the request.
An interesting pattern, although I don't think I've used it much in
systems I've worked on. It is probably indespensible if you are
writing a compiler.
The State Pattern in PHP 5
In the state pattern a class will change it's behavior based on
circumstances. In my example a subclass of a specific interface may
actually switch the class being used to another subclass of the same
When I first drew up this example yesterday evening, based on one I did
a few years back in Java, I was pretty enthusiastic about it. Now, I'm
not sure I like it 100%, and may still tinker with it. I guess this
proves that these are perhaps "living examples", just my best try at an
example of a given pattern, are not set in stone, and may change. I
also have a comments section with each pattern, so please feel free to
point out flaws or applaud any examples if you like.