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

Commitd76715b

Browse files
authored
Merge branch 'master' into adapter-grammatical-fixes
2 parents647afad +c5a4068 commitd76715b

File tree

165 files changed

+4591
-688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+4591
-688
lines changed

‎.all-contributorsrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,33 @@
15411541
"contributions": [
15421542
"code"
15431543
]
1544+
},
1545+
{
1546+
"login":"samuelpsouza",
1547+
"name":"Samuel Souza",
1548+
"avatar_url":"https://avatars.githubusercontent.com/u/17254162?v=4",
1549+
"profile":"https://www.linkedin.com/in/souzasamuel/",
1550+
"contributions": [
1551+
"code"
1552+
]
1553+
},
1554+
{
1555+
"login":"marlo2222",
1556+
"name":"Marlo Henrique",
1557+
"avatar_url":"https://avatars.githubusercontent.com/u/40809563?v=4",
1558+
"profile":"https://github.com/marlo2222",
1559+
"contributions": [
1560+
"translation"
1561+
]
1562+
},
1563+
{
1564+
"login":"AndriyPyzh",
1565+
"name":"AndriyPyzh",
1566+
"avatar_url":"https://avatars.githubusercontent.com/u/57706635?v=4",
1567+
"profile":"https://github.com/AndriyPyzh",
1568+
"contributions": [
1569+
"code"
1570+
]
15441571
}
15451572
],
15461573
"contributorsPerLine":4,

‎LICENSE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright(c) 2014-2021 Ilkka Seppälä
3+
Copyright© 2014-2021 Ilkka Seppälä
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,3 +19,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22+
23+
Module Model-view-viewmodel is using ZK framework
24+
ZK framework is licensed under LGPL and the license can be found at lgpl-3.0.txt

‎README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
1111
[![Join the chat athttps://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1212
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section-->
13-
[![All Contributors](https://img.shields.io/badge/all_contributors-169-orange.svg?style=flat-square)](#contributors-)
13+
[![All Contributors](https://img.shields.io/badge/all_contributors-172-orange.svg?style=flat-square)](#contributors-)
1414
<!-- ALL-CONTRIBUTORS-BADGE:END-->
1515

1616
<br/>
1717

18-
Read in different language :[**zh**](/localization/zh/README.md),[**ko**](/localization/ko/README.md),[**fr**](/localization/fr/README.md),[**tr**](/localization/tr/README.md),[**ar**](/localization/ar/README.md),[**es**](/localization/es/README.md)
18+
Read in different language :[**zh**](/localization/zh/README.md),[**ko**](/localization/ko/README.md),[**fr**](/localization/fr/README.md),[**tr**](/localization/tr/README.md),[**ar**](/localization/ar/README.md),[**es**](/localization/es/README.md),[**pt**](/localization/pt/README.md)
1919

2020
<br/>
2121

@@ -329,6 +329,9 @@ This project is licensed under the terms of the MIT license.
329329
</tr>
330330
<tr>
331331
<td align="center"><a href="https://github.com/Xenilo137"><img src="https://avatars.githubusercontent.com/u/24865069?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Xenilo137</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Xenilo137" title="Code">💻</a></td>
332+
<td align="center"><a href="https://www.linkedin.com/in/souzasamuel/"><img src="https://avatars.githubusercontent.com/u/17254162?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Samuel Souza</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=samuelpsouza" title="Code">💻</a></td>
333+
<td align="center"><a href="https://github.com/marlo2222"><img src="https://avatars.githubusercontent.com/u/40809563?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marlo Henrique</b></sub></a><br /><a href="#translation-marlo2222" title="Translation">🌍</a></td>
334+
<td align="center"><a href="https://github.com/AndriyPyzh"><img src="https://avatars.githubusercontent.com/u/57706635?v=4?s=100" width="100px;" alt=""/><br /><sub><b>AndriyPyzh</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=AndriyPyzh" title="Code">💻</a></td>
332335
</tr>
333336
</table>
334337

‎abstract-factory/README.md

Lines changed: 18 additions & 18 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.
@@ -196,13 +196,13 @@ Example use cases
196196
* Unit test case writing becomes much easier
197197
* UI tools for different OS
198198

199-
##Consequences:
199+
##Consequences
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

205-
##Tutorial
205+
##Tutorials
206206

207207
*[Abstract Factory Pattern Tutorial](https://www.journaldev.com/1418/abstract-factory-design-pattern-in-java)
208208

‎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

‎adapter/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Use the Adapter pattern when
105105
* You need to use several existing subclasses, but it's impractical to adapt their interface by subclassing everyone. An object adapter can adapt the interface of its parent class.
106106
* Most of the applications using third-party libraries use adapters as a middle layer between the application and the 3rd party library to decouple the application from the library. If another library has to be used only an adapter for the new library is required without having to change the application code.
107107

108-
##Consequences:
108+
##Consequences
109109
Class and object adapters have different trade-offs. A class adapter
110110

111111
*Adapts Adaptee to Target by committing to a concrete Adaptee class. As a consequence, a class adapter won’t work when we want to adapt a class and all its subclasses.

‎bridge/README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Decouple an abstraction from its implementation so that the two can vary indepen
1919

2020
##Explanation
2121

22-
Realworld example
22+
Real-world example
2323

2424
>Consider you have a weapon with different enchantments, and you are supposed to allow mixing
2525
>different weapons with different enchantments. What would you do? Create multiple copies of each
@@ -161,27 +161,36 @@ public class SoulEatingEnchantment implements Enchantment {
161161
Here are both hierarchies in action:
162162

163163
```java
164+
LOGGER.info("The knight receives an enchanted sword.");
164165
var enchantedSword=newSword(newSoulEatingEnchantment());
165166
enchantedSword.wield();
166167
enchantedSword.swing();
167168
enchantedSword.unwield();
168-
// The sword is wielded.
169-
// The item spreads bloodlust.
170-
// The sword is swinged.
171-
// The item eats the soul of enemies.
172-
// The sword is unwielded.
173-
// Bloodlust slowly disappears.
174169

170+
LOGGER.info("The valkyrie receives an enchanted hammer.");
175171
var hammer=newHammer(newFlyingEnchantment());
176172
hammer.wield();
177173
hammer.swing();
178174
hammer.unwield();
179-
// The hammer is wielded.
180-
// The item begins to glow faintly.
181-
// The hammer is swinged.
182-
// The item flies and strikes the enemies finally returning to owner's hand.
183-
// The hammer is unwielded.
184-
// The item's glow fades.
175+
```
176+
177+
Here's the console output.
178+
179+
```
180+
The knight receives an enchanted sword.
181+
The sword is wielded.
182+
The item spreads bloodlust.
183+
The sword is swung.
184+
The item eats the soul of enemies.
185+
The sword is unwielded.
186+
Bloodlust slowly disappears.
187+
The valkyrie receives an enchanted hammer.
188+
The hammer is wielded.
189+
The item begins to glow faintly.
190+
The hammer is swung.
191+
The item flies and strikes the enemies finally returning to owner's hand.
192+
The hammer is unwielded.
193+
The item's glow fades.
185194
```
186195

187196
##Class diagram

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp