docs: diagrams for callback, circuit breaker, client session, collecting parameter, colletion pipeline, combinator, command, commander, component, composite entity, composite view, composite, context object, converter, crtp, currying
@@ -41,7 +41,6 @@ Sequence diagram
|
||||
|
||||

|
||||
|
||||
|
||||
## Programmatic Example of Callback Pattern in Java
|
||||
|
||||
We need to be notified after the executing task has finished. We pass a callback method for the executor and wait for it to call back on us.
|
||||
|
||||
@@ -33,6 +33,10 @@ Wikipedia says
|
||||
|
||||
> Circuit breaker is a design pattern used in modern software development. It is used to detect failures and encapsulates the logic of preventing a failure from constantly recurring, during maintenance, temporary external system failure or unexpected system difficulties.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Circuit Breaker Pattern in Java
|
||||
|
||||
This Java example demonstrates how the Circuit Breaker pattern can manage remote service failures and maintain system stability.
|
||||
|
||||
|
After Width: | Height: | Size: 139 KiB |
@@ -33,6 +33,10 @@ Wikipedia says
|
||||
|
||||
> The client-server model on Wikipedia describes a system where client devices request services and resources from centralized servers. This model is crucial in web applications where client sessions are used to manage user-specific data across multiple requests. For example, when a bank customer accesses online banking services, their login credentials and session state are managed by the web server to maintain continuity of their interactions.
|
||||
|
||||
Sequence diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Client Session Pattern in Java
|
||||
|
||||
The Client Session design pattern is a behavioral design pattern that maintains a user's state and data across multiple requests within a web application, ensuring a continuous and personalized user experience. This pattern is commonly used in web applications where user-specific data needs to be managed across multiple requests.
|
||||
|
||||
|
After Width: | Height: | Size: 95 KiB |
@@ -36,6 +36,10 @@ Wikipedia says
|
||||
|
||||
> In the Collecting Parameter idiom a collection (list, map, etc.) is passed repeatedly as a parameter to a method which adds items to the collection.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Collecting Parameter Pattern in Java
|
||||
|
||||
Within a large corporate building, there exists a global printer queue that is a collection of all the printing jobs that are currently pending. Various floors contain different models of printers, each having a different printing policy. We must construct a program that can continually add appropriate printing jobs to a collection, which is called the collecting parameter.
|
||||
|
||||
|
After Width: | Height: | Size: 66 KiB |
@@ -29,6 +29,10 @@ Wikipedia says
|
||||
|
||||
> In software engineering, a pipeline consists of a chain of processing elements (processes, threads, coroutines, functions, etc.), arranged so that the output of each element is the input of the next; the name is by analogy to a physical pipeline. Usually some amount of buffering is provided between consecutive elements. The information that flows in these pipelines is often a stream of records, bytes, or bits, and the elements of a pipeline may be called filters; this is also called the pipe(s) and filters design pattern. Connecting elements into a pipeline is analogous to function composition.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Collection Pipeline Pattern in Java
|
||||
|
||||
The Collection Pipeline is a programming pattern where you organize some computation as a sequence of operations which compose by taking a collection as output of one operation and feeding it into the next.
|
||||
|
||||
|
After Width: | Height: | Size: 30 KiB |
@@ -35,6 +35,10 @@ Wikipedia says
|
||||
|
||||
> A combinator is a higher-order function that uses only function application and earlier defined combinators to define a result from its arguments.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Combinator Pattern in Java
|
||||
|
||||
In software design, combinatory logic is pivotal for creating reusable and modular code components. By leveraging higher-order functions, the Combinator pattern promotes code reuse and maintainability in Java applications.
|
||||
|
||||
|
After Width: | Height: | Size: 30 KiB |
@@ -34,6 +34,10 @@ Wikipedia says
|
||||
|
||||
> In object-oriented programming, the command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time.
|
||||
|
||||
Sequence diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Command Pattern in Java
|
||||
|
||||
In the Command pattern, objects are used to encapsulate all information needed to perform an action or trigger an event at a later time. This pattern is particularly useful for implementing undo functionality in applications.
|
||||
|
||||
|
After Width: | Height: | Size: 53 KiB |
@@ -33,6 +33,10 @@ In plain words
|
||||
|
||||
> The Commander pattern turns a request into a stand-alone object, allowing for the parameterization of commands, queueing of actions, and the implementation of undo operations.
|
||||
|
||||
Sequence diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Commander Pattern in Java
|
||||
|
||||
Managing transactions across different services in a distributed system, such as an e-commerce platform with separate `Payment` and `Shipping` microservices, requires careful coordination. Using the Commander pattern in Java for transaction coordination helps ensure data consistency and reliability, even when services experience partial failures.
|
||||
|
||||
|
After Width: | Height: | Size: 66 KiB |
@@ -30,6 +30,10 @@ In plain words
|
||||
|
||||
> The component design pattern provides a single attribute to be accessible by numerous objects without requiring the existence of a relationship between the objects themselves.
|
||||
|
||||
Architecture diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Component Pattern in Java
|
||||
|
||||
The `App` class creates a demonstration of the use of the component pattern by creating two different objects which inherit a small collection of individual components that are modifiable.
|
||||
|
||||
|
After Width: | Height: | Size: 52 KiB |
@@ -36,6 +36,10 @@ Wikipedia says
|
||||
|
||||
> Composite entity is a Java EE Software design pattern and it is used to model, represent, and manage a set of interrelated persistent objects rather than representing them as individual fine-grained entity beans, and also a composite entity bean represents a graph of objects.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Composite Entity in Java
|
||||
|
||||
For a console, there may be many interfaces that need to be managed and controlled. Using the composite entity pattern, dependent objects such as messages and signals can be combined and controlled using a single object.
|
||||
|
||||
|
After Width: | Height: | Size: 38 KiB |
@@ -29,6 +29,10 @@ Wikipedia says
|
||||
|
||||
> Composite views that are composed of multiple atomic subviews. Each component of the template may be included dynamically into the whole and the layout of the page may be managed independently of the content. This solution provides for the creation of a composite view based on the inclusion and substitution of modular dynamic and static template fragments. It promotes the reuse of atomic portions of the view by encouraging modular design.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Composite View Pattern in Java
|
||||
|
||||
A news site wants to display the current date and news to different users based on that user's preferences. The news site will substitute in different news feed components depending on the user's interest, defaulting to local news.
|
||||
|
||||
|
After Width: | Height: | Size: 59 KiB |
@@ -34,6 +34,10 @@ Wikipedia says
|
||||
|
||||
> In software engineering, the composite pattern is a partitioning design pattern. The composite pattern describes that a group of objects is to be treated in the same way as a single instance of an object. The intent of a composite is to "compose" objects into tree structures to represent part-whole hierarchies. Implementing the composite pattern lets clients treat individual objects and compositions uniformly.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Composite Pattern in Java
|
||||
|
||||
Every sentence is composed of words which are in turn composed of characters. Each of these objects are printable, and they can have something printed before or after them like sentence always ends with full stop and word always has space before it.
|
||||
|
||||
|
After Width: | Height: | Size: 42 KiB |
@@ -36,6 +36,10 @@ In plain words
|
||||
|
||||
> Use a Context Object to encapsulate state in a protocol-independent way to be shared throughout your application.
|
||||
|
||||
Sequence diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Context Object in Java
|
||||
|
||||
In a multi-layered Java application, different layers such as A, B, and C extract specific information from a shared context. Passing each piece of information individually is inefficient. The Context Object pattern efficiently stores and passes this information, improving the overall performance and maintainability of the Java application.
|
||||
|
||||
|
After Width: | Height: | Size: 76 KiB |
@@ -32,6 +32,10 @@ In plain words
|
||||
|
||||
> The Converter Pattern simplifies mapping instances of one class to instances of another class, ensuring consistent and clean data transformation.
|
||||
|
||||
Sequence diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic Example of Converter Pattern in Java
|
||||
|
||||
In applications, it's common for the database layer to have entities that need mapping to DTOs (Data Transfer Objects) for business logic. This mapping often involves many classes, necessitating a generic solution.
|
||||
|
||||
|
After Width: | Height: | Size: 99 KiB |
@@ -40,6 +40,10 @@ Wikipedia says
|
||||
|
||||
> The curiously recurring template pattern (CRTP) is an idiom, originally in C++, in which a class X derives from a class template instantiation using X itself as a template argument.
|
||||
|
||||
Flowchart
|
||||
|
||||

|
||||
|
||||
## Programmatic example of CRTP in Java
|
||||
|
||||
For a mixed martial arts promotion that is planning an event, ensuring that the fights are organized between athletes of the same weight class is crucial. This prevents mismatches between fighters of significantly different sizes, such as a heavyweight facing off against a bantamweight.
|
||||
|
||||
|
After Width: | Height: | Size: 22 KiB |
@@ -33,6 +33,10 @@ Wikipedia says
|
||||
|
||||
> In mathematics and computer science, currying is the technique of translating a function that takes multiple arguments into a sequence of families of functions, each taking a single argument.
|
||||
|
||||
Sequence diagram
|
||||
|
||||

|
||||
|
||||
## Programmatic example of Currying Pattern in Java
|
||||
|
||||
Consider a librarian who wants to populate their library with books. The librarian wants functions which can create books corresponding to specific genres and authors. Currying makes this possible by writing a curried book builder function and utilising partial application.
|
||||
|
||||
|
After Width: | Height: | Size: 68 KiB |