Update README.md

This commit is contained in:
Ilkka Seppälä 2020-08-30 19:17:45 +03:00
parent 9ff42389c6
commit 3c4ae6c4ca

View File

@ -9,19 +9,22 @@ tags:
---
## Intent
Allows processing of data in a series of stages by giving in an initial input and passing the processed output to be
used by the next stages.
Allows processing of data in a series of stages by giving in an initial input and passing the
processed output to be used by the next stages.
## Explanation
The Pipeline pattern uses ordered stages to process a sequence of input values. Each implemented task is represented by
a stage of the pipeline. You can think of pipelines as similar to assembly lines in a factory, where each item in the
assembly line is constructed in stages. The partially assembled item is passed from one assembly stage to another. The
outputs of the assembly line occur in the same order as that of the inputs.
The Pipeline pattern uses ordered stages to process a sequence of input values. Each implemented
task is represented by a stage of the pipeline. You can think of pipelines as similar to assembly
lines in a factory, where each item in the assembly line is constructed in stages. The partially
assembled item is passed from one assembly stage to another. The outputs of the assembly line occur
in the same order as that of the inputs.
Real world example
> Suppose we wanted to pass through a string to a series of filtering stages and convert it as a char array on the last stage.
> Suppose we wanted to pass through a string to a series of filtering stages and convert it as a
> char array on the last stage.
In plain words
@ -29,7 +32,9 @@ In plain words
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.
> 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.
**Programmatic Example**
@ -88,14 +93,17 @@ And here's the `Pipeline` in action processing the string.
```
## Class diagram
![alt text](./etc/pipeline.urm.png "Pipeline pattern class diagram")
## Applicability
Use the Pipeline pattern when you want to
* Execute individual stages that yields a final value
* Add readability to complex sequence of operations by providing a fluent builder as an interface
* Improve testability of code since stages will most likely be doing a single thing, complying to the [Single Responsibility Principle (SRP)](https://java-design-patterns.com/principles/#single-responsibility-principle)
* Execute individual stages that yields a final value.
* Add readability to complex sequence of operations by providing a fluent builder as an interface.
* Improve testability of code since stages will most likely be doing a single thing, complying to
the [Single Responsibility Principle (SRP)](https://java-design-patterns.com/principles/#single-responsibility-principle)
## Known uses