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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.