《设计模式》读书笔记_A

Design Pattern - Elements of Reusable Object Oriented Software Capturing a wealth of experience about the design of object-oriented software, four top-notch designers present a catalog of simple and succinct solutions to commonly occurring design problems. Previously undocumented, these 23 patterns allow designers to create more flexible, elegant, and ultimately reusable designs without having to rediscover the design solutions themselves. The authors begin by describing what patterns are and how they can help you design object-oriented software. They then go on to systematically name, explain, evaluate, and catalog recurring designs in object-oriented systems. With Design Patterns as your guide, you will learn how these important patterns fit into the software development process, and how you can leverage them to solve your own design problems most efficiently. Each pattern describes the circumstances in which it is applicable, when it can be applied in view of other design constraints, and the consequences and trade-offs of using the pattern within a larger design. All patterns are compiled from real systems and are based on real-world examples. Each pattern also includes code that demonstrates how it may be implemented in object-oriented programming languages like C++ or Smalltalk. 立即下载

title:<Design Patterns Elements of Reusable Object-Oriented Software>


author: Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides
version: 1st (1995)

Preface: 


This book assumes you are reasonably proficient in at least one object-oriented programming language, and you should have some experience in object-oriented design as well. 

 This isn't an advanced technical treatise either. It's a book of design patterns that describes simple and elegant solutions to specific problems in object-oriented software design. Design patterns capture solutions that have developed and evolved over time. 

A word of warning and encouragement: Don't worry if you don't understand this book completely on the first reading... We hope you'll find yourself referring to it again and again for design insights and for inspiration.

This book has two main parts. The first part (Chapters 1 and 2) describes what design patterns are and how they help you design object-oriented software. It includes a design case study that demonstrates how design patterns apply in practice. The second part of the book (Chapters 3, 4, and 5) is a catalog of the actual design patterns.

Introduction:

使用OO的思想设计一个大型系统来全面的解决一个庞大问题不是一件容易的事情,真如自然语言有如此多的表达方式一样,设计出灵活、高可重用性、可扩展的OO系统并不是一件容易的事情。往往需要有很多的实际经验积累才能较好的总结出设计的方法,这些宝贵的经验就是本书所主要将要介绍的内容,它将可以帮助我们这些新手快速的学习到前人总结出来的经验,让我们站在巨人的肩膀上吧!
The purpose of this book is to record experience in designing object-oriented software as design patterns. Each design pattern systematically names, explains, and evaluates an important and recurring design in object-oriented systems. Our goal is to capture design experience in a form that people can use effectively.

> what is a design pattern?
   >>"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"-- Christopher Alexander
  >>In general, a pattern has four essential elements:
  1. The pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a word or two. Naming a pattern immediately increases our design vocabulary. It lets us designat a higher level of abstraction. Having a vocabulary for patterns lets us talk about them with our colleagues, in our documentation, and even to ourselves. It makes it easier to think about designs and to communicate them and their trade-offs to others. Finding good names has been one of the hardest parts of developing our catalog.
  2. The problem describes when to apply the pattern. It explains the problem and its context. It might describe specific design problems such as how to represent algorithms as objects. It might describe class or object structures that are symptomatic of an inflexible design. Sometimes the problem will include a list of conditions that must be met before it makes sense to apply the pattern.
  3. The solution describes the elements that make up the design, their relationships, responsibilities, and collaborations. The solution doesn't describe a particular concrete design or implementation, because a pattern islike a template that can be applied in many different situations. Instead, the pattern provides an abstract description of a design problem and how a general arrangement of elements (classes and objects in our case) solves it.
  4. The consequences are the results and trade-offs of applying the pattern. Though consequences are often unvoiced when we describe design decisions, they are critical for evaluating design alternatives and for understanding the costs and benefits of applying the pattern. The consequences for software often concern space and time trade-offs. They may address language and implementation issues as well. Since reuse is often a factor in object-oriented design, the consequences of a pattern include its impact on a system's flexibility, extensibility,  or portability. Listing these consequences explicitly helps you understand and evaluate them.
>>The design patterns in this book are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context.

>以MVC(model-viewer-controller)中设计的几种通用pattern来具体说明本书中将要介绍的pattern是怎么样的一种形式!
MVC中主要的涉及了Observer、Composite、Strategy三种本质的pattern。

