C + + Design Pattern:what is a design Pattern?

Source: Internet
Author: User

Q: What is a Design Pattern?

a: Design Patterns represent solutions to problems what arise when developing software within A Particular context.

Each pattern describes a problem which occurs over and over again in we environment, and then describes the core of the S Olution to so problem, in such a-on-the-same-the-solution a million times over, without ever doing it the same The twice.
C. Alexander, The Timeless to Building, 1979Patterns help you learn from other ' s successes, instead of your own failures.
Mark Johnson(Cited by Bruce Eckel)


Q: How many types of design patterns exist?

A: Basically, there is three categories:

    • creational Patterns: Deal with initializing and configuring classes and objects
    • Structural Patterns: Deal with decoupling the interface and implementation of classes and objects
    • Behavioral Patterns: deal with dynamic interactions among societies of classes and objects






Q: What is good books about design patterns.

A: Here is some must-have books:

    • Design Patterns by Erich Gamma, Richard Helm, Ralph Johnson, John vlissides (also known as Gang of four)
    • Thinking in Patterns with Java, by Bruce Eckel
    • Thinking in Patterns with C + +, by Bruce Eckel




Q: How can I quickly find information about a design pattern?

A: Here is some links on the Web:

General

    • Design Patterns




creational Patterns

    • Abstract Factory: Creates an instance of several families of classes
      • Resource 1
      • Resource 2
    • Builder: Separates object construction from its representation
      • Resource 1
      • Resource 2
    • Factory Method: Creates an instance of several derived classes
      • Resource 1
      • Resource 2
      • Resource 3
    • Prototype: A fully initialized instance to be copied or cloned
      • Resource 1
      • Resource 2
    • Singleton: A class of which only a single instance can exist
      • Resource 1
      • Resource 2




Structural Patterns

  • Adapter: Match Interfaces of different classes
    • Resource 1
    • Resource 2
    • Resource 1
  • Bridge: Separates an object ' s interface from its implementation
    • Resource 1
    • Resource 2
  • Composite: A tree structure of simple and Composite objects
    • Resource 1
    • Resource 2
    • Resource 3
  • Decorator: Add responsibilities to objects dynamically
    • Resource 1
    • Resource 2
    • Resource 3
  • Façade: A single class, represents an entire subsystem
    • Resource 1
    • Resource 2
  • Flyweight: A fine-grained instance used for efficient sharing
    • Resource 1
    • Resource 2
    • Resource 3
  • Proxy: An object representing another object
    • Resource 1
    • Resource 2



Behavioral Patterns

    • Chain of Responsibility: A-by-passing a request between a Chain of objects
      • Resource 1
      • Resource 2
    • command: Encapsulate a command request as an object
      • Resource 1
      • Resource 2
      • Resource 3
    • interpreter: A-to-include language elements in A program
      • Resource 1
      • Resource 2
    • Iterator: Sequentially access the elements of a collection
      • Resource 1
      • Resource 2
    • Mediator: Defines simplified communication between classes
      • Resource 1
      • Resource 2
    • Memento: Capture and restore an object ' s internal state
      • Resource 1
    • Observer: A-A-notifying change to a number of classes
      • Resource 1
      • Resource 2
      • Resource 3
    • State: Alter A object ' s behavior when it state changes
      • Resource 1
      • Resource 2
      • Resource 3
    • Strategy: Encapsulates an algorithm inside a class
      • Resource 1
      • Resource 2
      • Resource 3
    • Template Method: Defer The exact steps of an algorithm to a subclass
      • Resource 1
      • Resource 2
      • Resource 3
    • Visitor: Defines a new operation to a class without change
      • Resource 1
      • Resource 2
      • Resource 3

and more resources on (www.oodesign.com). Make sure you read the design principles, it's very usefull for understanding the desing patterns:

OO Design principles:
Open Close Principle
Dependency inversion Principle
Interface sergregation Principle
Single Responsibility Principle
Liskov ' s Substitution Principle


Creational Patterns:
Singleton
Factory
Factory Method
Abstract Factory
Builder
Prototype
Object Pool

Behavioral Patterns:
Chain of Responsibility
Command
Interpreter
Iterator
Strategy
Template Method
Visitor

C + + Design Pattern:what is a design Pattern?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.