From fb26d42b51300b1665dc3d792c6d12e7e3eff5a6 Mon Sep 17 00:00:00 2001 From: prafful1 Date: Sun, 7 May 2017 13:28:54 +0530 Subject: [PATCH] Few additions in README Added few more points in applicability and also some use cases and consequences. --- abstract-factory/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/abstract-factory/README.md b/abstract-factory/README.md index a3881b893..f153c1202 100644 --- a/abstract-factory/README.md +++ b/abstract-factory/README.md @@ -27,6 +27,22 @@ Use the Abstract Factory pattern when * a system should be configured with one of multiple families of products * a family of related product objects is designed to be used together, and you need to enforce this constraint * you want to provide a class library of products, and you want to reveal just their interfaces, not their implementations +* the lifetime of the dependency is conceptually shorter than the lifetime of the consumer. +* you need a run-time value to construct a particular dependency +* you want to decide which product to call from a family at runtime. +* you need to supply one or more parameters only known at run-time before you can resolve a dependency. + +## Use Cases: + +* Selecting to call the appropriate implementation of FileSystemAcmeService or DatabaseAcmeService or NetworkAcmeService at runtime. +* Unit test case writing becomes much easier + +## Consequences: + +* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time. + + + ## Real world examples