Design Problems
-
Code Reuse / Redefining Parts of a Behavior
-
How can the invariant parts of a behavior be
implemented once
so that subclasses can implement the variant parts?
-
How can subclasses redefine certain parts of a behavior
without changing the behavior's structure?
-
Extending Behavior at Specific Points
-
How can subclasses extend a behavior
only at specific points (hooks)?
-
Controlling Subclassing
-
How can a class control how it is subclassed?
Refactoring Problems
-
Duplicated Code
-
How can common behavior among
classes
be factored out
and localized (generalized) in a common class?
Form Template Method (205)
[JK05]
"[…] common
behavior among subclasses should be factored
and localized in a common class to avoid code
duplication." [GoF, p326]