This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Chain of Responsibility Pattern [GoF] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Chain of Responsibility Pattern [GoF]" Watch "Chain of Responsibility Pattern [GoF]" New topic

Chain of Responsibility Pattern [GoF]

Victor M. Pereira
Ranch Hand

Joined: Mar 02, 2012
Posts: 50
I'm studying the gang of four book to add more patterns to what I know. And I've stumbled across the chain of responsibility pattern.

From what I read from the book and the internet. I saw two different approaches:

1) Traverses whole tree of successions and applies every handle that can do something with the data. This seemed like a if applicable decorate.

2) This one was traverse the tree until someone can do something about it, if it ends have a default.

The main problem is that I can't see myself using them. Since, most internet examples aren't really CoR but some mock of Strategy. In what cases can I really say
this is without a doubt CoR (Chain of Responsibility).

Victor M. Pereira
Jelle Klap

Joined: Mar 10, 2008
Posts: 1932

Servlet filters come to mind as an example of this pattern in practice.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
I agree. Here's the link:
subject: Chain of Responsibility Pattern [GoF]
It's not a secret anymore!