Implementation Issues
-
Different Kinds of Operations
-
"To reuse an abstract class
effectively, subclass writers must understand which
operations are designed for overriding."
[GoF, p328]
-
Primitive operations
- abstract operations that
must
be implemented by subclasses; or
concrete operations that provide a default implementation
and can
be redefined by subclasses if necessary.
Primitive operations can be declared
protected
to enable subclassing over package boundaries
but keeping clients from calling them
directly (see Sample Code).
-
Final operations
- concrete operations that
can not
be overridden by subclasses.
-
Hook operations
- concrete operations that do nothing by default
and
can
be redefined by subclasses if necessary.
-
Template methods
themselves can be declared
final
so that they can not be overridden.