4. Template Method

In many cases, an algorithm or process consists of several steps that are needed by many applications and one or more steps that may be unique to each application. The Template Method pattern implements the common steps within a reusable class while still enabling application-specific customization.

The Template Method pattern is also called the “Hollywood Pattern” because of the Hollywood cliché, “Don’t call us; we’ll call you.” The Template Method pattern identifies one or more methods that will be called automatically as needed by existing code but should not be called directly by application code.

A Template Method is nothing more than a special case of a method that is expected to be overridden in subclasses. The –dealloc ...

Get Cocoa Design Patterns now with O’Reilly online learning.

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