名称 Chain of Responsibility
结构  设计模式——链接模式
意图 使多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合关系。将这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它为止。
适用性
  • 有多个的对象可以处理一个请求,哪个对象处理该请求运行时刻自动确定。
  • 你想在不明确指定接收者的情况下,向多个对象中的一个提交一个请求。
  • 可处理一个请求的对象集合应被动态指定。
Code Example
  1设计模式——链接模式// Chain Of Responsibility
  2设计模式——链接模式
  3设计模式——链接模式// Intent: "Avoid coupling the sender of a request to its receiver by giving 
  4设计模式——链接模式// more than one object a chance to handle the reuqest. Chain the receiving 
  5设计模式——链接模式// objects and pass the request along the chain until an object handles it." 
  6设计模式——链接模式
  7设计模式——链接模式// For further information, read "Design Patterns", p223, Gamma et al.,
  8设计模式——链接模式// Addison-Wesley, ISBN:0-201-63361-2
  9设计模式——链接模式
 10

相关文章: