Tuesday, June 3, 2008

Design Pattern in PHP: Template Method

This next design pattern should not be mistaken with the common template conception (see Web template) more commonly found in web-technologies.

The template method pattern is designed with a base class which contains an high-level recipe and relies on sub-classes to specify the ingredients. An example would be a template for publishing a table of objects: the template method base class would implement the publishing logic whilst the sub-class would extract the relevant data pieces to expose in the table.

The project is located at GoogleCode.