VS 2008 当我们需要给一个已有的对象动态的附加状态或行为时,使用装饰模式。 装饰模式的要点是:装饰类实现了最初的被装饰类,并且包含了被装饰类的一个实例1. 模式静态类图2. 应用 从一只可以写的Pen开始 把它装饰成有颜色的笔、粗线的笔,甚至可以是有颜色且粗线的笔IWritable using System;using System.Collections.Generic;using System.Linq;using System.Text;} Pen using System;using System.Collections.Generic;using System.Linq;using System.Text;} ColoredPen using System;using System.Collections.Generic;using System.Linq;using System.Text;} BoldPen 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.Decorator.BLL;} 相关文章: 2017-12-13 2021-07-05 2021-10-13 2021-12-11 2022-02-22