Key Relationships
-
Strategy - Template Method - Subclassing
-
Strategy
provides a way
to change the algorithm/behavior of an object at run-time.
-
Template Method
provides a way
to change certain parts of the algorithm/behavior of a class
at compile-time.
-
Subclassing
is the standard way
to change the algorithm/behavior of a class
at compile-time.
-
Strategy - Abstract Factory
-
Strategy
A class delegates performing an algorithm to a strategy object.
-
Abstract Factory
A class delegates creating an object to a factory object.
-
Strategy - Abstract Factory - Dependency Injection
-
Strategy
A class can be configured with a strategy object.
-
Abstract Factory
A class can be configured with a factory object.
-
Dependency Injection
Actually performs the configuration
by creating and injecting the objects
a class requires.
-
Strategy - Decorator
-
Strategy
provides a way
to exchange the algorithm of an object at run-time.
This is done from inside the object.
The object is designed to
delegate an algorithm to a Strategy object.
-
Decorator
provides a way
to extend the functionality of an object at run-time.
This is done from outside the object.
The object already exists
and isn't needed to be touched.
That's very powerful.
-
Strategy - Command
-
Strategy
provides a way
to configure an object
with an algorithm at run-time
instead of committing to an algorithm at compile-time.
-
Command
provides a way
to configure an object
with a request at run-time
instead of committing to a request at compile-time.