Advantages
(+)
-
Avoids compile-time implementation dependencies.
-
Instead of instantiating concrete classes directly,
clients delegate instantiation
to a separate factory object.
-
Ensures creating consistent object families.
-
When an application supports
creating multiple families of related objects,
it must be ensured that a family of related objects
is created and used together
(see Sample Code / Example 3).
-
Makes exchanging whole object families easy.
-
Because a factory object encapsulates
creating a complete family of objects,
the whole family can be exchanged
by exchanging the factory object.
Disadvantages
(–)
-
Requires extending the
Factory interface
to extend an object family.
-
The
Factory interface
must be
extended to extend a family of objects
(to support new kinds of objects).
-
Introduces an additional level of indirection.
-
The pattern achieves flexibility by
introducing an additional level of indirection
(clients delegate instantiation
to a separate factory object),
which makes clients dependent on a factory object.