Implementing the Singleton Pattern in C#
Implementing the Singleton Pattern in C#[@more@]The singleton pattern is one of the best-known patterns in software engineering. Essentially, a singleton is a class which only allows a single instance of itself to be created, and usually gives simple access to that instance. Most commonly, singletons don't allow any parameters to be specified when creating the instance - as otherwise a second request for an instance but with a different parameter could be problematic! (If the same instance shoul
Observer Design Pattern in C# and VB_NET
观察者设计模式(Observer Design Pattern)适用场合观察者模式适合的情况是对象之间是一对多的依赖,在这种情况下,如果一个对象改变了状态,它的依赖的对象被通知到,同时自动改变状态使用的频率: 高UML 类图 参与者在模式中参与的类和对象是: Subject (Stock) 知道它的观察者. 所有的观察对象能观察到一个subject 为添加和删除观察对象提供一个接口. ConcreteSubject (IBM) 储存感兴趣的subject 到ConcreteObserver 当状态改变的时候,发送通知到它的观察者 Observer (IInvestor) 为所有对象定义一个更新接口,以致subject的状态改变能