Skip to content

Commit ff637de

Browse files
authored
Merge pull request #7 from iluwatar/master
Resync
2 parents 4476020 + fb2c026 commit ff637de

File tree

365 files changed

+8305
-454
lines changed

Some content is hidden

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

365 files changed

+8305
-454
lines changed

abstract-document/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ tags:
1212
## Intent
1313
Achieve flexibility of untyped languages and keep the type-safety
1414

15+
## Class diagram
1516
![alt text](./etc/abstract-document.png "Abstract Document Traits and Domain")
1617

1718

@@ -26,4 +27,4 @@ Use the Abstract Document Pattern when
2627
## Credits
2728

2829
* [Wikipedia: Abstract Document Pattern](https://en.wikipedia.org/wiki/Abstract_Document_Pattern)
29-
* [Martin Fowler: Dealing with properties](http://martinfowler.com/apsupp/properties.pdf)
30+
* [Martin Fowler: Dealing with properties](http://martinfowler.com/apsupp/properties.pdf)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
@startuml
2+
package com.iluwatar.abstractdocument.domain.enums {
3+
enum Property {
4+
+ MODEL {static}
5+
+ PARTS {static}
6+
+ PRICE {static}
7+
+ TYPE {static}
8+
+ valueOf(name : String) : Property {static}
9+
+ values() : Property[] {static}
10+
}
11+
}
12+
package com.iluwatar.abstractdocument.domain {
13+
class Car {
14+
+ Car(properties : Map<String, Object>)
15+
}
16+
interface HasModel {
17+
+ getModel() : Optional<String>
18+
}
19+
interface HasParts {
20+
+ getParts() : Stream<Part>
21+
}
22+
interface HasPrice {
23+
+ getPrice() : Optional<Number>
24+
}
25+
interface HasType {
26+
+ getType() : Optional<String>
27+
}
28+
class Part {
29+
+ Part(properties : Map<String, Object>)
30+
}
31+
}
32+
package com.iluwatar.abstractdocument {
33+
abstract class AbstractDocument {
34+
- properties : Map<String, Object>
35+
# AbstractDocument(properties : Map<String, Object>)
36+
+ children(key : String, constructor : Function<Map<String, Object>, T>) : Stream<T>
37+
+ get(key : String) : Object
38+
+ put(key : String, value : Object)
39+
+ toString() : String
40+
}
41+
class App {
42+
- LOGGER : Logger {static}
43+
+ App()
44+
+ main(args : String[]) {static}
45+
}
46+
interface Document {
47+
+ children(String, Function<Map<String, Object>, T>) : Stream<T> {abstract}
48+
+ get(String) : Object {abstract}
49+
+ put(String, Object) {abstract}
50+
}
51+
}
52+
AbstractDocument ..|> Document
53+
Car ..|> HasModel
54+
Car ..|> HasPrice
55+
Car ..|> HasParts
56+
Car --|> AbstractDocument
57+
HasModel --|> Document
58+
HasParts --|> Document
59+
HasPrice --|> Document
60+
HasType --|> Document
61+
Part ..|> HasType
62+
Part ..|> HasModel
63+
Part ..|> HasPrice
64+
Part --|> AbstractDocument
65+
@enduml

abstract-factory/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ public static void main(String[] args) {
157157
}
158158
```
159159

160+
## Class diagram
161+
![alt text](./etc/abstract-factory.urm.png "Abstract Factory class diagram")
162+
160163

161164
## Applicability
162165
Use the Abstract Factory pattern when
80.4 KB
Loading
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
@startuml
2+
package com.iluwatar.abstractfactory {
3+
class App {
4+
- LOGGER : Logger {static}
5+
- army : Army
6+
- castle : Castle
7+
- king : King
8+
+ App()
9+
+ createKingdom(factory : KingdomFactory)
10+
+ getArmy() : Army
11+
~ getArmy(factory : KingdomFactory) : Army
12+
+ getCastle() : Castle
13+
~ getCastle(factory : KingdomFactory) : Castle
14+
+ getKing() : King
15+
~ getKing(factory : KingdomFactory) : King
16+
+ main(args : String[]) {static}
17+
- setArmy(army : Army)
18+
- setCastle(castle : Castle)
19+
- setKing(king : King)
20+
}
21+
class FactoryMaker {
22+
+ FactoryMaker()
23+
+ makeFactory(type : KingdomType) : KingdomFactory {static}
24+
}
25+
enum KingdomType {
26+
+ ELF {static}
27+
+ ORC {static}
28+
+ valueOf(name : String) : KingdomType {static}
29+
+ values() : KingdomType[] {static}
30+
}
31+
interface Army {
32+
+ getDescription() : String {abstract}
33+
}
34+
interface Castle {
35+
+ getDescription() : String {abstract}
36+
}
37+
class ElfArmy {
38+
~ DESCRIPTION : String {static}
39+
+ ElfArmy()
40+
+ getDescription() : String
41+
}
42+
class ElfCastle {
43+
~ DESCRIPTION : String {static}
44+
+ ElfCastle()
45+
+ getDescription() : String
46+
}
47+
class ElfKing {
48+
~ DESCRIPTION : String {static}
49+
+ ElfKing()
50+
+ getDescription() : String
51+
}
52+
class ElfKingdomFactory {
53+
+ ElfKingdomFactory()
54+
+ createArmy() : Army
55+
+ createCastle() : Castle
56+
+ createKing() : King
57+
}
58+
interface King {
59+
+ getDescription() : String {abstract}
60+
}
61+
interface KingdomFactory {
62+
+ createArmy() : Army {abstract}
63+
+ createCastle() : Castle {abstract}
64+
+ createKing() : King {abstract}
65+
}
66+
class OrcArmy {
67+
~ DESCRIPTION : String {static}
68+
+ OrcArmy()
69+
+ getDescription() : String
70+
}
71+
class OrcCastle {
72+
~ DESCRIPTION : String {static}
73+
+ OrcCastle()
74+
+ getDescription() : String
75+
}
76+
class OrcKing {
77+
~ DESCRIPTION : String {static}
78+
+ OrcKing()
79+
+ getDescription() : String
80+
}
81+
class OrcKingdomFactory {
82+
+ OrcKingdomFactory()
83+
+ createArmy() : Army
84+
+ createCastle() : Castle
85+
+ createKing() : King
86+
}
87+
}
88+
KingdomType ..+ FactoryMaker
89+
App --> "-castle" Castle
90+
FactoryMaker ..+ App
91+
App --> "-king" King
92+
App --> "-army" Army
93+
ElfArmy ..|> Army
94+
ElfCastle ..|> Castle
95+
ElfKing ..|> King
96+
ElfKingdomFactory ..|> KingdomFactory
97+
OrcArmy ..|> Army
98+
OrcCastle ..|> Castle
99+
OrcKing ..|> King
100+
OrcKingdomFactory ..|> KingdomFactory
101+
@enduml

acyclic-visitor/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ tags:
99
- Difficulty-Intermediate
1010
---
1111

12-
![alt text](./etc/acyclic-visitor.png "Acyclic Visitor")
13-
1412
## Intent
1513
Allow new functions to be added to existing class hierarchies without affecting those hierarchies, and without creating the troublesome dependency cycles that are inherent to the GOF VISITOR Pattern.
1614

15+
## Class diagram
16+
![alt text](./etc/acyclic-visitor.png "Acyclic Visitor")
17+
1718
## Applicability
1819
This pattern can be used:
1920
* When you need to add a new function to an existing hierarchy without the need to alter or affect that hierarchy.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
@startuml
2+
package com.iluwatar.acyclicvisitor {
3+
interface AllModemVisitor {
4+
}
5+
class App {
6+
+ App()
7+
+ main(args : String[]) {static}
8+
}
9+
class ConfigureForDosVisitor {
10+
- LOGGER : Logger {static}
11+
+ ConfigureForDosVisitor()
12+
+ visit(hayes : Hayes)
13+
+ visit(zoom : Zoom)
14+
}
15+
class ConfigureForUnixVisitor {
16+
- LOGGER : Logger {static}
17+
+ ConfigureForUnixVisitor()
18+
+ visit(zoom : Zoom)
19+
}
20+
class Hayes {
21+
- LOGGER : Logger {static}
22+
+ Hayes()
23+
+ accept(modemVisitor : ModemVisitor)
24+
+ toString() : String
25+
}
26+
interface HayesVisitor {
27+
+ visit(Hayes) {abstract}
28+
}
29+
abstract class Modem {
30+
+ Modem()
31+
+ accept(ModemVisitor) {abstract}
32+
}
33+
interface ModemVisitor {
34+
}
35+
class Zoom {
36+
- LOGGER : Logger {static}
37+
+ Zoom()
38+
+ accept(modemVisitor : ModemVisitor)
39+
+ toString() : String
40+
}
41+
interface ZoomVisitor {
42+
+ visit(Zoom) {abstract}
43+
}
44+
}
45+
AllModemVisitor --|> ZoomVisitor
46+
AllModemVisitor --|> HayesVisitor
47+
ConfigureForDosVisitor ..|> AllModemVisitor
48+
ConfigureForUnixVisitor ..|> ZoomVisitor
49+
Hayes --|> Modem
50+
HayesVisitor --|> ModemVisitor
51+
Zoom --|> Modem
52+
ZoomVisitor --|> ModemVisitor
53+
@enduml

adapter/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ var captain = new Captain(new FishingBoatAdapter());
9797
captain.row();
9898
```
9999

100+
## Class diagram
101+
![alt text](./etc/adapter.urm.png "Adapter class diagram")
102+
100103
## Applicability
101104
Use the Adapter pattern when
102105

adapter/etc/adapter.urm.png

24.8 KB
Loading

adapter/etc/adapter.urm.puml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@startuml
2+
package com.iluwatar.adapter {
3+
class App {
4+
- App()
5+
+ main(args : String[]) {static}
6+
}
7+
class Captain {
8+
- rowingBoat : RowingBoat
9+
+ Captain()
10+
+ Captain(boat : RowingBoat)
11+
~ row()
12+
~ setRowingBoat(boat : RowingBoat)
13+
}
14+
~class FishingBoat {
15+
- LOGGER : Logger {static}
16+
~ FishingBoat()
17+
~ sail()
18+
}
19+
class FishingBoatAdapter {
20+
- boat : FishingBoat
21+
+ FishingBoatAdapter()
22+
+ row()
23+
}
24+
interface RowingBoat {
25+
+ row() {abstract}
26+
}
27+
}
28+
FishingBoatAdapter --> "-boat" FishingBoat
29+
Captain --> "-rowingBoat" RowingBoat
30+
FishingBoatAdapter ..|> RowingBoat
31+
@enduml

aggregator-microservices/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ More variations of the aggregator are:
1818
- Chained Microservice Design Pattern: In this case each microservice is dependent/ chained to a series
1919
of other microservices.
2020

21+
## Class diagram
22+
2123
![alt text](./etc/aggregator-microservice.png "Aggregator Microservice")
2224

2325
## Applicability
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@startuml
2+
package com.iluwatar.aggregator.microservices {
3+
class Aggregator {
4+
- informationClient : ProductInformationClient
5+
- inventoryClient : ProductInventoryClient
6+
+ Aggregator()
7+
+ getProduct() : Product
8+
}
9+
class App {
10+
+ App()
11+
+ main(args : String[]) {static}
12+
}
13+
class Product {
14+
- productInventories : int
15+
- title : String
16+
+ Product()
17+
+ getProductInventories() : int
18+
+ getTitle() : String
19+
+ setProductInventories(productInventories : int)
20+
+ setTitle(title : String)
21+
}
22+
interface ProductInformationClient {
23+
+ getProductTitle() : String {abstract}
24+
}
25+
class ProductInformationClientImpl {
26+
- LOGGER : Logger {static}
27+
+ ProductInformationClientImpl()
28+
+ getProductTitle() : String
29+
}
30+
interface ProductInventoryClient {
31+
+ getProductInventories() : Integer {abstract}
32+
}
33+
class ProductInventoryClientImpl {
34+
- LOGGER : Logger {static}
35+
+ ProductInventoryClientImpl()
36+
+ getProductInventories() : Integer
37+
}
38+
}
39+
Aggregator --> "-informationClient" ProductInformationClient
40+
Aggregator --> "-inventoryClient" ProductInventoryClient
41+
ProductInformationClientImpl ..|> ProductInformationClient
42+
ProductInventoryClientImpl ..|> ProductInventoryClient
43+
@enduml
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@startuml
2+
@enduml
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@startuml
2+
package com.iluwatar.information.microservice {
3+
class InformationApplication {
4+
+ InformationApplication()
5+
+ main(args : String[]) {static}
6+
}
7+
class InformationController {
8+
+ InformationController()
9+
+ getProductTitle() : String
10+
}
11+
}
12+
@enduml
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@startuml
2+
package com.iluwatar.inventory.microservice {
3+
class InventoryApplication {
4+
+ InventoryApplication()
5+
+ main(args : String[]) {static}
6+
}
7+
class InventoryController {
8+
+ InventoryController()
9+
+ getProductInventories() : int
10+
}
11+
}
12+
@enduml

0 commit comments

Comments
 (0)