Skip to content

Commit 8c50536

Browse files
authored
Merge branch 'master' into issue-2673
2 parents 059f292 + 30d1308 commit 8c50536

18 files changed

+36
-12
lines changed

Diff for: decorator/README.md

+4
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.

Diff for: decorator/etc/decorator-sequence-diagram.png

60.1 KB
Loading

Diff for: delegation/README.md

+4-4
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.

Diff for: delegation/etc/delegation-sequence-diagram.png

25.5 KB
Loading

Diff for: dependency-injection/README.md

+4
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.
Loading

Diff for: dirty-flag/README.md

+4
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.

Diff for: dirty-flag/etc/dirty-flag-flowchart.png

46.7 KB
Loading

Diff for: domain-model/README.md

+4-4
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.

Diff for: domain-model/etc/domain-model-mind-map.png

107 KB
Loading

Diff for: double-buffer/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Wikipedia says
3434

3535
> In computer science, multiple buffering is the use of more than one buffer to hold a block of data, so that a "reader" will see a complete (though perhaps old) version of the data, rather than a partially updated version of the data being created by a "writer". It is very commonly used for computer display images.
3636
37+
Sequence diagram
38+
39+
![Double Buffer sequence diagram](./etc/double-buffer-sequence-diagram.png)
40+
3741
## Programmatic Example of Double Buffer Pattern in Java
3842

3943
A typical example, and one that every game engine must address, is rendering. When the game draws the world the users see, it does so one piece at a time - the mountains in the distance, the rolling hills, the trees, each in its turn. If the user watched the view draw incrementally like that, the illusion of a coherent world would be shattered. The scene must update smoothly and quickly, displaying a series of complete frames, each appearing instantly. Double buffering solves the problem.

Diff for: double-buffer/etc/double-buffer-sequence-diagram.png

61.6 KB
Loading

Diff for: double-checked-locking/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Wikipedia says
2929

3030
> In software engineering, double-checked locking (also known as "double-checked locking optimization") is a software design pattern used to reduce the overhead of acquiring a lock by testing the locking criterion (the "lock hint") before acquiring the lock. Locking occurs only if the locking criterion check indicates that locking is required.
3131
32+
Flowchart
33+
34+
![Double-Checked Locking flowchart](./etc/double-checked-locking-flowchart.png)
35+
3236
## Programmatic Example of Double-Checked Locking Pattern in Java
3337

3438
The Double-Checked Locking pattern is used in the `HolderThreadSafe` class to ensure that the `Heavy` object is only created once, even when accessed from multiple threads. Here's how it works:
67.3 KB
Loading

Diff for: double-dispatch/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Wikipedia says
3333

3434
> In software engineering, double dispatch is a special form of multiple dispatch, and a mechanism that dispatches a function call to different concrete functions depending on the runtime types of two objects involved in the call. In most object-oriented systems, the concrete function that is called from a function call in the code depends on the dynamic type of a single object and therefore they are known as single dispatch calls, or simply virtual function calls.
3535
36+
Sequence diagram
37+
38+
![Double Dispatch sequence diagram](./etc/double-dispatch-sequence-diagram.png)
39+
3640
## Programmatic Example of Double Dispatch Pattern in Java
3741

3842
The Double Dispatch pattern in Java is used to handle collisions between different types of game objects. Each game object is an instance of a class that extends the `GameObject` abstract class. The `GameObject` class has a `collision(GameObject)` method, which is overridden in each subclass to define the behavior when a collision occurs with another game object. Here is a simplified version of the `GameObject` class and its subclasses:
@@ -113,10 +117,6 @@ Here is the program output:
113117
15:47:23.773 [main] INFO com.iluwatar.doubledispatch.App -- SpaceStationIss at [12,12,14,14] damaged=true onFire=false
114118
```
115119

116-
## Detailed Explanation of Double Dispatch Pattern with Real-World Examples
117-
118-
![Double Dispatch](./etc/double-dispatch.png "Double Dispatch")
119-
120120
## When to Use the Double Dispatch Pattern in Java
121121

122122
* When the behavior of a method needs to vary not just based on the object it is called on, but also based on the type of the argument.
24.2 KB
Loading

Diff for: dynamic-proxy/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Wikipedia says
3535

3636
> A dynamic proxy class is a class that implements a list of interfaces specified at runtime such that a method invocation through one of the interfaces on an instance of the class will be encoded and dispatched to another object through a uniform interface. Thus, a dynamic proxy class can be used to create a type-safe proxy object for a list of interfaces without requiring pre-generation of the proxy class, such as with compile-time tools. Method invocations on an instance of a dynamic proxy class are dispatched to a single method in the instance's invocation handler, and they are encoded with a _java.lang.reflect.Method_ object identifying the method that was invoked and an array of type _Object_ containing the arguments.
3737
38+
Sequence diagram
39+
40+
![Dynamic Proxy sequence diagram](./etc/dynamic-proxy-sequence-diagram.png)
41+
3842
## Programmatic Example of Dynamic Proxy Pattern in Java
3943

4044
This example demonstrates using the Dynamic Proxy pattern in Java to hit the public fake API [JSONPlaceholder](https://jsonplaceholder.typicode.com) for the resource `Album` through an interface.

Diff for: dynamic-proxy/etc/dynamic-proxy-sequence-diagram.png

49.5 KB
Loading

0 commit comments

Comments
 (0)