设计模式gof

Gangs of Four Design Patterns is the collection of 23 design patterns from the book “Design Patterns: Elements of Reusable Object-Oriented Software”.

四种设计模式的帮派是《设计模式:可重用的面向对象软件的元素》一书中的23种设计模式的集合。

Gangs Of Four Design Patterns Book

四个设计模式书的帮派

This book was first published in 1994 and it’s one of the most popular books to learn design patterns. The book was authored by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. It got nicknamed as Gangs of Four design patterns because of four authors. Furthermore, it got a shorter name as “GoF Design Patterns”.

这本书于1994年首次出版,是学习设计模式的最受欢迎的书籍之一。 该书由Erich Gamma,Richard Helm,Ralph Johnson和John Vlissides撰写。 由于四位作者,它被昵称为“四个设计模式的帮派”。 此外,它的简称为“ GoF设计模式”。

GoF设计模式类型 (GoF Design Pattern Types)

GoF Design Patterns are divided into three categories:

GoF设计模式分为三类:

  1. Creational: The design patterns that deal with the creation of an object.Creational :涉及对象创建的设计模式。
  2. Structural: The design patterns in this category deals with the class structure such as Inheritance and Composition.结构 :此类别中的设计模式涉及类结构,例如继承和组成。
  3. Behavioral: This type of design patterns provide solution for the better interaction between objects, how to provide lose coupling, and flexibility to extend easily in future.行为的 :这种类型的设计模式提供了解决方案,以实现对象之间更好的交互,如何提供丢失耦合以及将来轻松扩展的灵活性。

创新设计模式 (Creational Design Patterns)

There are 5 design patterns in the creational design patterns category.

创新设计模式类别中有5个设计模式。

Pattern Name Description
Singleton The singleton pattern restricts the initialization of a class to ensure that only one instance of the class can be created.
Factory The factory pattern takes out the responsibility of instantiating a object from the class to a Factory class.
Abstract Factory Allows us to create a Factory for factory classes.
Builder Creating an object step by step and a method to finally get the object instance.
Prototype Creating a new object instance from another similar instance and then modify according to our requirements.
模式名称 描述
辛格尔顿 单例模式限制了类的初始化,以确保只能创建该类的一个实例。
工厂模式承担了从类到工厂类实例化对象的责任。
抽象工厂 允许我们为工厂类创建工厂。
建造者 逐步创建对象以及最终获取对象实例的方法。
原型 从另一个类似的实例创建一个新的对象实例,然后根据我们的要求进行修改。

结构设计模式 (Structural Design Patterns)

There are 7 structural design patterns defined in the Gangs of Four design patterns book.

《四大帮派设计模式》一书中定义了7种结构设计模式。

Pattern Name Description
Adapter Provides an interface between two unrelated entities so that they can work together.
Composite Used when we have to implement a part-whole hierarchy. For example, a diagram made of other pieces such as circle, square, triangle, etc.
Proxy Provide a surrogate or placeholder for another object to control access to it.
Flyweight Caching and reusing object instances, used with immutable objects. For example, string pool.
Facade Creating a wrapper interfaces on top of existing interfaces to help client applications.
Bridge The bridge design pattern is used to decouple the interfaces from implementation and hiding the implementation details from the client program.
Decorator The decorator design pattern is used to modify the functionality of an object at runtime.
模式名称 描述
适配器 在两个不相关的实体之间提供接口,以便它们可以一起工作。
综合 在我们必须实现部分整体层次结构时使用。 例如,由其他零件(例如圆形,正方形,三角形等)制成的图表。
代理 为另一个对象提供代理或占位符,以控制对其的访问。
飞行重量 缓存和重用与不可变对象一起使用的对象实例。 例如,字符串池。
正面 在现有接口之上创建包装器接口以帮助客户端应用程序。
桥接设计模式用于将接口与实现分离,并从客户端程序隐藏实现细节。
装饰器 装饰器设计模式用于在运行时修改对象的功能。

行为设计模式 (Behavioral Design Patterns)

There are 11 behavioral design patterns defined in the GoF design patterns.

GoF设计模式中定义了11种行为设计模式。

Pattern Name Description
Template Method used to create a template method stub and defer some of the steps of implementation to the subclasses.
Mediator used to provide a centralized communication medium between different objects in a system.
Chain of Responsibility used to achieve loose coupling in software design where a request from the client is passed to a chain of objects to process them.
Observer useful when you are interested in the state of an object and want to get notified whenever there is any change.
Strategy Strategy pattern is used when we have multiple algorithm for a specific task and client decides the actual implementation to be used at runtime.
Command Command Pattern is used to implement lose coupling in a request-response model.
State State design pattern is used when an Object change it’s behavior based on it’s internal state.
Visitor Visitor pattern is used when we have to perform an operation on a group of similar kind of Objects.
Interpreter defines a grammatical representation for a language and provides an interpreter to deal with this grammar.
Iterator used to provide a standard way to traverse through a group of Objects.
Memento The memento design pattern is used when we want to save the state of an object so that we can restore later on.
模式名称 描述
模板方法 用于创建模板方法存根并将某些实现步骤推迟到子类。
调解员 用于在系统中不同对象之间提供集中式通信介质。
责任链 用于实现软件设计中的松散耦合,其中将来自客户端的请求传递给对象链以对其进行处理。
观察者 当您对对象的状态感兴趣并希望在发生任何更改时得到通知时,此功能很有用。
战略 当我们对一个特定的任务有多种算法并且客户决定在运行时使用的实际实现时,将使用策略模式。
命令 命令模式用于在请求-响应模型中实现丢失耦合。
当对象根据其内部状态更改其行为时,将使用状态设计模式。
游客 当我们必须对一组相似类型的对象执行操作时,将使用访问者模式。
口译员 定义一种语言的语法表示形式,并提供解释器来处理这种语法。
迭代器 用于提供遍历一组对象的标准方法。
纪念 当我们要保存对象的状态以便以后可以恢复时,将使用memento设计模式。

