C++ Design Pattern: What is a Design Pattern?
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
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
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 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 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
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 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
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?的更多相关文章
- HTML:Registry design.(Include a simple web design use HTML)
Registry design: I feel a little bored when I design this registry,so T design a simple website all ...
- 零元学Expression Design 4 - Chapter 2 熟悉Design并且快速设计出Silverlight网页
原文:零元学Expression Design 4 - Chapter 2 熟悉Design并且快速设计出Silverlight网页 本章将用带大家熟悉Design 4并制作简易的网页版面,也会让你了 ...
- [Design Patterns] 03. Behavioral Patterns - Observer Pattern
前言 参考资源 Ref: 史上最全设计模式导学目录(完整版) 观察者模式-Observer Pattern[学习难度:★★★☆☆,使用频率:★★★★★] 对象间的联动——观察者模式(一):多人联机对战 ...
- [Design Patterns] 02. Structural Patterns - Facade Pattern
前言 参考资源 史上最全设计模式导学目录(完整版) 只把常用的五星的掌握即可. 外观模式-Facade Pattern[学习难度:★☆☆☆☆,使用频率:★★★★★] 深入浅出外观模式(一):外观模式概 ...
- Android Material Design:ViewPager与android.support.design.widget.TabLayout双向交互联动切换
通常,android.support.design.widget.TabLayout与Android的ViewPager联合使用,实现与ViewPager的切换与联动.(1)比如,当用户手指触摸选择T ...
- 【译】UI设计基础(UI Design Basics)--为iOS设计(Design for iOS)(二)
2.1 为iOS设计(Design for iOS) iOS体现以下主题: 遵从:UI帮助用户理解界面内容并与内容交互,但绝不会与内容相互冲突. 清晰:文本在任何尺寸下都是清晰易读,图标精确易懂,装饰 ...
- Material Design 开发利器:Android Design Support Library 介绍
转自:https://blog.leancloud.cn/3306/ Android 5.0 Lollipop 是迄今为止最重大的一次发布,很大程度上是因为 material design —— 这是 ...
- Tcl与Design Compiler (十三)——Design Compliler中常用到的命令(示例)总结
本文如果有错,欢迎留言更正:此外,转载请标明出处 http://www.cnblogs.com/IClearner/ ,作者:IC_learner 本文将描述在Design Compliler中常用 ...
- 【java设计模式】【创建模式Creational Pattern】建造模式Builder Pattern
package com.tn.pattern; public class Client { public static void main(String[] args) { Director dire ...
随机推荐
- vc 找到一个或多个多重定义的符号
vc 找到一个或多个多重定义的符号, 这个问题还是不能很好的解决. 最根本的是: 把所有有关定义的部分都放在.cpp文件中,对应的.h文件中只放声明.这样在#include ""的 ...
- linux 删除文件夹及其内容,显示文件路径
比如要删除work文件夹包括里面的内容,则:rm -r /home/ftk/apache-tomcat-5.5.20/work,不管它是文件还是目录都删掉了 知道文件名 要查询文件大概地址用~cd ~ ...
- phpcms二级栏目的调用
1.二级栏目的调用方法 {php $data = subcat($module, $catid);} {loop $data $n $r} {if $r[ismenu]} {$r[catname]} ...
- 笔记:写Java程序,并输出
建一个文件名为 demo.java的文件 //写框架文件 public class Demo{ //写入口文件 public static void main(String[] args){ Syst ...
- linq在获取部门层级树种的应用
public string GetNavigationsJson() { AjaxA_NAVIGATIONS ajaxnavigations = new AjaxA_NAVIGATIONS(); IL ...
- oracle的常用函数 instr() 和substr()函数
from:http://1055592535.iteye.com/blog/1676235 在Oracle中 可以使用instr函数对某个字符串进行判断,判断其是否含有指定的字符. 在一个字符串中查找 ...
- swift -- 计步器CMPedometer的使用
最近公司接了个项目,是一款运动类型的APP,可以检测运动量(例如:步数,上下楼等).睡眠信息.速度等信息,因为以前粗略的了解过传感器方面的相关信息,知道主要是苹果设备内置的传感器在起作用,传感器的种类 ...
- ASP代码审计学习笔记 -3.上传漏洞
1.ASP上传过程抓包分析: POST /4.asp HTTP/1.1 Host: 192.168.1.102 User-Agent: Mozilla/5.0 (Windows NT 10.0; WO ...
- [转载]2014年10月26完美世界校招两道java题
public class VolitileTest { volatile static int count=0; public static void main(String args[]){ for ...
- Linux lspci 命令
PCI(Peripheral Component Interconnect,外设部件互连标准),即定义连接外部设备的一个标准: 主板上有很多 PCI 接口,用来连接显卡.网卡.声卡等外部设备,而 ls ...