| 
	
 | 
 Posted by ltruett@fluffycat.com on 08/30/06 15:10 
....and I've finally completed my series of GOF design patterns using 
PHP 5 with the Template Pattern. 
 
http://www.fluffycat.com/PHP-Design-Patterns/Template/ 
 
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 
this.
 
  
Navigation:
[Reply to this message] 
 |