泡泡

              宠辱不惊-闲看庭前花开花落
                           去留无意-漫观天外云展云舒
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2007年9月19日

摘要: 享元模式的目的是: 使多个客户共享使用数量有限的对象。 实例代码(类似于String类中实例): abstract class Character { protected char symbol; protected int width; protected int height; protected int ascent; protected int desc... 阅读全文

posted @ 2007-09-19 17:13 AlanPaoPao 阅读(105) 评论(0) 推荐(0)

摘要: 外观模式的目的是: 为子系统中的一组接口提供一个高层接口,使得这一子系统更加容易使用。 实例代码: class User { private string name; public User(string name) { this.name = name; } public string Name { get { return this.na... 阅读全文

posted @ 2007-09-19 16:43 AlanPaoPao 阅读(159) 评论(0) 推荐(0)

摘要: 装饰模式的目的是: 动态地给一个对象添加一些额外的职责(比生成子类更为灵活)。 实例代码: interface IItemLibrary { void Display(); int ItemCount { get; set; } double Price { get; set; } } abstract class ItemLibrary : IItemLibrary ... 阅读全文

posted @ 2007-09-19 15:07 AlanPaoPao 阅读(212) 评论(0) 推荐(0)

摘要: 组合模式的目的是: 用户对单个对象和组合对象的使用具有一致性。 实例代码: abstract class TreeElement { protected string name; public TreeElement(string name) { this.name = name; } public abstract void Add(TreeEleme... 阅读全文

posted @ 2007-09-19 13:37 AlanPaoPao 阅读(129) 评论(0) 推荐(0)

摘要: 桥接模式的目的是: 将抽象部分与实现部分分离,使它们都可以独立的变化。 实例代码: class Ticket //奖券 { private String code; private String dept; private String status; public String Code { get { return code; } set ... 阅读全文

posted @ 2007-09-19 13:09 AlanPaoPao 阅读(136) 评论(0) 推荐(0)

摘要: 适配器模式的目的是: 将一个类的接口转换成客户希望的另外一个接口。 实例代码: class EmployeeDatabank { public Int32 GetAge(String name) { Int32 age = 0; switch (name.ToLower()) { case "paopao": age = 25; bre... 阅读全文

posted @ 2007-09-19 09:23 AlanPaoPao 阅读(140) 评论(0) 推荐(0)