>本书中每一个pattern item是如何呈现加以介绍的:
>>    Pattern Name and Classification:The pattern's name conveys the essence of the pattern succinctly. A good name is vital,              because it will become part of your design vocabulary. 
   Intent
   Also Known As
   Motivation
   Applicability
   Structure :A graphical representation of the classes in the pattern using a notation based on the Object Modeling Technique 
   Participants
   Collaborations
  Consequences
 Implementation、Sample Code、Known Uses、Related Patterns

>pattern清单及其分类
>>purpose reflects what a pattern does. Patterns can have either creational, structural, or behavioral purpose. Creational patterns concern the process of object creation. Structural patterns deal with the composition of classes or objects.Behavioral patterns characterize the ways in which classes or objects interact and distribute responsibility. 
 scope specifies whether the pattern applies primarily to classes or to objects. Class patterns deal with relationships between classes and their subclasses. These relationships are established through inheritance, so they are static—fixed at compile-time. Object patterns deal with object relationships, which can be changed at run-time and are more dynamic.

 Purpose
CreationalStructuralBehavioral
ScopeClassFactory MethodAdapterInterpreter 
Template Method
ObjectAbstract Factory 
Builder 
Prototype 
Singleton 
Adapter 
Bridge 
Composite 
Decorator 
Facade 
Proxy 
Chain of Responsibility 
Command 
Iterator 
Mediator 
Memento 
Flyweight (195)
Observer 
State 
Strategy 
Visitor 

Table 1.1:  Design pattern space


>> Creational class patterns defer some part of object creation to subclasses, while Creational object patterns defer it to another object. The Structural class patterns use inheritance to compose classes, while the Structural object patterns describe ways to assemble objects. The Behavioral class patterns use inheritance to describe algorithms and flow of control, whereas the Behavioral object patterns describe how a group of objects cooperate to perform a task that no single object can carry out alone.

How Design Patterns Solve Design Problems

(以下部分介绍了在一个项目的完整开发流程中那些环节可以或者应该使用design pattern来指导具体的实施.同时,这一部分应该看作一个对于OO Language的高层特征的总结.这里对于OO的总结是超越语言的!十分的seminal的!!值得多读几次,反复品味!)


>Finding Appropriate Object.仅仅靠分析现实问题的模型,进而简单直接的映射到OO solution空间中的objects是不恰当的一种方法,会导致系统缺乏可扩展性。

>> Requests are the only way to get an object to execute an operation. Operations are the only way to change an object's internal data

>> The hard part about object-oriented design is decomposing a system into objects
>>Strict modeling of the real world leads to a system that reflects today's realities but not necessarily tomorrow's.The abstractions that emerge during design are key to making a design flexible
>Determining Object Granularity 
>Specifying Object Interfaces:

>>An object's interface characterizes the complete set of requests that can be sent to the object

>> A type is a name used to denote a particular interface. We speak of an object as having the type "Window" if it accepts all requests for the operations defined in the interface named "Window." 

>> Interfaces are fundamental in object-oriented systems. Objects are known only through their interfaces. There is no way to know anything about an object or to ask it to do anything without going through its interface. An object's interface says nothing about its implementation—different objects are free to implement requests differently. Ihterface--Dynamic binding---Polymorphism
>> Design patterns help you define interfaces by identifying their key elements and the kinds of data that get sent across an interface
>>Design patterns also specify relationships between interfaces

>Specifying object implementations:
>>An object's implementation is defined by its class. The class specifies the object's internal data and representation and defines the operations the object can perform.
>>A mixin class is a class that's intended to provide an optional interface or functionality to other classes. It's similar to an abstract class in that it's not intended to be instantiated. Mixin classes require multiple inheritance

It's important to understand the difference between an object's class and its type.

An object's class defines how the object is implemented. The class defines the object's internal state and the implementation of its operations. In contrast, an object's type only refers to its interface—the set of requests to which it can respond. An object can have many types, and objects of different classes can have the same type.


>>It's also important to understand the difference between class inheritance and interface inheritance (or subtyping). Class inheritance defines an object's implementation in terms of another object's implementation. In short, it'sa mechanism for code and representation sharing. In contrast, interface inheritance (or subtyping) describeswhen an object can be used in place of another.
+Many of the design patterns depend on this distinction



