Design Problems
-
Creating Objects
-
How can a class be independent
of how the objects it requires are created?
-
How can a class request the objects it requires
(from a factory object)
instead of creating the objects directly?
-
How can a class delegate object creation
to a factory object?
-
How can a class be configured with a factory object?
-
Creating Different Object Families
-
How can families of related or dependent objects be
created?
-
How can be ensured that a
family of related or dependent objects
is created and used together (consistent object families)?
-
How can an application be configured with a family of objects?
-
How can a family of objects
be selected and exchanged at run-time?
Refactoring Problems
-
Inflexible Code
-
How can instantiating concrete classes throughout
an
application
(compile-time implementation dependencies)
be refactored?
-
How can object creation that is distributed across
an application
be centralized?
Move Creation Knowledge to Factory (68)
[JK05]
Testing Problems
-
Unit Testing
-
How can the objects a class requires
be replaced with mock objects
so that the class can be unit tested in isolation?