Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Layers and Pipes and filters?

What is difference between these two design patterns? It seems very similar to me, one processing unit (layer or filter) do some data procession and pull / push data into another processing unit. Unit n communicates only with n+1 and n-1 unit, there are interfaces defining functionality that one particular unit offers.

What is difference?

Edit: maybe one difference should be the data flow. In Layers flow can be top-down, bottom-up and/or communication between some layers inside. In Pipes and filters data flow starts at unit 1 and goes to unit n (not back).

like image 490
Artegon Avatar asked Apr 26 '15 08:04

Artegon


People also ask

What is the difference between a pipe and a filter?

A filter transforms data that it receives through one or more pipes and transmits the result through one or more pipes. A pipe is a connector that conveys streams of data from the output port of one filter to the input port of another filter.

What is the difference between a pipe layers and pipe fitters?

Pipe layers generally work on projects that involve laying pipe underground or on the seabed. They work outside, primarily because they lay pipe in trenches in the earth. Pipe fitters, on the other hand, work inside, installing piping into spaces above or below ground or the spaces within buildings or ships.

What is the difference between pipe-and-filter architecture and traditional architecture?

The main difference between the two architectural styles are the flow of data. On one hand, for Pipe-and-Filter, the data are pushed from the first filter to the last one. And they WILL be pushed, otherwise, the process will not be deem success. For example, in car manufacturing factory, each station is placed after one another.

What do the lines in a pipe and filter system represent?

In the pipe-and-filter style, "lines" between components represent connectors, which have a specific computational meaning: They transmit streams of data from one filter to another. In data flow projections, the lines represent relations indicating the communication of data between components.


1 Answers

Organization wise it may looks like both Layers and Pipe and Filters patters are similar (One component taking input and passing result to another) but functionally they are not. They are Architectural Patterns.

If we go by definition:

Pipes and Filters pattern divide a larger processing task into a sequence of smaller, independent processing steps (Filters) that are connected by channels (Pipes).

While in Layer Pattern, each layer communicates with the adjacent layers and is responsible for some processing of its own, passing requests to the layer below it and answering requests from the layer above it.

Comparison:

The pipe and filter pattern allows a system to be assembled from small programs called filters whereas a Layered system is one in which different layers of the system take care of a specific function of the system. 

A filter has an input and an output whereas each layer in a layered architectural style is a package of software (or systems) that has a well-defined interface and a few well-known dependencies within the application.

The filters are assembled into a chain in which each filter gets data from the previous filter in the chain, processes the data, and passes the data to the next filter in the chain whereas in Layered systems dataflow can be bidirectional such that all requests of layer above are fulfilled with or without help of layers below it.

Order may not matter. e.g. you can Authenticate a message and then filter the contents of the message, or you can filter contents first then do authentication whereas in Layered system order is always same and cannot be interchanged.

Hope this helps.

like image 84
Guanxi Avatar answered Sep 20 '22 04:09

Guanxi