From 3c4ae6c4ca897d5f741d5741f454a010646b05ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Sun, 30 Aug 2020 19:17:45 +0300 Subject: [PATCH] Update README.md --- pipeline/README.md | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/pipeline/README.md b/pipeline/README.md index fd03cd7b9..d7f0f749b 100644 --- a/pipeline/README.md +++ b/pipeline/README.md @@ -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