File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,22 @@ Use the Abstract Factory pattern when
2727* a system should be configured with one of multiple families of products
2828* a family of related product objects is designed to be used together, and you need to enforce this constraint
2929* you want to provide a class library of products, and you want to reveal just their interfaces, not their implementations
30+ * the lifetime of the dependency is conceptually shorter than the lifetime of the consumer.
31+ * you need a run-time value to construct a particular dependency
32+ * you want to decide which product to call from a family at runtime.
33+ * you need to supply one or more parameters only known at run-time before you can resolve a dependency.
34+
35+ ## Use Cases:
36+
37+ * Selecting to call the appropriate implementation of FileSystemAcmeService or DatabaseAcmeService or NetworkAcmeService at runtime.
38+ * Unit test case writing becomes much easier
39+
40+ ## Consequences:
41+
42+ * Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time.
43+
44+
45+
3046
3147## Real world examples
3248
You can’t perform that action at this time.
0 commit comments