diff --git a/spatial-partition/README.md b/spatial-partition/README.md index 26f070d5b..0a13b6f26 100644 --- a/spatial-partition/README.md +++ b/spatial-partition/README.md @@ -39,6 +39,10 @@ Wikipedia says > > For example, in ray tracing, space partitioning helps quickly determine the objects a ray might intersect by narrowing down the search space, leading to faster rendering times. Similarly, in game development, Quadtrees can efficiently manage 2D game environments by segmenting the space into smaller regions, facilitating quicker collision detection and rendering. +Flowchart + +![Spatial Partition flowchart](./etc/spatial-partition-flowchart.png) + ## Programmatic Example of Spatial Partition Pattern in Java The Spatial Partition design pattern in Java is a strategic approach for handling multiple objects in expansive game worlds or detailed simulation environments, boosting query efficiency and operational speed. It allows us to efficiently manage these objects and perform operations like collision detection or range queries. The pattern works by dividing the space into smaller, manageable regions, and each object is associated with the region it belongs to. This way, we can limit our operations to a specific region, instead of checking every object against every other object. diff --git a/spatial-partition/etc/spatial-partition-flowchart.png b/spatial-partition/etc/spatial-partition-flowchart.png new file mode 100644 index 000000000..0e287932d Binary files /dev/null and b/spatial-partition/etc/spatial-partition-flowchart.png differ diff --git a/special-case/README.md b/special-case/README.md index eda6ad0ff..e7bbeb39d 100644 --- a/special-case/README.md +++ b/special-case/README.md @@ -37,6 +37,10 @@ In [Patterns of Enterprise Application Architecture](https://amzn.to/3WfKBPR) Ma > If you’ll pardon the unresistable pun, I see [Null Object](https://java-design-patterns.com/patterns/null-object/) as special case of Special Case. +Sequnce diagram + +![Special Case sequence diagram](./etc/special-case-sequence-diagram.png) + ## Programmatic Example of Special Case Pattern in Java The Special Case Pattern is a software design pattern that is used to handle a specific, often uncommon, case separately from the general case in the code. This pattern is useful when a class has behavior that requires conditional logic based on its state. Instead of cluttering the class with conditional logic, we can encapsulate the special behavior in a subclass. diff --git a/special-case/etc/special-case-sequence-diagram.png b/special-case/etc/special-case-sequence-diagram.png new file mode 100644 index 000000000..87842ec4c Binary files /dev/null and b/special-case/etc/special-case-sequence-diagram.png differ diff --git a/specification/README.md b/specification/README.md index 4ccb68cc5..9310555ec 100644 --- a/specification/README.md +++ b/specification/README.md @@ -37,6 +37,10 @@ Wikipedia says > In computer programming, the specification pattern is a particular software design pattern, whereby business rules can be recombined by chaining the business rules together using boolean logic. +Flowchart + +![Specification Pattern flowchart](./etc/specification-flowchart.png) + ## Programmatic Example of Specification Pattern in Java Let's consider a creature pool example. We have a collection of creatures with specific properties. These properties might belong to a predefined, limited set (represented by enums like `Size`, `Movement`, and `Color`) or they might be continuous values (e.g., the mass of a `Creature`). In cases with continuous values, it's better to use a "parameterized specification," where the property value is provided as an argument when the `Creature` is instantiated, allowing for greater flexibility. Additionally, predefined and/or parameterized properties can be combined using boolean logic, offering almost limitless selection possibilities (this is known as a "composite specification," explained further below). The advantages and disadvantages of each approach are detailed in the table at the end of this document. diff --git a/specification/etc/specification-flowchart.png b/specification/etc/specification-flowchart.png new file mode 100644 index 000000000..73bc446f7 Binary files /dev/null and b/specification/etc/specification-flowchart.png differ diff --git a/state/README.md b/state/README.md index 7fdc242ae..b35768834 100644 --- a/state/README.md +++ b/state/README.md @@ -38,6 +38,10 @@ Wikipedia says > The state pattern is a behavioral software design pattern that allows an object to alter its behavior when its internal state changes. This pattern is close to the concept of finite-state machines. The state pattern can be interpreted as a strategy pattern, which is able to switch a strategy through invocations of methods defined in the pattern's interface. +Flowchart + +![State flowchart](./etc/state-flowchart.png) + ## Programmatic Example of State Pattern in Java In our programmatic example there is a mammoth with alternating moods. diff --git a/state/etc/state-flowchart.png b/state/etc/state-flowchart.png new file mode 100644 index 000000000..fb49c9e0a Binary files /dev/null and b/state/etc/state-flowchart.png differ diff --git a/step-builder/README.md b/step-builder/README.md index a651cff45..3b0f4c479 100644 --- a/step-builder/README.md +++ b/step-builder/README.md @@ -35,6 +35,10 @@ Wikipedia says > The Step Builder pattern is a variation of the Builder design pattern, designed to provide a flexible solution for constructing complex objects step-by-step. This pattern is particularly useful when an object requires multiple initialization steps, which can be done incrementally to ensure clarity and flexibility in the creation process. +Sequence diagram + +![Step Builder sequence diagram](./etc/step-builder-sequence-diagram.png) + ## Programmatic Example of Step Builder Pattern in Java The Step Builder pattern in Java is an extension of the Builder pattern that guides the user through the creation of an object in a step-by-step manner. This pattern improves the user experience by only showing the next step methods available, and not showing the build method until it's the right time to build the object. @@ -162,10 +166,6 @@ Console output: 12:58:13.889 [main] INFO com.iluwatar.stepbuilder.App -- This is a Rogue named Desmond armed with a with nothing. ``` -## Detailed Explanation of Step Builder Pattern with Real-World Examples - -![Step Builder](./etc/step-builder.png "Step Builder") - ## When to Use the Step Builder Pattern in Java The Step Builder pattern in Java is used diff --git a/step-builder/etc/step-builder-sequence-diagram.png b/step-builder/etc/step-builder-sequence-diagram.png new file mode 100644 index 000000000..c2c458219 Binary files /dev/null and b/step-builder/etc/step-builder-sequence-diagram.png differ diff --git a/strangler/README.md b/strangler/README.md index 569a2151f..22baf44ec 100644 --- a/strangler/README.md +++ b/strangler/README.md @@ -32,6 +32,10 @@ Wikipedia says > The Strangler Design Pattern involves incrementally migrating a legacy system by gradually replacing it with a new system. It wraps old code with new code, redirecting or logging uses of the old code to ensure a seamless transition. This pattern is named after the strangler fig plant, which grows around a host tree and eventually replaces it entirely. It's particularly useful for modernizing monolithic applications and transitioning them to microservices architecture with minimal risk and disruption. +Flowchart + +![Strangler flowchart](./etc/strangler-flowchart.png) + ## Programmatic Example of Strangler Pattern in Java The Strangler design pattern in Java is a software design pattern that incrementally migrates a legacy system by gradually replacing specific pieces of functionality with new applications and services. As features from the legacy system are replaced, the new system eventually replaces all the old system's features, strangling the old system and allowing you to decommission it. diff --git a/strangler/etc/strangler-flowchart.png b/strangler/etc/strangler-flowchart.png new file mode 100644 index 000000000..205746909 Binary files /dev/null and b/strangler/etc/strangler-flowchart.png differ diff --git a/strategy/README.md b/strategy/README.md index 781463d20..9f9148ccd 100644 --- a/strategy/README.md +++ b/strategy/README.md @@ -34,6 +34,10 @@ Wikipedia says > In computer programming, the strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm at runtime. +Flowchart + +![Strategy flowchart](./etc/strategy-flowchart.png) + ## Programmatic Example of Strategy Pattern in Java Slaying dragons is a dangerous job. With experience, it becomes easier. Veteran dragonslayers have developed different fighting strategies against different types of dragons. diff --git a/strategy/etc/strategy-flowchart.png b/strategy/etc/strategy-flowchart.png new file mode 100644 index 000000000..18623f248 Binary files /dev/null and b/strategy/etc/strategy-flowchart.png differ diff --git a/subclass-sandbox/README.md b/subclass-sandbox/README.md index 1dbea163e..ffe272749 100644 --- a/subclass-sandbox/README.md +++ b/subclass-sandbox/README.md @@ -35,6 +35,10 @@ In plain words > A base class defines an abstract sandbox method and several provided operations. Marking them protected makes it clear that they are for use by derived classes. Each derived sandboxed subclass implements the sandbox method using the provided operations. +Flowchart + +![Subclass Sandbox flowchart](./etc/subclass-sandbox-flowchart.png) + ## Programmatic Example of Subclass Sandbox Pattern in Java Using the Subclass Sandbox pattern, developers can create distinct functionalities within Java applications, enhancing game development and software design. diff --git a/subclass-sandbox/etc/subclass-sandbox-flowchart.png b/subclass-sandbox/etc/subclass-sandbox-flowchart.png new file mode 100644 index 000000000..580d2c030 Binary files /dev/null and b/subclass-sandbox/etc/subclass-sandbox-flowchart.png differ