Class inheritance is basically just a mechanism for extending an application's functionality by reusing functionality in parent classes. It lets you define a new kind of object rapidly in terms of an old one. It lets you get new implementations almost for free, inheriting most of what you need from existing classes.

However, implementation reuse is only half the story. Inheritance's ability to define families of objects with identical interfaces (usually by inheriting from an abstract class) is also important. Why? Because polymorphism depends on it.

principle of reusable object-oriented design:

Program to an interface, not an implementation


Don't declare variables to be instances of particular concrete classes. Instead, commit only to an interface defined by an abstract class. You will find this to be a common theme of the design patterns in this book.

> Putting Reuse Mechanisms to Work
TBA...


Design Patterns - Elements of Reusable Object-Oriented Software - Gof Design Patterns - Elements of Reusable Object-Oriented Software [English] Design Patterns 英文版 带书签 解压密码:123456 立即下载

相关推荐

设计模式:可复用面向对象软件的基础(中文)Design Patterns:Elements of Reusable Object-Oriented software

设计模式:可复用面向对象软件的基础(中文)Design Patterns:Elements of Reusable Object-Oriented software

Design Patterns - Elements of Reusable Object-Oriented Software

《Design Patterns - Elements of Reusable Object-Oriented Software》 中文译名:设计模式 - 可复用的面向对象软件元素

u012060443的博客 1882

Design Patterns-Elements of Reusable Object-Oriented Software 无水印pdf

Design Patterns-Elements of Reusable Object-Oriented Software 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

【Fluent Python】第六章 使用一等函数实现设计模式 Design Patterns with First-Class Functions

rethink the Strategy, Command, Template Method, and Visitor patterns. General idea: you can replace instances of some participant class in these patterns with simple functions, reducing a lot of boilerplate code. Case Study: Refactoring Strategy Strategy i

apple_50678962的博客 247

百度地图街景图像批量获取

由于个人研究需要在最近试了一下使用API获取百度地图街景图片,在此介绍一下基于我个人需求的百度街景批量获取方法,本文以Python编码作为主要方法,如果对零编码工具有需要的可以关注一下UA城市分析小组刚刚发布的街景图片获取工具。 街景图像用作区域细粒度空间指标测度需要解决几个问题。 1. 首先就是调用额度的限制,现在百度对于个人认证开发者每天可用的街景图像调用额度为100张,在不考虑购买额度上限(1万张600元,其实有经费的前提下可以直接考虑钞能力)的情况下动辄几千上万张的爬取数量会大大增加需要爬取的时间周

boycetoon29的博客 1万+

PV-RCNN实战:如何在KITTI数据集上实现3D目标检测(附完整代码解析)

本文提供了在KITTI数据集上实战PV-RCNN 3D目标检测的完整指南,涵盖环境配置、数据预处理、模型训练与评估全流程。通过详细的代码解析和调参技巧,帮助读者掌握这一融合点与体素优势的经典3D目标检测模型,并实现从理论到实践的跨越。

weixin_29098391的博客 406

Design Patterns - Elements of Reusable Object-Oriented Software 设计模式-可复用的面向对象软件元素。【笔记】

设计模式一共有23种,分为三大类:创建型模式(Creational Patterns),结构型模式(Structural Patterns),行为型模式(Behavioral Patterns)。还有另一类设计模式:J2EE设计模式。1.创建型模式:提供了一种在创建对象的同时隐藏创建逻辑的方式,而不是直接使用new直接实例化对象。使得程序在判断针对某个给定实例需要创建哪些对象时更加的灵活。工厂模式...

janny_flower的博客 2105

H3C交换机Console口连接全攻略:从接线到PuTTY配置(附常见问题排查)

本文详细介绍了H3C交换机Console口的连接与配置方法,包括硬件线缆选择、驱动安装、PuTTY参数设置及常见问题排查。特别针对Console转USB线缆的兼容性和驱动安装难点提供实用建议,帮助网络工程师快速掌握串联调试技巧,解决连接中的黑屏、乱码等典型问题。

weixin_42549451的博客 689

设计模式学习笔记(一)

