Skip to content

Commit d8b07ac

Browse files
committed
docs: add diagrams for identity map, intercepting filter, interpreter, iterator
1 parent 9d23a23 commit d8b07ac

File tree

7 files changed

+12
-4
lines changed

7 files changed

+12
-4
lines changed

Diff for: identity-map/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Wikipedia says
3131

3232
> In the design of DBMS, the identity map pattern is a database access design pattern used to improve performance by providing a context-specific, in-memory cache to prevent duplicate retrieval of the same object data from the database.
3333
34+
Sequence diagram
35+
36+
![Identity Map sequence diagram](./etc/identity-map-sequence-diagram.png)
37+
3438
## Programmatic Example of Identity Map Pattern in Java
3539

3640
For the purpose of this demonstration in Java programming, assume we have already created a database instance, showcasing the Identity Map pattern to avoid duplicate objects in memory.

Diff for: identity-map/etc/identity-map-sequence-diagram.png

52.7 KB
Loading
Loading

Diff for: interpreter/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ Wikipedia says
3232

3333
> In computer programming, the interpreter pattern is a design pattern that specifies how to evaluate sentences in a language. The basic idea is to have a class for each symbol (terminal or nonterminal) in a specialized computer language. The syntax tree of a sentence in the language is an instance of the composite pattern and is used to evaluate (interpret) the sentence for a client.
3434
35+
Sequence diagram
36+
37+
![Interpreter sequence diagram](./etc/interpreter-sequence-diagram.png)
38+
3539
## Programmatic Example of Interpreter Pattern in Java
3640

3741
To be able to interpret basic math in Java, we need a hierarchy of expressions. The `Expression` class is the base, and concrete implementations like `NumberExpression` handle specific parts of the grammar. The Interpreter pattern in Java simplifies parsing and evaluating arithmetic expressions by translating them into a structured format that the application can process.
@@ -174,10 +178,6 @@ Executing the program produces the following console output.
174178
13:33:15.440 [main] INFO com.iluwatar.interpreter.App -- result: 8
175179
```
176180

177-
## Detailed Explanation of Interpreter Pattern with Real-World Examples
178-
179-
![Interpreter](./etc/interpreter_1.png "Interpreter")
180-
181181
## When to Use the Interpreter Pattern in Java
182182

183183
Use the Interpreter design pattern when there is a language to interpret, and you can represent statements in the language as abstract syntax trees. The Interpreter pattern works best when

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

57.1 KB
Loading

Diff for: iterator/README.md

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

3636
> In object-oriented programming, the iterator pattern is a design pattern in which an iterator is used to traverse a container and access the container's elements.
3737
38+
Sequence diagram
39+
40+
![Iterator sequence diagram](./etc/iterator-sequence-diagram.png)
41+
3842
## Programmatic Example of Iterator Pattern in Java
3943

4044
The main class in our Java Iterator Design Pattern example is the `TreasureChest` that contains items. This demonstrates how to implement and use iterators for efficient collection traversal in Java.

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

52.6 KB
Loading

0 commit comments

Comments
 (0)