|
9 | 9 | ---
|
10 | 10 |
|
11 | 11 | ## Intent
|
12 |
| -Allows processing of data in a series of stages by giving in an initial input and passing the processed output to be |
13 |
| -used by the next stages. |
| 12 | + |
| 13 | +Allows processing of data in a series of stages by giving in an initial input and passing the |
| 14 | +processed output to be used by the next stages. |
14 | 15 |
|
15 | 16 | ## Explanation
|
16 | 17 |
|
17 |
| -The Pipeline pattern uses ordered stages to process a sequence of input values. Each implemented task is represented by |
18 |
| -a stage of the pipeline. You can think of pipelines as similar to assembly lines in a factory, where each item in the |
19 |
| -assembly line is constructed in stages. The partially assembled item is passed from one assembly stage to another. The |
20 |
| -outputs of the assembly line occur in the same order as that of the inputs. |
| 18 | +The Pipeline pattern uses ordered stages to process a sequence of input values. Each implemented |
| 19 | +task is represented by a stage of the pipeline. You can think of pipelines as similar to assembly |
| 20 | +lines in a factory, where each item in the assembly line is constructed in stages. The partially |
| 21 | +assembled item is passed from one assembly stage to another. The outputs of the assembly line occur |
| 22 | +in the same order as that of the inputs. |
21 | 23 |
|
22 | 24 | Real world example
|
23 | 25 |
|
24 |
| -> 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. |
| 26 | +> Suppose we wanted to pass through a string to a series of filtering stages and convert it as a |
| 27 | +> char array on the last stage. |
25 | 28 |
|
26 | 29 | In plain words
|
27 | 30 |
|
28 | 31 | > Pipeline pattern is an assembly line where partial results are passed from one stage to another.
|
29 | 32 |
|
30 | 33 | Wikipedia says
|
31 | 34 |
|
32 |
| -> 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. |
| 35 | +> In software engineering, a pipeline consists of a chain of processing elements (processes, |
| 36 | +> threads, coroutines, functions, etc.), arranged so that the output of each element is the input |
| 37 | +> of the next; the name is by analogy to a physical pipeline. |
33 | 38 |
|
34 | 39 | **Programmatic Example**
|
35 | 40 |
|
@@ -88,14 +93,17 @@ And here's the `Pipeline` in action processing the string.
|
88 | 93 | ```
|
89 | 94 |
|
90 | 95 | ## Class diagram
|
| 96 | + |
91 | 97 | 
|
92 | 98 |
|
93 | 99 | ## Applicability
|
| 100 | + |
94 | 101 | Use the Pipeline pattern when you want to
|
95 | 102 |
|
96 |
| -* Execute individual stages that yields a final value |
97 |
| -* Add readability to complex sequence of operations by providing a fluent builder as an interface |
98 |
| -* 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) |
| 103 | +* Execute individual stages that yields a final value. |
| 104 | +* Add readability to complex sequence of operations by providing a fluent builder as an interface. |
| 105 | +* Improve testability of code since stages will most likely be doing a single thing, complying to |
| 106 | +the [Single Responsibility Principle (SRP)](https://java-design-patterns.com/principles/#single-responsibility-principle) |
99 | 107 |
|
100 | 108 | ## Known uses
|
101 | 109 |
|
|
0 commit comments