Reputation: 153
I'm trying to get my head around these two patterns and am wondering about the similarities and differences. To me they are similiar in ways as they both seem to use the step by step process. Could someone shed some more light on these two patterns? Am I right in saying that the pipe and filter pattern would be used in larger scale applications and builder pattern used on small scale applications? Sorry to go on a bit but in builder pattern do all steps happen at the same time i.e. all attributes passed to the builder before the completed object is returned?
Thanks.
Upvotes: 2
Views: 1495
Reputation: 572
Pipes and Filters pattern is Enterprice integration pattern, while the Builder pattern is one of the object-oriented design pattern.
These two patterns have a different semantics:
As you can see, it is incorrect to compare these two patterns. But they can be used in conjunction: using Builder you can configure what will Filters
participate in the processing of the message type of T
. After, configured object can be used:
To create Endpoints (it will Pipes), through which the message will be transmitted
To create a Processes (or even instances of virtual machines, it depends on the application) that will process messages (this will Filters)
For example, you have Book sale system:
In this case Pipes may be a TCP channel, Filters will process the order.
The ordering process for ordinary users would be:
The ordering process for privileged users:
As can be seen, the two processes differ from each other by one step. Branching process occurs after the user's authorization. After user authorization, Filter #2 (Authorization) must generate and send a message of a certain type: privileged or normal user. After sending this message should react different Filters. Filter for discount calculation for the privileged user or withdrawal of money for the ordinary user. This configuration in declarative manner can be describe using Builder pattern.
Upvotes: 2