天天看點

Software Design Patterns in C#

軟體設計模式C#

Software Design Patterns in C#

設計模式(Design Patterns)是你在實際應用程式開發中,對不斷發現的軟體設計問題的重複解決方案。設計模式是關于對象的設計和互動,關于對經常出現的軟體開發挑戰的一些完美和重用的解決方案,也提供了一個交流平台,

“四人幫”(GOF)模式被認為是所有其他模式的基礎,23種設計模式分為3類:建立型模式(Creational Pattern),結構型模式(Structural Pattern)和行為型模式(Behavioral Pattern)。

為了讓你先起步,這裡提供了2種形式的源碼:結構方面的(structural)和現實應用方法的(real-world)。結構方面的代碼使用模式定義和UML類圖中提供的類型名稱,而實際應用方面的代碼提供了你需要使用模式的真實設計情況。

  Creational Patterns 建立型模式
  Abstract Factory   Creates an instance of several families of classes
  Builder   Separates object construction from its representation
  Factory Method   Creates an instance of several derived classes
  Prototype   A fully initialized instance to be copied or cloned
  Singleton   A class of which only a single instance can exist
  Structural Patterns 結構型模式
  Adapter   Match interfaces of different classes
  Bridge   Separates an object’s interface from its implementation
  Composite   A tree structure of simple and composite objects
  Decorator   Add responsibilities to objects dynamically
  Façade   A single class that represents an entire subsystem
  Flyweight   A fine-grained instance used for efficient sharing
  Proxy   An object representing another object
  Behavioral Patterns 行為型模式
  Chain of Resp.   A way of passing a request between a chain of objects
  Command   Encapsulate a command request as an object
  Interpreter   A way to include language elements in a program
  Iterator   Sequentially access the elements of a collection
  Mediator   Defines simplified communication between classes
  Memento   Capture and restore an object's internal state
  Observer   A way of notifying change to a number of classes
  State   Alter an object's behavior when its state changes
  Strategy   Encapsulates an algorithm inside a class
  Template Method   Defer the exact steps of an algorithm to a subclass
  Visitor   Defines a new operation to a class without change

原英文URL:

http://www.dofactory.com/Patterns/Patterns.aspx#list

上述各類模式的連結均提供了簡單的解釋、UML類圖、Structural code(C#)和Real-world code(C#)。

繼續閱讀