官术网_书友最值得收藏!

The chain-of-responsibility pattern

Computer software is for processing information, and there are different ways of structuring and processing that information. We already know that when we talk about object-oriented programming, we should assign a single responsibility to each class in order to make our design easy to extend and maintain.

Consider a scenario where multiple types of operations can be performed on a set of data that comes with a client request. Instead of adding information about all the operations in a single class, we can maintain different classes responsible for the different types of operations. This helps us keep our code loosely coupled and clean.

These classes are called handlers. The first handler will receive the request and take a call if it needs to perform an action, or pass it on to the second handler. Similarly, the second handler checks and can pass on the request to the next handler in the chain.

主站蜘蛛池模板: 蛟河市| 肥西县| 东至县| 台南县| 军事| 杭锦旗| 五华县| 定兴县| 洞口县| 灌阳县| 湘潭市| 西乌珠穆沁旗| 武鸣县| 巴塘县| 靖西县| 阳新县| 烟台市| 新蔡县| 承德县| 白水县| 绩溪县| 台安县| 历史| 嘉义市| 应用必备| 阳原县| 永新县| 涿州市| 离岛区| 梁山县| 石楼县| 武定县| 德惠市| 哈巴河县| 灌云县| 阿合奇县| 德清县| 宁津县| 防城港市| 上饶市| 盐边县|