我们举个手机厂的例子:用户需要手机产品时,直接提供手机产品名称给工厂,由手机工厂完成根据提供的信息决定提供哪个具体产品,即使用哪个具体产品的实现对产品进行实例化。@Overridedefault:HuaWei手机工厂根据传入的产品类型名确定具体生产Mate60、Mate60Pro还是Mate60RS。从上面的新建对象方式变成下面的方式工厂模式下,当新产品发布时,用户不需要新增getNewPhone方法,而是由工厂方法对产品扩展进行适配。

CuteFruit的博客 908

从X86到ARM:将VINS-Fusion-GPU和ego-planner迁移到Jetson Orin-NX时,我踩过的那些‘环境差异’坑

本文详细介绍了将VINS-Fusion-GPU和ego-planner从X86平台迁移到Jetson Orin-NX(ARM架构)时遇到的环境差异问题及解决方案。内容涵盖ARM与X86的架构差异、依赖管理、性能调优和硬件接口适配,特别强调了CUDA在ARM平台上的优化配置和内存访问技巧,帮助开发者高效完成跨平台迁移。

weixin_42647395的博客 123

三种 绘制奈奎斯特曲线 的方法

如何绘制Nyquist曲线 提供三种绘制方法,其中使用最广泛的是概略图绘制方法 ①解析法绘制 ②概略图法绘制 ③MATLAB绘制

weixin_46664967的博客 6万+

Java设计模式概述

设计模式(Design pattern)代表了最佳的实践,通常被有经验的面向对象的软件开发人员所采用。设计模式是软件开发人员在软件开发过程中面临的一般问题的解决方案。这些解决方案是众多软件开发人员经过相当长的一段时间的试验和错误总结出来的。设计模式是一套被反复使用的、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了重用代码、让代码更容易被他人理解、保证代码可靠性。

u013115157的博客 1282

单细胞分析R包monocle3服务器安装教程

由于centos7系统yum只能安装到低版本gdal,而monocle3依赖包需要 gdal>2 版本,从gdal官网下载2.4.4版本编译安装。monocle3的安装是通过cole-trapnell-lab安装的,该包挂在github上,需要通过github先安装leidenbase包,需要提前安装devtools包下载工具。接着利用BiocManager安装相应的依赖包,由于这些包的特殊性,所以不要切换到国内Bio_Mirror镜像,否则会找不到,如果一次不成功,缺啥补啥即可。运行 ldconfig。

qq_36608036的博客 1万+

设计模式的两个原则——《C# Design Patterns》笔记(一)

  从学校图书馆借了《C# Design Patterns: A Tutorial》(影印版)这本书,花些时间看看,顺便把一些读书笔记写在这里。虽然有人说该书不怎么样(看了一部分,的确书中的错误不少,而且明显地带有Java的色彩,似乎没有把C#语言的特点发挥出来。不知道作者有没兴趣出第二版?呵呵),但我也未曾系统地学习过设计模式,刚好借我感兴趣的语言C#和这本书初探这里面可复用编程的思想。   ...

weixin_33877885的博客 147

面经-2023-联发科MTK-数字芯片设计

面经-2023-联发科MTK-数字芯片设计

w0shishabi的博客 2946

RK3399外设驱动之MIPI

RK3399外设驱动之MIPI 文章目录RK3399外设驱动之MIPIMIPI命令解析入口代码mipi显示配置实例rk3399mipi驱动rk mipi驱动注册过程rk32_mipi_dsi.c解析 内核版本 Linux4.4 平台 rk3399 作者 nineyole MIPI命令解析入口代码 MIPI的入口代码如下:kernel\drivers\video\rockchip\screen\lcd_mipi.c static int __init rk_mipi_screen_in

学无止境 2233

《Head First设计模式》读书笔记 —— 工厂

简单工厂其实不是一个设计模式,反而是比较像一种编程习惯。#HeadFirst设计模式4-工厂方法模式工厂方法模式定义了一个创建对象的接口,但由子类决定要实例化的类是哪一个。工厂方法让类把实例化推迟到子类。工厂方法模式能够封装具体类型的实例化。“工厂方法”:抽象的Creator提供了一个创建对象的方法的接口,称为工厂方法理解“工厂方法让子类决定要实例化的类”此处的“决定”并不是指模式允许子类本身在运行时决定。

