Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf6d4397

Browse files
iluwatarohbus
andauthored
docs: Grammatical fixes for Abstract Factory (iluwatar#1782)
* Grammatical fixes* Update abstract-factory/README.mdCo-authored-by: Subhrodip Mohanta <hello@subho.xyz>
1 parentc0d3689 commitf6d4397

File tree

10 files changed

+32
-35
lines changed

10 files changed

+32
-35
lines changed

‎abstract-factory/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ objects without specifying their concrete classes.
2020

2121
##Explanation
2222

23-
Realworld example
23+
Real-world example
2424

25-
>To create a kingdom we need objects with a common theme.Elvenkingdom needs anElven king,Elven castle andElven army whereasOrcishkingdom needs anOrcish king,Orcish castle andOrcish army. There is a dependency between the objects in the kingdom.
25+
>To create a kingdom we need objects with a common theme.The elvenkingdom needs anelven king,elven castle, andelven army whereasthe orcishkingdom needs anorcish king,orcish castle, andorcish army. There is a dependency between the objects in the kingdom.
2626
2727
In plain words
2828

@@ -34,7 +34,7 @@ Wikipedia says
3434
3535
**Programmatic Example**
3636

37-
Translating the kingdom example above. First of all we have some interfaces and implementation for the objects in the
37+
Translating the kingdom example above. First of all, we have some interfaces and implementation for the objects in the
3838
kingdom.
3939

4040
```java
@@ -52,21 +52,21 @@ public interface Army {
5252

5353
// Elven implementations ->
5454
publicclassElfCastleimplementsCastle {
55-
staticfinalStringDESCRIPTION="This is theElven castle!";
55+
staticfinalStringDESCRIPTION="This is theelven castle!";
5656
@Override
5757
publicStringgetDescription() {
5858
returnDESCRIPTION;
5959
}
6060
}
6161
publicclassElfKingimplementsKing {
62-
staticfinalStringDESCRIPTION="This is theElven king!";
62+
staticfinalStringDESCRIPTION="This is theelven king!";
6363
@Override
6464
publicStringgetDescription() {
6565
returnDESCRIPTION;
6666
}
6767
}
6868
publicclassElfArmyimplementsArmy {
69-
staticfinalStringDESCRIPTION="This is theElven Army!";
69+
staticfinalStringDESCRIPTION="This is theelven Army!";
7070
@Override
7171
publicStringgetDescription() {
7272
returnDESCRIPTION;
@@ -77,7 +77,7 @@ public class ElfArmy implements Army {
7777

7878
```
7979

80-
Then we have the abstraction and implementations for the kingdom factory
80+
Then we have the abstraction and implementations for the kingdom factory.
8181

8282
```java
8383
publicinterfaceKingdomFactory {
@@ -111,7 +111,7 @@ public class OrcKingdomFactory implements KingdomFactory {
111111
}
112112
```
113113

114-
Now we haveour abstract factory that lets us make family of related objects i.e.Elven kingdom factory createsElven castle, king and army etc.
114+
Now we havethe abstract factory that lets us makeafamily of related objects i.e.elven kingdom factory createselven castle, king and army, etc.
115115

116116
```java
117117
var factory=newElfKingdomFactory();
@@ -127,13 +127,13 @@ army.getDescription();
127127
Program output:
128128

129129
```java
130-
This is theElven castle!
131-
This is theElven king!
132-
This is theElvenArmy!
130+
This is theelven castle!
131+
This is theelven king!
132+
This is theelvenArmy!
133133
```
134134

135-
Now, we can design a factory for our different kingdom factories. In this example, we created FactoryMaker, responsible for returning an instance of either ElfKingdomFactory or OrcKingdomFactory.
136-
The client can use FactoryMaker to create the desired concrete factory which, in turn, will produce different concrete objects (Army,King,Castle).
135+
Now, we can design a factory for our different kingdom factories. In this example, we created`FactoryMaker`, responsible for returning an instance of either`ElfKingdomFactory` or`OrcKingdomFactory`.
136+
The client can use`FactoryMaker` to create the desired concrete factory which, in turn, will produce different concrete objects (derived from`Army`,`King`,`Castle`).
137137
In this example, we also used an enum to parameterize which type of kingdom factory the client will ask for.
138138

139139
```java
@@ -179,8 +179,8 @@ public static void main(String[] args) {
179179

180180
Use the Abstract Factory pattern when
181181

182-
* The system should be independent of how its products are created, composed and represented
183-
* The system should be configured with one of multiple families of products
182+
* The system should be independent of how its products are created, composed, and represented
183+
* The system should be configured with one ofthemultiple families of products
184184
* The family of related product objects is designed to be used together, and you need to enforce this constraint
185185
* You want to provide a class library of products, and you want to reveal just their interfaces, not their implementations
186186
* The lifetime of the dependency is conceptually shorter than the lifetime of the consumer.
@@ -200,7 +200,7 @@ Example use cases
200200

201201
* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time.
202202
* While the pattern is great when creating predefined objects, adding the new ones might be challenging.
203-
* The code becomes more complicated than it should be, since a lot of new interfaces and classes are introduced along with the pattern.
203+
* The code becomes more complicated than it should be since a lot of new interfaces and classes are introduced along with the pattern.
204204

205205
##Tutorial
206206

‎abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* <p>The essence of the Abstract Factory pattern is a factory interface ({@link KingdomFactory})
3939
* and its implementations ( {@link ElfKingdomFactory}, {@link OrcKingdomFactory}). The example uses
40-
* both concrete implementations to create a king, a castle and an army.
40+
* both concrete implementations to create a king, a castle, and an army.
4141
*/
4242
@Slf4j
4343
publicclassAppimplementsRunnable {
@@ -60,13 +60,13 @@ public static void main(String[] args) {
6060

6161
@Override
6262
publicvoidrun() {
63-
LOGGER.info("Elf Kingdom");
63+
LOGGER.info("elf kingdom");
6464
createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
6565
LOGGER.info(kingdom.getArmy().getDescription());
6666
LOGGER.info(kingdom.getCastle().getDescription());
6767
LOGGER.info(kingdom.getKing().getDescription());
6868

69-
LOGGER.info("Orc Kingdom");
69+
LOGGER.info("orc kingdom");
7070
createKingdom(Kingdom.FactoryMaker.KingdomType.ORC);
7171
LOGGER.info(kingdom.getArmy().getDescription());
7272
LOGGER.info(kingdom.getCastle().getDescription());

‎abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfArmy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
publicclassElfArmyimplementsArmy {
3030

31-
staticfinalStringDESCRIPTION ="This is theElven Army!";
31+
staticfinalStringDESCRIPTION ="This is theelven army!";
3232

3333
@Override
3434
publicStringgetDescription() {

‎abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfCastle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
publicclassElfCastleimplementsCastle {
3030

31-
staticfinalStringDESCRIPTION ="This is theElven castle!";
31+
staticfinalStringDESCRIPTION ="This is theelven castle!";
3232

3333
@Override
3434
publicStringgetDescription() {

‎abstract-factory/src/main/java/com/iluwatar/abstractfactory/ElfKing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
publicclassElfKingimplementsKing {
3030

31-
staticfinalStringDESCRIPTION ="This is theElven king!";
31+
staticfinalStringDESCRIPTION ="This is theelven king!";
3232

3333
@Override
3434
publicStringgetDescription() {

‎abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcArmy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
publicclassOrcArmyimplementsArmy {
3030

31-
staticfinalStringDESCRIPTION ="This is theOrc Army!";
31+
staticfinalStringDESCRIPTION ="This is theorc army!";
3232

3333
@Override
3434
publicStringgetDescription() {

‎abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcCastle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
publicclassOrcCastleimplementsCastle {
3030

31-
staticfinalStringDESCRIPTION ="This is theOrc castle!";
31+
staticfinalStringDESCRIPTION ="This is theorc castle!";
3232

3333
@Override
3434
publicStringgetDescription() {

‎abstract-factory/src/main/java/com/iluwatar/abstractfactory/OrcKing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
publicclassOrcKingimplementsKing {
3030

31-
staticfinalStringDESCRIPTION ="This is theOrc king!";
31+
staticfinalStringDESCRIPTION ="This is theorc king!";
3232

3333
@Override
3434
publicStringgetDescription() {

‎abstract-factory/src/test/java/com/iluwatar/abstractfactory/AbstractFactoryTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
importstaticorg.junit.jupiter.api.Assertions.assertTrue;
3030

3131
/**
32-
*Test for abstract factory.
32+
*Tests for abstract factory.
3333
*/
3434
classAbstractFactoryTest {
3535

3636
privatefinalAppapp =newApp();
3737

3838
@Test
39-
voidking() {
39+
voidverifyKingCreation() {
4040
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
4141
finalvarkingdom =app.getKingdom();
4242

@@ -51,7 +51,7 @@ void king() {
5151
}
5252

5353
@Test
54-
voidcastle() {
54+
voidverifyCastleCreation() {
5555
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
5656
finalvarkingdom =app.getKingdom();
5757

@@ -66,7 +66,7 @@ void castle() {
6666
}
6767

6868
@Test
69-
voidarmy() {
69+
voidverifyArmyCreation() {
7070
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
7171
finalvarkingdom =app.getKingdom();
7272

@@ -81,7 +81,7 @@ void army() {
8181
}
8282

8383
@Test
84-
voidcreateElfKingdom() {
84+
voidverifyElfKingdomCreation() {
8585
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ELF);
8686
finalvarkingdom =app.getKingdom();
8787

@@ -97,7 +97,7 @@ void createElfKingdom() {
9797
}
9898

9999
@Test
100-
voidcreateOrcKingdom() {
100+
voidverifyOrcKingdomCreation() {
101101
app.createKingdom(Kingdom.FactoryMaker.KingdomType.ORC);
102102
finalvarkingdom =app.getKingdom();
103103

‎abstract-factory/src/test/java/com/iluwatar/abstractfactory/AppTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
importstaticorg.junit.jupiter.api.Assertions.assertDoesNotThrow;
2929

3030
/**
31-
* Issue: Add at least one assertion to this test case.
32-
*
33-
* Solution: Inserted assertion to check whether the execution of the main method in {@link App}
34-
* throws an exception.
31+
* Check whether the execution of the main method in {@link App} throws an exception.
3532
*/
3633
classAppTest {
3734

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp