Skip to content

Commit bf41b1d

Browse files
committed
Updates README.md:
- Adding class diagram - Adding Pros and Cons - replace "" with ''
1 parent b3ef214 commit bf41b1d

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎factory/README.md‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Wikipedia says
2929
3030
**Programmatic Example**
3131

32-
We have an interface "Car" and tow implementations "Ford" and "Ferrari".
32+
We have an interface 'Car' and tow implementations 'Ford' and 'Ferrari'.
3333

3434
```java
3535
/**
@@ -68,7 +68,7 @@ public class Ferrari implements Car {
6868
}
6969
```
7070

71-
Enumeration above represents types of cars that we support(Ford and Ferrari).
71+
Enumeration above represents types of cars that we support (Ford and Ferrari).
7272

7373
```java
7474
public enum CarType {
@@ -90,7 +90,7 @@ public enum CarType {
9090
}
9191
}
9292
```
93-
Then we have the static method "getCar" to create car objects encapsulated in the factory class "CarSimpleFactory".
93+
Then we have the static method 'getCar' to create car objects encapsulated in the factory class 'CarSimpleFactory'.
9494

9595
```java
9696
/**
@@ -122,13 +122,18 @@ Program output:
122122
This is Ford.
123123
This Ferrari.
124124
```
125-
## Applicability
125+
## Class Diagram
126+
![alt text](./etc/factory.urm.png "Factory pattern class diagram")
126127

128+
## Applicability
127129
Use the Simple Factory pattern when you only care about the creation of a object, not how to create and manage it.
128130

129-
## Disadvantages:
131+
## Pros
132+
* Allows keeping all objects creation in one place and avoid of spreading 'new' key value across codebase.
133+
* Allows to writs loosely coupled code. Some of its main advantages include better testability, easy-to-understand code, swappable components, scalability and isolated features.
130134

131-
The code becomes more complicated than it should be.
135+
## Cons
136+
* The code becomes more complicated than it should be.
132137

133138
## Related patterns
134139

‎factory/etc/factory.urm.png‎

24.8 KB
Loading

0 commit comments

Comments
 (0)