diff --git a/marker-interface/README.md b/marker-interface/README.md index 1d242f5bc..c272093e0 100644 --- a/marker-interface/README.md +++ b/marker-interface/README.md @@ -37,6 +37,10 @@ Wikipedia says > > To use this pattern, a class implements a marker interface (also called tagging interface) which is an empty interface, and methods that interact with instances of that class test for the existence of the interface. Whereas a typical interface specifies functionality (in the form of method declarations) that an implementing class must support, a marker interface need not do so. The mere presence of such an interface indicates specific behavior on the part of the implementing class. Hybrid interfaces, which both act as markers and specify required methods, are possible but may prove confusing if improperly used. +Flowchart + +![Marker Interface flowchart](./etc/marker-interface-flowchart.png) + ## Programmatic Example of Marker Interface Pattern in Java The Marker Interface design pattern is a design pattern in computer science that is used with languages that provide run-time type information about objects. It provides a means to associate metadata with a class where the language does not have explicit support for such metadata. diff --git a/marker-interface/etc/marker-interface-flowchart.png b/marker-interface/etc/marker-interface-flowchart.png new file mode 100644 index 000000000..289a2cdb6 Binary files /dev/null and b/marker-interface/etc/marker-interface-flowchart.png differ diff --git a/master-worker/README.md b/master-worker/README.md index 1b8f7cfef..708859522 100644 --- a/master-worker/README.md +++ b/master-worker/README.md @@ -33,6 +33,10 @@ Wikipedia says > Master–slave is a model of asymmetric communication or control where one device or process (the master) controls one or more other devices or processes (the slaves) and serves as their communication hub. In some systems, a master is selected from a group of eligible devices, with the other devices acting in the role of slaves. +Sequence diagram + +![Master-Worker sequence diagram](./etc/master-worker-sequence-diagram.png) + ## Programmatic Example of Master-Worker Pattern in Java In the provided code, the `MasterWorker` class initiates the concurrent computation process. The `Master` class divides the work among `Worker` objects, each performing its task in parallel, thus optimizing task processing and enhancing system efficiency. diff --git a/master-worker/etc/master-worker-sequence-diagram.png b/master-worker/etc/master-worker-sequence-diagram.png new file mode 100644 index 000000000..e2e28a262 Binary files /dev/null and b/master-worker/etc/master-worker-sequence-diagram.png differ diff --git a/mediator/README.md b/mediator/README.md index 628d976e0..f9650d3f1 100644 --- a/mediator/README.md +++ b/mediator/README.md @@ -33,6 +33,10 @@ Wikipedia says > In software engineering, the mediator pattern defines an object that encapsulates how a set of objects interact. This pattern is considered to be a behavioral pattern due to the way it can alter the program's running behavior. In object-oriented programming, programs often consist of many classes. Business logic and computation are distributed among these classes. However, as more classes are added to a program, especially during maintenance and/or refactoring, the problem of communication between these classes may become more complex. This makes the program harder to read and maintain. Furthermore, it can become difficult to change the program, since any change may affect code in several other classes. With the mediator pattern, communication between objects is encapsulated within a mediator object. Objects no longer communicate directly with each other, but instead communicate through the mediator. This reduces the dependencies between communicating objects, thereby reducing coupling. +Sequence diagram + +![Mediator sequence diagram](./etc/mediator-sequence-diagram.png) + ## Programmatic Example of Mediator Pattern in Java In this example, the mediator encapsulates how a set of objects interact. Instead of referring to each other directly, they use the mediator interface. @@ -175,10 +179,6 @@ Here's the console output from running the example. 14:05:15.083 [main] INFO com.iluwatar.mediator.PartyMemberBase -- Rogue arrives for dinner ``` -## Detailed Explanation of Mediator Pattern with Real-World Examples - -![Mediator](./etc/mediator_1.png "Mediator") - ## When to Use the Mediator Pattern in Java Use the Mediator pattern when diff --git a/mediator/etc/mediator-sequence-diagram.png b/mediator/etc/mediator-sequence-diagram.png new file mode 100644 index 000000000..e79a4aaec Binary files /dev/null and b/mediator/etc/mediator-sequence-diagram.png differ diff --git a/memento/README.md b/memento/README.md index c1c5372b2..520c4b4ec 100644 --- a/memento/README.md +++ b/memento/README.md @@ -36,6 +36,10 @@ Wikipedia says > The memento pattern is a software design pattern that provides the ability to restore an object to its previous state (undo via rollback). +Sequence diagram + +![Memento sequence diagram](./etc/memento-sequence-diagram.png) + ## Programmatic Example of Memento Pattern in Java In our astrology application, we use the Memento pattern to capture and restore the state of star objects. Each state is saved as a memento, allowing us to revert to previous states as needed. diff --git a/memento/etc/memento-sequence-diagram.png b/memento/etc/memento-sequence-diagram.png new file mode 100644 index 000000000..8d70255a1 Binary files /dev/null and b/memento/etc/memento-sequence-diagram.png differ diff --git a/metadata-mapping/README.md b/metadata-mapping/README.md index bd2342709..3ca71dc9d 100644 --- a/metadata-mapping/README.md +++ b/metadata-mapping/README.md @@ -29,6 +29,10 @@ Wikipedia says > Create a "virtual [object database](https://en.wikipedia.org/wiki/Object_database)" that can be used from within the programming language. +Flowchart + +![Metadata Mapping flowchart](./etc/metadata-mapping-flowchart.png) + ## Programmatic Example of Metadata Mapping Pattern in Java Hibernate ORM Tool uses Metadata Mapping Pattern to specify the mapping between classes and tables either using XML or annotations in code. diff --git a/metadata-mapping/etc/metadata-mapping-flowchart.png b/metadata-mapping/etc/metadata-mapping-flowchart.png new file mode 100644 index 000000000..88f7d9953 Binary files /dev/null and b/metadata-mapping/etc/metadata-mapping-flowchart.png differ diff --git a/microservices-api-gateway/README.md b/microservices-api-gateway/README.md index 72b9b521a..4f03560b9 100644 --- a/microservices-api-gateway/README.md +++ b/microservices-api-gateway/README.md @@ -38,6 +38,10 @@ Wikipedia says > API Gateway is a server that acts as an API front-end, receives API requests, enforces throttling and security policies, passes requests to the back-end service and then passes the response back to the requester. A gateway often includes a transformation engine to orchestrate and modify the requests and responses on the fly. A gateway can also provide functionality such as collecting analytics data and providing caching. The gateway can provide functionality to support authentication, authorization, security, audit and regulatory compliance. +Sequence diagram + +![Microservices API Gateway sequence diagram](./etc/microservices-api-gateway-sequence-diagram.png) + ## Programmatic Example of Microservice API Gateway in Java This implementation shows what the API Gateway pattern could look like for an e-commerce site. The`ApiGateway` makes calls to the Image and Price microservices using the `ImageClientImpl` and `PriceClientImpl` respectively. Customers viewing the site on a desktop device can see both price information and an image of a product, so the `ApiGateway` calls both of the microservices and aggregates the data in the `DesktopProduct` model. However, mobile users only see price information; they do not see a product image. For mobile users, the `ApiGateway` only retrieves price information, which it uses to populate the `MobileProduct`. diff --git a/microservices-api-gateway/etc/microservices-api-gateway-sequence-diagram.png b/microservices-api-gateway/etc/microservices-api-gateway-sequence-diagram.png new file mode 100644 index 000000000..9186b3232 Binary files /dev/null and b/microservices-api-gateway/etc/microservices-api-gateway-sequence-diagram.png differ diff --git a/microservices-log-aggregation/README.md b/microservices-log-aggregation/README.md index c23b1fe43..2fcef9b70 100644 --- a/microservices-log-aggregation/README.md +++ b/microservices-log-aggregation/README.md @@ -38,6 +38,10 @@ Wikipedia says > You have applied the Microservice architecture pattern. The application consists of multiple services and service instances that are running on multiple machines. Requests often span multiple service instances. Each service instance generates writes information about what it is doing to a log file in a standardized format. The log file contains errors, warnings, information and debug messages. +Flowchart + +![Microservices Log Aggregration flowchart](./etc/microservices-log-aggregation-flowchart.png) + ## Programmatic Example of Microservices Log Aggregation Pattern in Java Log Aggregation is a pattern that centralizes the collection, storage, and analysis of logs from multiple sources to facilitate monitoring, debugging, and operational intelligence. It is particularly useful in distributed systems where logs from various components need to be centralized for better management and analysis. diff --git a/microservices-log-aggregation/etc/microservices-log-aggregation-flowchart.png b/microservices-log-aggregation/etc/microservices-log-aggregation-flowchart.png new file mode 100644 index 000000000..a73f948dd Binary files /dev/null and b/microservices-log-aggregation/etc/microservices-log-aggregation-flowchart.png differ diff --git a/monad/README.md b/monad/README.md index e63d830a7..4fdf14763 100644 --- a/monad/README.md +++ b/monad/README.md @@ -43,6 +43,10 @@ Wikipedia says > In functional programming, a monad is a structure that combines program fragments (functions) and wraps their return values in a type with additional computation. In addition to defining a wrapping monadic type, monads define two operators: one to wrap a value in the monad type, and another to compose together functions that output values of the monad type (these are known as monadic functions). General-purpose languages use monads to reduce boilerplate code needed for common operations (such as dealing with undefined values or fallible functions, or encapsulating bookkeeping code). Functional languages use monads to turn complicated sequences of functions into succinct pipelines that abstract away control flow, and side effects. +Flowchart + +![Monad flowchart](./etc/monad-flowchart.png) + ## Programmatic Example of Monad Pattern in Java Here’s the Monad implementation in Java. The `Validator` class encapsulates an object and performs validation steps in a monadic fashion, showcasing the benefits of using the Monad pattern for error handling and state management. diff --git a/monad/etc/monad-flowchart.png b/monad/etc/monad-flowchart.png new file mode 100644 index 000000000..0db0e5e12 Binary files /dev/null and b/monad/etc/monad-flowchart.png differ diff --git a/monitor/README.md b/monitor/README.md index 46d5b6867..ecf229d71 100644 --- a/monitor/README.md +++ b/monitor/README.md @@ -36,6 +36,10 @@ Wikipedia says > In concurrent programming (also known as parallel programming), a monitor is a synchronization construct that allows threads to have both mutual exclusion and the ability to wait (block) for a certain condition to become false. Monitors also have a mechanism for signaling other threads that their condition has been met. +Sequence diagram + +![Monitor sequence diagram](./etc/monitor-sequence-diagram.png) + ## Programmatic Example of Monitor Pattern in Java The Monitor design pattern is a synchronization technique used in concurrent programming to ensure that only one thread can execute a particular section of code at a time. It is a method of wrapping and hiding the synchronization primitives (like semaphores or locks) within the methods of an object. This pattern is useful in situations where race conditions could occur. diff --git a/monitor/etc/monitor-sequence-diagram.png b/monitor/etc/monitor-sequence-diagram.png new file mode 100644 index 000000000..94f85d275 Binary files /dev/null and b/monitor/etc/monitor-sequence-diagram.png differ diff --git a/monostate/README.md b/monostate/README.md index 33a603502..5a69c4a3d 100644 --- a/monostate/README.md +++ b/monostate/README.md @@ -34,6 +34,10 @@ wiki.c2.com says > A monostate is a "conceptual singleton" - all data members of a monostate are static, so all instances of the monostate use the same (static) data. Applications using a monostate can create any number of instances that they desire, as each instance uses the same data. +Flowchart + +![Monostate flowchart](./etc/monostate-flowchart.png) + ## Programmatic Example of Monostate Pattern in Java The Monostate pattern in Java ensures that all instances of a class share the same state, making it a great Singleton alternative for maintaining consistent data. This is achieved by using static fields in the class. Any changes to these fields will be reflected across all instances of the class. This pattern is useful when you want to avoid global variables but still need a shared state across multiple instances. diff --git a/monostate/etc/monostate-flowchart.png b/monostate/etc/monostate-flowchart.png new file mode 100644 index 000000000..44e93e200 Binary files /dev/null and b/monostate/etc/monostate-flowchart.png differ diff --git a/multiton/README.md b/multiton/README.md index 34e37866a..f1df11dc2 100644 --- a/multiton/README.md +++ b/multiton/README.md @@ -32,6 +32,10 @@ Wikipedia says > In software engineering, the multiton pattern is a design pattern which generalizes the singleton pattern. Whereas the singleton allows only one instance of a class to be created, the multiton pattern allows for the controlled creation of multiple instances, which it manages through the use of a map. +Flowchart + +![Multiton flowchart](./etc/multiton-flowchart.png) + ## Programmatic Example of Multiton Pattern in Java In this tutorial, we’ll explore how to implement the Multiton pattern in Java, covering its structure, benefits, and providing code examples. By following these implementation tips, you’ll be able to effectively utilize this Java design pattern. diff --git a/multiton/etc/multiton-flowchart.png b/multiton/etc/multiton-flowchart.png new file mode 100644 index 000000000..bc3c119e6 Binary files /dev/null and b/multiton/etc/multiton-flowchart.png differ diff --git a/mute-idiom/README.md b/mute-idiom/README.md index 3999d7ab9..c75db9fac 100644 --- a/mute-idiom/README.md +++ b/mute-idiom/README.md @@ -34,6 +34,10 @@ In plain words > The Mute Idiom design pattern suppresses the handling of trivial or non-critical exceptions to simplify code. +Flowchart + +![Mute Idiom flowchart](./etc/mute-idiom-flowchart.png) + ## Programmatic Example of Mute Idiom Pattern in Java In the following Java code example, we demonstrate the Mute Idiom by muting non-critical exceptions during the resource management process. This approach ensures error handling does not interrupt the main logic. diff --git a/mute-idiom/etc/mute-idiom-flowchart.png b/mute-idiom/etc/mute-idiom-flowchart.png new file mode 100644 index 000000000..846c3b32d Binary files /dev/null and b/mute-idiom/etc/mute-idiom-flowchart.png differ