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

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.

主站蜘蛛池模板: 禄丰县| 息烽县| 叙永县| 唐山市| 无锡市| 南开区| 康马县| 吉木乃县| 临漳县| 白沙| 连平县| 英山县| 邓州市| 邢台市| 大田县| 吉木乃县| 西昌市| 九台市| 城口县| 穆棱市| 紫阳县| 安顺市| 商洛市| 太白县| 江城| 定州市| 海门市| 潼南县| 宜兰县| 宣化县| 贵德县| 长沙市| 子长县| 湾仔区| 巴楚县| 石河子市| 康乐县| 玉树县| 溆浦县| 葫芦岛市| 托克逊县|