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
  • 相关阅读:
    在数据库中 存储图片 以及 在界面中显示图片(存储图片路径)- 这种方法相对与存储二进制文件好
    # 会员注册与登录模块
    文本文件从磁盘读取、写入
    简单的web三层架构系统【第五版】
    Nginx负载均衡中后端节点服务器健康检查的一种简单方式
    编译安装php-7.1.17及部分扩展
    wkhtmltopdf 安装过程不包含php扩展部分
    Centos6下安装中文字体
    xen 配置vm 跟随xen server一起启动
    CENTOS 升级Nodejs 到最新版本
  • 原文地址:https://www.cnblogs.com/windy86/p/3978699.html
Copyright © 2011-2022 走看看