结论 (Conclusion)

Gangs of Four design patterns lay the foundation of core design patterns in programming. There are many other design patterns built on top of these patterns for specific requirements.

四个设计模式的帮派奠定了编程中核心设计模式的基础。 在这些模式之上还有许多其他设计模式可以满足特定需求。

翻译自: https://www.journaldev.com/31902/gangs-of-four-gof-design-patterns

设计模式gof

设计模式gof_四个(GoF)设计模式的帮派相关推荐

  1. Java设计模式(十四):MVC设计模式

    1. 应用场景 MVC设计模式广泛应用于桌面应用程序开发和网页页面开发这些与用户交互的应用场景中. 2.概念 众所周知MVC不是设计模式,是一个比设计模式更大一点的模式,称作设计模式不合理,应该说MV ...

  2. 设计模式(四)Builder设计模式

    文章目录 1.定义以及UML建模图: 2.使用场景: 3.核心类 (1) 抽象产品类 computer (2) Builder 抽象Builder,规范产品的组建,一般是由子类实现具体的组建过程. ( ...

  3. (转):GOF设计模式趣解(23种设计模式)

    GOF设计模式趣解(23种设计模式) 创建型模式 1.FACTORY--追MM少不了请吃饭了,麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西,虽然口味有所不同,但不管你带MM去麦当劳或肯德基,只管向服务 ...

  4. 总结:GoF设计模式及应用

    2019独角兽企业重金招聘Python工程师标准>>> GoF设计模式 Christopher Alexander 说过:"每一个模式描述了一个在我们周围不断重复发生的问题 ...

  5. 23种GoF设计模式的分类

    GoF设计模式一共有23个.一般可以按目的和作用范围来进行划分,具体划分方法如下: 第一,这些模式按目的(即完成什么样任务)来划分为创建型.结构型和行为型这三种模式: 创建型:用来创建对象.单例.原型 ...

  6. GOF设计模式学习--辨析各种模式的要点和相似模式之间的区别

    --辨析各种模式的要点和相似模式之间的区别 http://blog.csdn.net/wind19/article/details/6968149 1                    正文之前 ...

  7. JavaScript设计模式系列四之外观模式(附案例源码)

    文章初衷 设计模式其实旨在解决语言本身存在的缺陷, 目前javaScript一些新的语法特性已经集成了一些设计模式的实现, 大家在写代码的时候,没必要为了用设计模式而去用设计模式, 那么我这边为什么还 ...

  8. sql中如何统计各种零件的总数量_如何应用GOF设计模式中的构建者模式创建复合对象实例...

    软件项目实训及课程设计指导--如何应用GOF设计模式中的构建者模式创建复合对象实例 1.GOF设计模式中的构建者模式 构建者设计模式能够将一个复杂对象(它一般为组合类)的构建过程与它的表示部件相互分离 ...

  9. 设计模式(四)--代理模式

    设计模式(四)–代理模式 文章目录 设计模式(四)--代理模式 其他链接 代理模式 1.简介 2.静态代理 角色 代码实现 好处 3.动态代理 代码实现 解析 其他链接 JVM学习笔记(一) JVM学 ...

最新文章

  1. 深入理解java虚拟机---读后笔记(垃圾回收)
  2. django创建一个管理员用户
  3. latex插入表格_如何将word表格变成LaTeX代码?
  4. boost::filesystem模块打印文件状态的测试程序
  5. Tensorflow2.0 tf.function和AutoGraph模式
  6. 怎么配置java ee_如何配置Java EE Eclipse+Tomcat开发环境
  7. 某8086cpu构成的微型计算机,微型计算机原理及应用试题及答案
  8. 团队-手机备忘录-需求分析
  9. linux之安装模式的选择
  10. renren-fast:使用人人开源renren-fast报错Error:(11, 39) java: 程序包io.renren.datasource.annotation不存在
  11. PLSQL导入导出表结构及数据
  12. opencv实现银行卡号识别
  13. html背景图片显示不出,css中背景图片显示不出来
  14. recover 没有捕获异常_Golang学习笔记之错误处理error、panic (抛出错误),recover(捕获错误...
  15. 脑膜瘤论文阅读(一)
  16. js判断设备是ios还是安卓,以及微信端
  17. css 毛玻璃: backdrop-filter
  18. php开发工具PhpStorm新版本V2022.1 新增功能亮点介绍
  19. 打开Word提示:Office已阻止访问以下嵌入对象,以便保护你的安全解决方法
  20. camunda7、camunda8对比分析,哪个版本好

热门文章

  1. Linux命令之进程的管理
  2. css3圆形修边按钮
  3. 实现iOS长时间后台的两种方法:Audiosession和VOIP(转)
  4. [转载] Python进程——multiprocessing.Event()|Barrier()
  5. Unity 移动端的复制这么写
  6. centos6.5 conky安装配置
  7. SQL Server数据库导入导出数据方式比较
  8. c++ 课程设计之车票管理系统
  9. error: #error This file requires compiler and library support for the ISO C++ 2011 standard.
  10. 关于Linux SHELL 的编程的几个练习(课本182页5-10题)