您的位置:首页 > 其它

Core Design Patterns(13) Strategy 策略模式

2008-03-16 16:58 330 查看
VS 2008

一个类的某个行为可能有多种实现策略,可以将这个行为提取出来定义为接口,那么就可以提供这个接口的多个实现。这些类(策略)可以相互替换而不影响客户端代码。

1. 模式UML图



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

CommonDiscountStrategy.cs



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

GoldenDiscountStrategy.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

Book.cs



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

Client



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using DesignPattern.Strategy.BLL;

Output


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: