[Codeguru] C ++ design pattern: What is a design pattern?

Source: Internet
Author: User
February 9th, 2005, AM
Http://www.codeguru.com/forum/showthread.php? T = 327982

C ++ design pattern: What is a design pattern? Q: What is a design pattern?

A: Design patterns representSolutionsToProblemsWhat arise when developing software within a participantContext.

Quote:
Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.
C. Alexander,The timeless way of building, 1979
Quote:
Patterns 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 are three categories:

  • Creational patterns: Deal With initializing and naming 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 are good books about design patterns.

A: Here are 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 are 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 C Ade: A single class that 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 way of 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 Way 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 way of changing Ying change to a number of classes
    • Resource 1
    • Resource 2
    • Resource 3
  • State: Alter an object's behavior when its 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

Last edited by Andreas Masur; July 27th, 2005 at pm.

Cilu
View Public Profile
Visit cilu's homepage!
Find all posts by cilu

#2 February 11th, 2007, AM

Adiian junior member   Join Date: Sep 2006 posts: 1

Re: C ++ design pattern: What is a design pattern? 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

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.