The Template Pattern in PHP 5

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

...and I've finally completed my series of GOF design patterns using
PHP 5 with the Template Pattern.

This is a pretty useful pattern, and one that you could easily use
without even realizing it is a pattern.

Essentially you have an abstract template class that defines a
non-abstract method with an algorithm.  Also in the abstract template
class are more methods which said algorithm will use.  Some of these
methods are be abstract and must be defined by any concrete extending
classes, while others are not abstract and may be defined by any
concrete extending classes.  In the Template pattern, the non abstract
methods should do nothing if not extended.

Pretty simple, basic abstract class stuff.  One interesting point here
is that the algorithm in the abstract class controls the main flow of
things, where as ordinarily a method in the extending classes would do

Site Timeline