zoukankan      html  css  js  c++  java
  • 设计模式总览

    From http://www.codeproject.com/Articles/106198/Design-Patterns-nuff-said

    Popular design pattern introduced by GoF are as follows:

    Category: Creational design 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

    Category: Structural design 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

    Category: Behavioral design patterns

    • Chain of responsibility - 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

    For each design pattern we should explore following points:-

    1. Design pattern name
    2. Intent – What all design problems it solves
    3. Motivation – Understanding the design problems solved by this design pattern to appreciate its intent
    4. Applicability – Known practical applications. These applications are many of the few to give you a head start to explore new software design areas where this pattern is applicable. It will come with practice and experience so beginners do not worry about this now.
    5. Structure / UML diagram
    6. Participants – Roles of each class in design pattern structure described in point 5.
    7. Collaborations – Object communication
    8. Consequences – What things we can do after using design pattern which are not possible without using it.
    9. Implementation and Implementation issue – How to map design into language specific working application 
    10. Sample code – The application code
    11. Known issues – pattern limitations and their solution if any. 
    12. Related patterns – Compound pattern. Matter of advance research for beginners. 

    The first thing that GoF done towards making 'the Intent' of the design patterns clear is by doing high level categorization of design patterns:-

    • Creational Design Patterns: If answers to any of the following question is ‘Yes’ then your design need one of the Creational Design Pattern
    • Is my design is having object creation logic?
    • Is object creation logic is complex and needs to be simplified?
    • Is object creation logic is subject to frequent changes in future and hence need to decoupled from client logic?
    • Structural Design Patterns: We need one of the Structural Design Pattern when
    • We are in process of building new types (specifying new class definitions) or extending existing types (through inheritance or composition) and we want that our new types addition will not make our design complex to understand and it works with same client code thus promoting code re-use by the virtue of loosely coupled design
    • Our design is affected by problems like class explosion, machine resources limitations etc.
    • Behavioral Design Patterns: We need one of the Behavioral Design Pattern when
    • We need to simply object communication by virtue of loosely coupled design
    • Having division of responsibility in context of algorithms and at the same time we want our design to be scalable with respect to addition/modification of algorithms
  • 相关阅读:
    在ChemDraw中输入千分号的方法
    将几何画板x轴坐标值换成弧度制的方法
    几何画板怎么会出现符号乱码
    几何画板绘制正方形网格的技巧
    怎么用ChemDraw 15.1 Pro绘制彩色结构
    深入理解:单一入口、MVC、ORM、CURD、ActiveRecord概念
    IIS下PHP的ISAPI和FastCGI比较
    非常好用的两个PHP函数 serialize()和unserialize()
    为什么要让我们的“领域模型”裸奔?
    依赖注入
  • 原文地址:https://www.cnblogs.com/windy86/p/3978699.html
Copyright © 2011-2022 走看看