Skip to content

Commit 9b64cde

Browse files
committed
docs: add diagrams for facade, factory kit, factory method, factory, fan-out/fan-in, feature toggle, filterer, fluent interface, flyweight, front controller, function composition
1 parent aef4b37 commit 9b64cde

21 files changed

+40
-5
lines changed

Diff for: facade/README.md

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

3434
> A facade is an object that provides a simplified interface to a larger body of code, such as a class library.
3535
36+
Sequence diagram
37+
38+
![Facade sequence diagram](./etc/facade-sequence-diagram.png)
39+
3640
## Programmatic Example of Facade Pattern in Java
3741

3842
Here's an example of the Facade Design Pattern in a goldmine scenario, demonstrating how a Java facade can streamline complex operations.

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

61.9 KB
Loading

Diff for: factory-kit/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ In plain words
3232

3333
> Factory kit is a configurable object builder, a factory to create factories.
3434
35+
Sequence diagram
36+
37+
![Factory Kit sequence diagram](./etc/factory-kit-sequence-diagram.png)
38+
3539
## Programmatic Example of Factory Kit Pattern in Java
3640

3741
Imagine a magical weapon factory in Java capable of creating any desired weapon using the Factory Kit Pattern. This pattern allows for configurable object builders, making it ideal for scenarios where the types of objects are not known upfront.

Diff for: factory-kit/etc/factory-kit-sequence-diagram.png

44 KB
Loading

Diff for: factory-method/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Wikipedia says
3636

3737
> In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. This is done by creating objects by calling a factory method — either specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived classes—rather than by calling a constructor.
3838
39+
Sequence diagram
40+
41+
![Factory Method sequence diagram](./etc/factory-method-sequence-diagram.png)
42+
3943
## Programmatic Example of Factory Method Pattern in Java
4044

4145
The Factory Method approach is pivotal in Java Design Patterns for achieving flexible and maintainable code as we see in the following example.
59 KB
Loading

Diff for: factory/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Wikipedia says
2626

2727
> Factory is an object for creating other objects – formally a factory is a function or method that returns objects of a varying prototype or class.
2828
29+
Sequence diagram
30+
31+
![Factory sequence diagram](./etc/factory-sequence-diagram.png)
32+
2933
## Programmatic Example of Factory Pattern in Java
3034

3135
Imagine an alchemist who is about to manufacture coins. The alchemist must be able to create both gold and copper coins and switching between them must be possible without modifying the existing source code. The factory pattern makes it possible by providing a static construction method which can be called with relevant parameters.

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

28.8 KB
Loading

Diff for: fanout-fanin/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Wikipedia says
3535
>
3636
> The fan-in concept, on the other hand, typically refers to the aggregation of multiple inputs. In digital electronics, it describes the number of inputs a logic gate can handle. Combining these concepts, the Fan-Out/Fan-In pattern in software engineering involves distributing tasks (fan-out) and then aggregating the results (fan-in).
3737
38+
Sequence diagram
39+
40+
![Fan-Out/Fan-In flowchart](./etc/fan-out-fan-in-flowchart.png)
41+
3842
## Programmatic Example of Fan-Out/Fan-In Pattern in Java
3943

4044
The provided implementation involves a list of numbers with the objective to square them and aggregate the results. The `FanOutFanIn` class receives the list of numbers as `SquareNumberRequest` objects and a `Consumer` instance that collects the squared results as the requests complete. Each `SquareNumberRequest` squares its number with a random delay, simulating a long-running process that finishes at unpredictable times. The `Consumer` instance gathers the results from the various `SquareNumberRequest` objects as they become available at different times.

Diff for: fanout-fanin/etc/fan-out-fan-in-flowchart.png

61.2 KB
Loading

Diff for: feature-toggle/README.md

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

3535
> A feature toggle in software development provides an alternative to maintaining multiple feature branches in source code. A condition within the code enables or disables a feature during runtime. In agile settings the toggle is used in production, to switch on the feature on demand, for some or all the users.
3636
37+
Flowchart
38+
39+
![Feature Toggle flowchart](./etc/feature-toggle-flowchart.png)
40+
3741
## Programmatic Example of Feature Toggle Pattern in Java
3842

