mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-09-08 06:17:22 +00:00
docs: update abstract factory readme
This commit is contained in:
@@ -36,6 +36,10 @@ Wikipedia says
|
|||||||
|
|
||||||
> The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes
|
> The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes
|
||||||
|
|
||||||
|
Class diagram
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Programmatic Example of Abstract Factory in Java
|
## Programmatic Example of Abstract Factory in Java
|
||||||
|
|
||||||
To create a kingdom using the Abstract Factory pattern in Java, we need objects with a common theme. The elven kingdom needs an elven king, elven castle, and elven army whereas the orcish kingdom needs an orcish king, orcish castle, and orcish army. There is a dependency between the objects in the kingdom.
|
To create a kingdom using the Abstract Factory pattern in Java, we need objects with a common theme. The elven kingdom needs an elven king, elven castle, and elven army whereas the orcish kingdom needs an orcish king, orcish castle, and orcish army. There is a dependency between the objects in the kingdom.
|
||||||
@@ -165,10 +169,6 @@ The program output:
|
|||||||
07:35:46.343 [main] INFO com.iluwatar.abstractfactory.App -- This is the orc king!
|
07:35:46.343 [main] INFO com.iluwatar.abstractfactory.App -- This is the orc king!
|
||||||
```
|
```
|
||||||
|
|
||||||
## Abstract Factory Pattern Class Diagram
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## When to Use the Abstract Factory Pattern in Java
|
## When to Use the Abstract Factory Pattern in Java
|
||||||
|
|
||||||
Use the Abstract Factory pattern in Java when:
|
Use the Abstract Factory pattern in Java when:
|
||||||
|
|||||||
Reference in New Issue
Block a user