May21_F的博客 2396

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

《设计模式Design Pattern》读书笔记之十八

《设计模式Design Pattern》读书笔记之十八State模式结构 目的当一个对象(context)根据当前本身的状态(state),会产生不同的行为的时候,可以采用state模式。把所有跟改状态相关的行为/动作转移到一个外部的state对象中。这样,可以避免context内部大量的switch.if等判断。 优缺点带来更大的灵活性和可维护性,因为一个新的状态可以很容易地通过派生一个类来追加

Jadyleung的专栏 1641

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

《设计模式Design Pattern》读书笔记之十七

《设计模式Design Pattern》读书笔记之十七Observer模式结构 目的在一个一对多(one-to-many)的关系中,当一个对象(one)的状态被更新的时候,它的所有的相关对象(many)都会被得到通知。 讨论1,  可能会带来很大的状态更新成本,subject的一个很小的状态更新都可能使得大量的observer进行相应的更新。更为严重的是,如果subject不提供是什么状态被更新了

Jadyleung的专栏 1453

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

JavaScript设计模式读书笔记(一)=> 创建型设计模式

简单工厂模式 为了尽量减少地创建全局变量,同一类对象在不同需求中的重复性使用。通过对简单工厂来创建一些对象,可以让这些对象共用一些资源而又私有一些资源。对于简单工厂模式来说,它的使用场合通常也就限制在创建单一对象。 // e.g. function createPop(type, text) { const o = {}; o.content = text; o.show = func...

翾的博客 894

《设计模式Design Pattern》读书笔记之十六

《设计模式Design Pattern》读书笔记之十六Memento模式结构 目的为了可以把一个对象恢复到以前的状态,却不想公开内部状态使得封装性被破坏。 优点1,  通过把originator的内部状态保存到memento,而不是直接把内部状态公开,保持了originator的封装性。因为memento有两种接口,宽(wide)的接口只会被originator使用,使得别人不能访问这些内部状态。

Jadyleung的专栏 1388

《Head First设计模式》读书笔记 —— 命令模式

HeadFirst设计模式7-命令模式命令模式将“请求”封装成对象,以便使用不同的请求、队列或者日志来参数化其他对象。命令模式也支持可撤销的操作。一个命令对象通过在特定接收者上绑定一组动作来封装一个请求命令对象将动作和接收者包进对象中。这个对象只暴露出一个execute()方法,当此方法被调用时,接收者会进行这些动作,从外面看,其他对象不知道接收者做了哪些具体动作,只知道调用execute()就能达成目标Q:接收者一定有必要存在吗?为何命令对象不直接实现execute()方法的细节?

May21_F的博客 1056

《设计模式Design Pattern》读书笔记之一

     《设计模式Design Pattern》读书笔记之一      本书所使用到的符号(Guide To Notation) 《Design Pattern》这本书虽然有时候也使用一些非正式的图来表明自己的思想,但在设计模式中表示类/对象之间的关系时,使用规范的图。可能我的书版本比较老一些的缘故?它使用的图并不是基于UML,而是基于UML的前身。类图(class diagram)、对象图(o

Jadyleung的专栏 1926

JavaScript设计模式读书笔记(四)=> 技巧型设计模式

javascript设计模式读书笔记 1. 节流模式 这个单独找了搞了篇文章 https://blog.csdn.net/c_kite/article/details/90446725 2. 惰性模式 减少每次代码执行时的重复性的分支判断,通过对象的重定义来屏蔽原对象中的分支判断。下面来个浏览器的事件绑定兼容问题例子: ...

翾的博客 988

《设计模式Design Pattern》读书笔记之九

《设计模式Design Pattern》读书笔记之九Decorator模式结构 目的动态地给一个对象增加功能(responsibilities)。 讨论1, 给一个对象增加功能,最简单的方法是派生一个类;但这是一种静态的方法,不灵活。而Decorator是一种动态的方法,比较灵活。2, 对于一个轻量型的component,Decorator模式是一种比较好的方法,但如果component是重量型的

Jadyleung的专栏 1342
上一篇: forbes八月底对Andrew Ng的采访(zz)
下一篇: python自学笔记
vingstar
博客等级 码龄17年 35粉丝 68原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值