File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,22 @@ Use the Abstract Factory pattern when
27
27
* a system should be configured with one of multiple families of products
28
28
* a family of related product objects is designed to be used together, and you need to enforce this constraint
29
29
* 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
+
30
46
31
47
## Real world examples
32
48
You can’t perform that action at this time.
0 commit comments