"Design Mode Design Pattern" reading notes 13

xiaoxiao2021-03-06  23

"Design Mode Design Pattern" reading notes 13

Chain of Responsibility

structure

purpose

By release the binding between the sender and the recipient of the message / request, the REQUEST is allowed to transmit, increasing the flexibility of the Request processing in an object chain. Of course, an inevitable possibility is that the request may be delivered to the end of the object chain until it is not processed.

discuss

1. For Success, if there is no problem, you can use the existing object structure, such as if there is a Parent Reference in Composite. If you can't, you can only create a dedicated connection for Successor.

2. If necessary, you can create a request object, and passed to HandleRequest () as a parameter. Then, the Run-Time Type Information can be utilized to determine the type of the request, or the REQUEST object provides functions such as getkind ().

Reference

"Design Pattern" Gang-Of-4 1997

转载请注明原文地址:https://www.9cbs.com/read-43646.html

New Post(0)