Skip to content

Commit 6195d5e

Browse files
committed
docs: diagrams for transaction script, twin, and type object
1 parent 21914f9 commit 6195d5e

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

transaction-script/README.md

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

3535
> The Transaction Script design pattern is a straightforward way to organize business logic in applications, particularly suitable for scenarios where each request from the presentation layer can be handled by a single procedure. This pattern is often used in simple applications or in systems where rapid development and ease of understanding are crucial. Each transaction script is responsible for a particular task, such as processing an order or calculating a result, and typically interacts directly with the database.
3636
37+
Flowchart
38+
39+
![Transaction Script Pattern Flowchart](./etc/transaction-script-flowchart.png)
40+
3741
## Programmatic Example of Transaction Script Pattern in Java
3842

3943
Our Transaction Script pattern in Java example is about booking hotel rooms.
Loading

twin/README.md

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

3232
> The Twin pattern is a software design pattern that allows developers to simulate multiple inheritance in languages that don't support it. Instead of creating a single class inheriting from multiple parents, two closely linked subclasses are created, each inheriting from one of the parents. These subclasses are mutually dependent, working together as a pair to achieve the desired functionality. This approach avoids the complications and inefficiencies often associated with multiple inheritance, while still allowing the reuse of functionalities from different classes.
3333
34+
Sequence diagram
35+
36+
![Twin Pattern Sequence Diagram](./etc/twin-sequence-diagram.png)
37+
3438
## Programmatic Example of Twin Pattern in Java
3539

3640
Consider a game where a ball needs to function as both a `GameItem` and a `Thread`. Instead of inheriting from both, we use the Twin pattern with two closely linked objects: `BallItem` and `BallThread`.

twin/etc/twin-sequence-diagram.png

55.2 KB
Loading

type-object/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ Real-world example
3232
3333
In plain words
3434

35-
> Explore how the Java Type Object pattern enables dynamic creation and management of flexible and extensible sets of related classes, ideal for Java developers seeking modularity without modifying existing codebase.
35+
> Type Object pattern enables dynamic creation and management of flexible and extensible sets of related classes, ideal for Java developers seeking modularity without modifying existing codebase.
3636
3737
gameprogrammingpatterns.com says
3838

3939
> Define a type object class and a typed object class. Each type object instance represents a different logical type. Each typed object stores a reference to the type object that describes its type.
4040
41+
Flowchart
42+
43+
![Type Object Pattern Flowchart](./etc/type-object-flowchart.png)
44+
4145
## Programmatic Example of Type Object Pattern in Java
4246

4347
The Type Object pattern is a design pattern that allows for the creation of flexible and reusable objects by creating a class with a field that represents the 'type' of the object. This design pattern proves invaluable for scenarios where anticipated Java types are undefined upfront, or when modifications or additions are required, ensuring efficient Java development without frequent recompilations.
30.9 KB
Loading

0 commit comments

Comments
 (0)