Template

The next pattern that we are going to analyze is called Template and it also has a lot in common with the Strategy pattern. Template consists of defining an abstract pseudo class that represents the skeleton of an algorithm, where some of its steps are left undefined. Subclasses can then fill the gaps in the algorithm by implementing the missing steps, called template methods. The intent of this pattern is to make it possible to define a family of classes that are all variations of a similar algorithm. The following UML diagram shows the structure that we just described:

Template

The three concrete classes shown in the previous diagram, extend ...

Get Node.js Design Patterns - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.