Layered and Pipe-and-Filter
Asked Answered
A

2

5

I'm a bit confused in which situations these patterns should be used, because in some sense, they seem similar to me?

I understand that Layered is used when system is complex, and can be divided by its hierarchy, so each layer has a function on different level of hierarchy, and uses the functions on the lower level, while in the same time exposes its function to higher level.

On the other hand, Pipe-and-Filter is based on independent components that process data, and can be connected by pipes so they make a whole that executes the complete algorithm.

But if the hierarchy does not exist, it all comes to question if order of the modules can be changed?

And an example that confuses me is compiler. It is an example of pipe-and-filter architecture, but the order of some modules is relevant, if I'm not wrong?

Some example to clarify things would be nice, to remove my confusion. Thanks in advance...

Auvil answered 26/1, 2014 at 15:7 Comment(0)
C
9

Maybe it is too late to answer but I will try anyway. 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. The car will be assembled from the first station to the last. If nothing goes wrong, you will get a complete car at the end. And this is also true for compiler example. You get the binary code after from the last compiling process.

On the other hand, Layered architecture dictates that the components are grouped in so-called layers. Typically, the client (the user or component that accesses the system) can access the system only from the top-most layer. He also does not care how many layers the system has. He cares only about the outcome from the layer that he is accessing (which is the top-most one). This is not the same as Pipe-and-Filter where the output comes from the last filter.

Also, as you said, the components in the same layer are using "services" from the lower layers. However, not all services from the lower layer must be accessed. Nor that the upper layer must access the lower layer at all. As long as the client gets what he wants, the system is said to work. Like TCP/IP architecture, the user is using a web browser from application layer without any knowledge how the web browser or any underlying protocols work.

To your question, the "hierarchy" in layered architecture is just a logical model. You can just say they are packages or some groups of components accessing each other in chain. The key point here is that the results must be returned in chain from the last component back to the first one (where the client is accessing) too. (In contrast to Pipe-and-Filter where the client gets the result from the last component.)

Cardamom answered 4/5, 2014 at 11:38 Comment(0)
O
4

1.) Layered Architecture is hierarchical architecture, it views the entire system as -

hierarchy of structures

The software system is decomposed into logical modules at different levels of hierarchy.

where as

2.) Pipe and Filter is a Data-Flow architecture, it views the entire system as -

series of transformations on successive sets of data

where data and operations on it are independent of each other.

Overrun answered 10/3, 2015 at 9:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.