Chapter 24
- The chain of responsibility pattern gracefully handles an unknown number of requests or events that our program needs to process. This is useful in event-based logic such as purchase applications and shipping systems.
- In our system, if an object does not know how to handle a given request, it passes the request along the chain. As we have seen, a
close
event cannot be handled directly bySendDialog
andMsgText
and is passed toMainWindow
. - The chain of responsibility pattern may not be useful if there are multiple requests, but they may be processed by a single object. This renders all the bookkeeping that's done by the pattern useless.