These two design pattern i.e. Proxy design pattern and chain of responsibility (CoR) seems similarity somewhere or others. Structurally both are same but intent of both design pattern are different. Let me explain the similarity and differences between them.
Proxy Design Pattern
control Access to it.
What is proxy?
It’s an intermediary between a client object and the target object. responsibility wise it, It receives a call from client object and forwards them to the target Object.
Chain of Responsibility
allows an object to send a command without knowing what object will receive and handle it.
The Chain of Responsibility design pattern allows an object to send a command without knowing what object will receive and handle it. The request is sent from one object to another making them parts of a chain and each object in this chain can handle the command, pass it on or do both.
The example of Chain of Responsibility is Filter Interceptor in core J2EE design pattern. In the Filter there is a chain and no one know about another , if any filter does not fulfilled then request to next filter , if fulfilled then return from the same filter to caller. There could be possibility that no one fulfilled the request. Another example of approval of Purchase Order in work flow by Manger, sr Manger, Director, AVP, VP, COO etc.. Every person has limit to approve if limit exceeds , send request to next in the work flow.
Key Points[table “” not found /]
Please write your comment to improve this post.