Changes

Jump to: navigation, search

Template Method

766 bytes added, 16:28, 19 March 2007
Pseudo Code
Source from Javacamp, http://www.javacamp.org/designPattern/template.html/
 
=== PHP 5.0 ===
 
<pre>
abstract class AbstractClass {
public final function templateMethod() {
print "AbstractClass::templateMethod() called.\n";
$this->mandatoryOperation();
$this->optionalOperation();
}
 
protected abstract function mandatoryOperation();
 
protected function optionalOperation() {
}
}
class ConcreteClass extends AbstractClass {
protected function mandatoryOperation() {
print "ConcreteClass::mandatoryOperation() called.\n";
}
 
protected function optionalOperation() {
print "ConcreteClass::optionalOperation() called.\n";
}
}
</pre>
 
Source from Zend Technologies, http://www.zend.com/zend/php5/php5-OOP.php?article=php5-OOP&kind=ph&id=3204&open=1&anc=0&view=1
== References ==
1
edit

Navigation menu