less than 1 minute read

use template method when you need a base class to contain a certain behaviour with some base algorithms while having the subclasses implement those other behaviours that can vary.

ie. an abstract class with final methods (methods that cannot be overridden in the subclasses)and abstract methods (these methods have to be implemented in the subclasses).

This is a good method for controlling at which point your classes can be subclassed.

Comments