2005年11月1日

proxy

摘要: 若需处理需要大量创建时间、复杂或占用内存太多的对象,应使用proxy模式。通过proxy模式 可以将大对象的创建时间推迟至真正使用之时public class HelloPrinterProxy:IHelloPrinter{ string language; IHelloPrinter printer=null; HelloPrinterProxy(string language) ... 阅读全文

posted @ 2005-11-01 13:51 井泉 阅读(277) 评论(0) 推荐(0) 编辑

memento 纪念品

摘要: memento仅存储对象状态 ,以便以后进行恢复。public class OurObjectMemento{ int internalState; string anotherState; public int InternalState { get { return internalState; } set { internalState =... 阅读全文

posted @ 2005-11-01 13:32 井泉 阅读(155) 评论(0) 推荐(0) 编辑

strategy 策略

摘要: strategy 可以封装算法 并在运行时更改他们相比较而言,decorator 模式更改了皮肤 而 strategy 模式改变的是内脏strategy 模式类似于factory 模式 但factory模式在创建时改变对象 ,而 stratrgy 模式则可以自由切换public interface IHelloStrategy{ string GenerateHelloString();} ... 阅读全文

posted @ 2005-11-01 11:48 井泉 阅读(151) 评论(0) 推荐(0) 编辑

decorator 装饰者

摘要: decorator运行时为对象添加功能public interface IHelloPrinter{ void PrintHello();} public interface IHelloPrinterDecorator : IHelloPrinter{ void PrintGoodbye();} public abstract class AbstractHelloPrinterDe... 阅读全文

posted @ 2005-11-01 11:09 井泉 阅读(200) 评论(0) 推荐(0) 编辑

factory

摘要: factory 模式 从若干个可能类创建对象 public interface IHelloPrinter{ void PrintHello();}public class EnglishHelloPrinter:IHelloPrinter{ void PrintHello(){ System.Console.write(""); ... 阅读全文

posted @ 2005-11-01 10:21 井泉 阅读(223) 评论(0) 推荐(0) 编辑

singleton

摘要: singleton 模式是一种面向模式的全局变量创建方法,确保了在运行时只有singleton类的一个实例。他还提供了一个全局访问点。 在应用程序运行时,如果确定只需要一个对象实例,那么就应该使用singleton模式。 class ExampleSingleton{ public void PrintHello() { Syste... 阅读全文

posted @ 2005-11-01 09:18 井泉 阅读(235) 评论(0) 推荐(0) 编辑

导航