Solution: Piping through Filters
The Pipes and Filters pattern structures the processing of a stream of data. Each processing step is implemented as a filter, with information flowing between the filters through a pipe. Filters can be combined in many ways to provide a family of solutions.
Exploring the effects of Pipes and Filters
In any design activity, the choices that you make have consequences. This section looks at the consequences of defining a Pipes and Filters architecture.
Benefits
The Pipes and Filters architecture has the following benefits:
- The system's behavior is very flexible. By exchanging filters for new and different filters or rearranging the filters in a different order, you can change the system's behavior.
- The filters can be reused in other situations. Because the inputs and outputs are well defined and standard, you can use the filters created for one application for different applications and combine them with different filters.
Piping water to your house
The pipes that bring water to your house are a real-world example of Pipes and Filters. The water comes from its source to the first filter through a pipe. That filter chlorinates the water and directs the output through another pipe. Other filters do further purification. Some of the filters are junctions in the pipes that divert the flow or allow it to be shut off. Eventually, the network of pipes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access