Chapter    26

The Template Method Pattern

The template method pattern allows for individual steps in an algorithm to be changed, which is useful when you are writing classes with default behavior that you want to allow to be changed by other developers. This is a simple pattern to understand and to implement, but it is widely used and can be found throughout most public frameworks, including those provided by Apple. Table 26-1 puts the template method pattern into context.

Table 26-1. Putting the Template Method Pattern into Context

Question

Answer

What is it?

The template method pattern allows specific steps in an algorithm to be replaced by implementations provided by a third-party, either by specifying functions as closures or by creating a ...

Get Pro Design Patterns in Swift 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.