3943
This Java code example demonstrates how to display a feature when it is enabled by the developer and the user is a Premium member of the application. This approach is useful for managing subscription-locked features.

Diff for: feature-toggle/etc/feature-toggle-flowchart.png

45.4 KB
Loading

Diff for: filterer/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ In plain words
3333

3434
> Filterer pattern is a design pattern that helps container-like objects return filtered versions of themselves.
3535
36+
Flowchart
37+
38+
![Filterer flowchart](./etc/filterer-flowchart.png)
39+
3640
## Programmatic Example of Filterer Pattern in Java
3741

3842
To illustrate, we use the Filterer design pattern for a malware detection system in Java. This system can filter threats based on various criteria, showcasing the pattern’s flexibility and dynamic nature. In the design we have to take into consideration that new Threat types can be added later. Additionally, there is a requirement that the threat detection system can filter the detected threats based on different criteria (the target system acts as container-like object for threats).

Diff for: filterer/etc/filterer-flowchart.png

39.1 KB
Loading

Diff for: fluent-interface/README.md

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

3636
> In software engineering, a fluent interface is an object-oriented API whose design relies extensively on method chaining. Its goal is to increase code legibility by creating a domain-specific language (DSL).
3737
38+
Sequence diagram
39+
40+
![Fluent Interface sequence diagram](./etc/fluent-interface-sequence-diagram.png)
41+
3842
## Programmatic Example of Fluent Interface Pattern in Java
3943

4044
We need to select numbers based on different criteria from the list. It's a great chance to utilize fluent interface pattern to provide readable easy-to-use developer experience.
89.4 KB
Loading

Diff for: flyweight/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Wikipedia says
3030

3131
> In computer programming, flyweight is a software design pattern. A flyweight is an object that minimizes memory use by sharing as much data as possible with other similar objects; it is a way to use objects in large numbers when a simple repeated representation would use an unacceptable amount of memory.
3232
33+
Sequence diagram
34+
35+
![Flyweight sequence diagram](./etc/flyweight-sequence-diagram.png)
36+
3337
## Programmatic Example of Flyweight Pattern in Java
3438

3539
Alchemist's shop has shelves full of magic potions. Many of the potions are the same so there is no need to create a new object for each of them. Instead, one object instance can represent multiple shelf items so the memory footprint remains small.

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

74.3 KB
Loading

Diff for: front-controller/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Architecture diagram
3838

3939
![Front Controller Architecture Diagram](./etc/front-controller-architecture-diagram.png)
4040

41-
4241
## Programmatic Example of Front Controller Pattern in Java
4342

4443
The Front Controller design pattern is a pattern that provides a centralized entry point for handling all requests in a web application. It ensures that request handling is managed consistently and efficiently across an application.

Diff for: function-composition/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ Wikipedia says
3939

4040
> Function composition is an act or mechanism to combine simple functions to build more complicated ones. Like the usual composition of functions in mathematics, the result of each function is passed as the argument of the next, and the result of the last one is the result of the whole.
4141
42+
Sequence diagram
43+
44+
![Function Composition sequence diagram](./etc/function-composition-sequence-diagram.png)
45+
4246
## Programmatic Example of Function Composition Pattern in Java
4347

4448
In the functional programming paradigm, function composition is a powerful technique. For instance, in Java, you can use higher-order functions to compose operations like multiplying and squaring numbers.
@@ -81,10 +85,6 @@ Result of composing 'timesTwo' and 'square' functions applied to 3 is: 36
8185

8286
This example demonstrates how the Function Composition pattern can be used to create complex functions by composing simpler ones, enhancing modularity and reusability of function-based logic.
8387

84-
## Function Composition Pattern Sequence diagram
85-
86-
![Functional Composition Diagram](./etc/function.composition.urm.png "Functional Composition")
87-
8888
## When to Use the Function Composition Pattern in Java
8989

9090
Use the Function Composition pattern when:
Loading

0 commit comments

Comments
 (0)