首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

Chain of Responsibility Pattern Example in C

2012-09-01 
Chain of Responsibility Pattern Example in C#The?Chain of Responsibility?pattern takes a request an

Chain of Responsibility Pattern Example in C#

The?Chain of Responsibility?pattern takes a request and flows through a chain of handlers. Each handler checks if it can handle the request according to some business rules. If the handler can’t handle the request it gets passed to the next handler in the chain. The client doesn’t know which handler eventually handles the request.

In this example we send a parcel with a certain value. Some of the packages are insured. Based on the following criteria a package gets a certain treatment. For uninsured parcels with a value lower than 50 there is the budget treatment (you don’t want that). Parcels with a uninsured value from 50 and up get a normal treatment. All insured packages get a treatment deluxe. The chain of handlers is set up in that order.

Chain of Responsibility Pattern Example in C

This design makes it easy to extend, change and maintain serial chain of responsibility rules. Further and recommended readings on the subject by?Anoop Madhusudanan?and?Kory Becker.

热点排行