0

I was just experimenting with the Chain of responsibility design pattern, implementing my own version.

I'm currently reading Design Patterns, but I'm not really sure whether DP tells to stop the forwarding of the requests when a single action is accomplished, or just continuing to the end of the chain.

What I'm interested in is how this feature of the COR pattern is managed in most of cases. In my example below, I let the forwarding continue to the end of my chain.

I don't think you need any source, but you can anyway find it here.

If I missed some DP paragraphs telling about this, please provide me its location!

  • 1
    I don't understand your question. What do you mean by "how the original COR pattern is built?" Didn't you already answer that by linking to the example source code> – Robert Harvey Oct 11 '13 at 19:41
  • Just edited my question. Thanks for pointing out my mistake. – Acsor Oct 11 '13 at 19:45
0

in this example there is very distinct line drawn that one thing permanently handles the request, and only if that thing is unable to handle it does the next in line even get a chance to look at the request.

public override void ProcessRequest(Purchase purchase)  
{  
  if (purchase.Amount < 10000.0)  
  {  
    Console.WriteLine("{0} approved request# {1}",  
    this.GetType().Name, purchase.Number);  
  }  
  else if (successor != null)  
  {  
    successor.ProcessRequest(purchase);  
  }  
}  

http://www.dofactory.com/Patterns/PatternChain.aspx#_self2

i have a feeling there is more richness and dynamicism to be had here. like you could have one of these handlers, that had a certain threshold where it would allow the next in line to 'bid' and then make a decision. you'd really have to write such logic, and keep in organized as the base pattern doesn't really address this kind of complexity.

i'd say that such rich patterns would tend towards an overall Reponsibility Driven Design instead of a cookie cutter Chain of R.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.