Skip to content

Commit 30d1308

Browse files
committed
docs: add diagrams for decorator, delegation, dependency injection, dirty flag, domain model, double buffer, double-checked locking, double dispatch, and dynamic proxy
1 parent 203548e commit 30d1308

18 files changed

+36
-12
lines changed

decorator/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Wikipedia says
3535

3636
> In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class. The decorator pattern is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern as well as to the Open-Closed Principle, by allowing the functionality of a class to be extended without being modified.
3737
38+
Sequence diagram
39+
40+
![Decorator sequence diagram](./etc/decorator-sequence-diagram.png)
41+
3842
## Programmatic Example of Decorator Pattern in Java
3943

4044
There is an angry troll living in the nearby hills. Usually, it goes bare-handed, but sometimes it has a weapon. To arm the troll it's not necessary to create a new troll but to decorate it dynamically with a suitable weapon.
60.1 KB
Loading

delegation/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Wikipedia says
3333

3434
> In object-oriented programming, delegation refers to evaluating a member (property or method) of one object (the receiver) in the context of another original object (the sender). Delegation can be done explicitly, by passing the sending object to the receiving object, which can be done in any object-oriented language; or implicitly, by the member lookup rules of the language, which requires language support for the feature.
3535
36+
Sequence diagram
37+
38+
![Delegation sequence diagram](./etc/delegation-sequence-diagram.png)
39+
3640
## Programmatic Example of Delegation Pattern in Java
3741

3842
Let's consider a printing example.
@@ -114,10 +118,6 @@ Canon Printer:hello world
114118
Epson Printer:hello world
115119
```
116120

117-
## Detailed Explanation of Delegation Pattern with Real-World Examples
118-
119-
![Delegate class diagram](./etc/delegation.png "Delegate")
120-
121121
## When to Use the Delegation Pattern in Java
122122

123123
* When you want to pass responsibility from one class to another without inheritance.
25.5 KB
Loading

dependency-injection/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Wikipedia says
3535

3636
> In software engineering, dependency injection is a technique in which an object receives other objects that it depends on. These other objects are called dependencies.
3737
38+
Sequence diagram
39+
40+
![Dependency Injection sequence diagram](./etc/dependency-injection-sequence-diagram.png)
41+
3842
## Programmatic Example of Dependency Injection Pattern in Java
3943

4044
The old wizard likes to fill his pipe and smoke tobacco once in a while. However, he doesn't want to depend on a single tobacco brand only but likes to be able to enjoy them all interchangeably.
25.6 KB
Loading

dirty-flag/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Wikipedia says
3434

3535
> A dirty bit or modified bit is a bit that is associated with a block of computer memory and indicates whether the corresponding block of memory has been modified. The dirty bit is set when the processor writes to (modifies) this memory. The bit indicates that its associated block of memory has been modified and has not been saved to storage yet. When a block of memory is to be replaced, its corresponding dirty bit is checked to see if the block needs to be written back to secondary memory before being replaced or if it can simply be removed. Dirty bits are used by the CPU cache and in the page replacement algorithms of an operating system.
3636
37+
Flowchart
38+
39+
![Dirty Flag flowchart](./etc/dirty-flag-flowchart.png)
40+
3741
## Programmatic Example of Dirty Flag Pattern in Java
3842

3943
The `DataFetcher` class is responsible for fetching data from a file. It has a dirty flag that indicates whether the data in the file has changed since the last fetch.
46.7 KB
Loading

domain-model/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ In plain words
3434

3535
> The Domain Model is an object model of the domain that incorporates both behavior and data.
3636
37+
Mind map
38+
39+
![Domain Model mind map](./etc/domain-model-mind-map.png)
40+
3741
## Programmatic Example of Domain Model Pattern in Java
3842

3943
Let's assume that we need to build an e-commerce web application. While analyzing requirements you will notice that there are few nouns you talk about repeatedly. It’s your Customer, and a Product the customer looks for. These two are your domain-specific classes and each of that classes will include some business logic specific to its domain.
@@ -225,10 +229,6 @@ The program output:
225229
12:17:23.846 [main] INFO com.iluwatar.domainmodel.Customer -- Tom bought: Eggs - $10.00, Cheese - $20.00
226230
```
227231
228-
## Detailed Explanation of Domain Model Pattern with Real-World Examples
229-
230-
![Domain Model class diagram](./etc/domain-model.urm.png "Domain Model")
231-
232232
## When to Use the Domain Model Pattern in Java
233233
234234
* Appropriate in complex applications with rich business logic.
107 KB
Loading

0 commit comments

Comments
 (0)