![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
是启山啊
博采众长,自成一派
展开
-
设计模式中英文汇总分类
《设计模式中英文汇总分类》23种设计模式(包含但是不限于)可以分为三类:创建型、结构型、行为型。1、 AbstractFactoryProvide an interface for creating families of related or dependent object without specifying their concrete classes.中文...原创 2017-06-21 00:46:26 · 1281 阅读 · 0 评论 -
策略模式
策略模式定义Define a family of algorithms, encapsulate each one, and make them interchangeable.定义一组算法,并将算法封装起来,并且使他们之间可以互换;分析策略模式的核心是定义算法、封装算法并且让它们可以相互替换;相互替换的实现自然要通过继承或者实现相同接口来实现,这样他们在满足里氏替换原则的前提下...原创 2019-02-12 12:11:32 · 249 阅读 · 2 评论 -
解释器模式
解释器模式定义Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.给定一门语言,定义它的文法的一种表示,并定一个解释器,该解释器使用该表示来解...原创 2019-02-13 23:21:47 · 154 阅读 · 0 评论 -
享元模式
享元模式定义Use sharing to support large numbers of fine-grained objects efficiently.使用共享对象可有效支持大量的细粒度的对象;分析享元模式是池技术的重要实现方式。主要用于解决内存泄漏、对象数量爆炸等问题。共享对象以及细粒度对象是享元模式的关键。也就是将可以共享的信息抽取为共享对象,细粒度对象即为精确的、可共享的对...原创 2019-02-13 23:25:46 · 323 阅读 · 0 评论 -
桥梁模式
桥梁模式定义Decouple an abstraction from its implementation so that the two can vary independently.将抽象和实现解耦,使得两者可以独立地变化;分析桥梁模式是一个指导如何设计类依赖关系的模式。A依赖B,为了让A和B都拥有可扩展性,A不应该依赖B的实现,而应该依赖B的抽象,也就是基于接口或者抽象类;A依赖B...原创 2019-02-13 23:39:17 · 360 阅读 · 0 评论 -
访问者模式
访问者模式定义Represent an operation to be performed on the elements of of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates;封装...原创 2019-02-13 23:44:55 · 204 阅读 · 0 评论 -
状态模式
状态模式定义Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.当一个对象内在状态改变时,允许其改变行为,这个对象看起来像改变了所属类。分析状态模式是一个很好用的模式。很明显,不同状态下行为是有所不同的。我们往往需...原创 2019-02-13 23:47:01 · 138 阅读 · 0 评论 -
观察者模式
观察者模式定义Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.定义对象间一种一对多的依赖关系,使得每当一个对象改变状态,则所有依赖它的对象都会得到通知并...原创 2019-02-13 23:49:57 · 166 阅读 · 0 评论 -
备忘录模式
备忘录模式定义Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restored to this state later.在不破坏分装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态。这样就可以将该对象恢复到原...原创 2019-02-13 23:52:26 · 817 阅读 · 0 评论 -
迭代器模式
迭代器模式定义Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.它提供一种访问容器对象中各个元素而又不暴露该对象内部细节的方法;分析迭代器模式是一种数据访问方法,同组合模式属于同一类别。迭代器模式是...原创 2019-02-13 23:55:16 · 369 阅读 · 0 评论 -
门面模式
门面模式定义Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.要求一个子系统的外部与其内部的通信必须通过一个统一的对象进行。门面模式提供一个高层次的接口...原创 2019-02-13 23:56:46 · 565 阅读 · 0 评论 -
组合模式
组合模式定义Compose objects into tree structures to represent part-whole hierarchies. Composite let client treat individual objects and compositions of objects uniformly.将对象组合成树形结构以表示“部分-整体”的层次结构,使得用户对于单...原创 2019-02-13 23:58:21 · 424 阅读 · 0 评论 -
装饰者模式
装饰者模式定义 Attach additional responsibilities to an object dynamically keeping the same interface. Decorators provide a flexible alternative to subclass for extending functionality. 通过保持相同的接口动态地给对象添...原创 2018-03-05 15:34:34 · 208 阅读 · 0 评论 -
责任链模式
责任链模式定义Avoid coupling the sender of request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until a...原创 2018-03-05 14:25:07 · 202 阅读 · 0 评论 -
命令模式
命令模式定义Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations;将一个请求封装为独享,从而让你使用不同的请求把客户端参数化,...原创 2018-03-01 23:33:51 · 184 阅读 · 0 评论 -
面向对象程序6大设计原则
一、单一职责原则内容介绍SRP,Single Responsibility Principle,中文翻译为“单一职责原则。一个类应该有且仅有一个职责。一个类变化的原因应该不多于一个。 我的理解要实现单一职责原则:首先要了解“职责”。所谓职责,面向对象大师Robert. C. Martin有一个著名的定义:所谓一个类的职责就是引起该类变化的原因。如果一个类有...原创 2017-05-11 18:25:26 · 637 阅读 · 0 评论 -
面向对象之类间的关系
关联:两个类之间有联系,但是这种联系很轻,不是很直接;依赖:依赖是比关联更强、更紧密的一种关系;组合与聚合都是一种“整体与部分”的关系:原创 2017-05-08 09:08:53 · 438 阅读 · 0 评论 -
面向对象基本理论及三大特征
类是一组相似事物的统称;对象是类的一个实体;接口:一组相关的交互功能点定义的集合;封装的核心目的是:拥抱变化。唯一不变的只有变化本身。通过封装,将变化所带来的影响控制到最小;继承描述了类和类之间的关系;抽象类定义了子类必须遵守的一种规范;多态:多种形态;原创 2017-05-06 07:57:50 · 723 阅读 · 0 评论 -
单例模式
单例模式1. 定义:Ensure a class has only one instance, and provide a global point of access to it(确保一个类只有一个实例,并且提供一个全局访问点以访问到它);2. 分析:通过减少类实例的数量,减少内存开支,提高系统性能,当然,前提是整个系统有这一个实例便可完成相应的工作。(可以只有...原创 2018-02-26 23:04:24 · 180 阅读 · 0 评论 -
工厂方法模式
工厂方法模式1. 定义Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclasses (工厂方法定义了创建对象的接口,但是让...原创 2018-02-26 23:52:38 · 168 阅读 · 0 评论 -
抽象工厂模式
抽象工厂模式1. 定义:Provide an interface for creating families of related or dependent objects without specifying their concrete classes(为创建一组相关的或者相互依赖的对象提供一个接口,无需指定它们的具体类);2. 分析:抽象工厂模式也是一个创...原创 2018-02-27 00:00:42 · 242 阅读 · 0 评论 -
模板方法模式
模板方法模式定义Define the skeleton of an algorithm in an operation, deferring some steps to subclass. Template Method lets subclasses redefine certain steps of an algorithm without change the algorithm’...原创 2018-02-27 12:03:01 · 181 阅读 · 0 评论 -
构造者模式
构造者模式定义Separate the construction of a complex object from its representation so that the same construction construction process can create different representations.将一个复杂对象的创建过程从它的表示分离,使得同样的构建过...原创 2018-02-27 23:35:19 · 230 阅读 · 0 评论 -
代理模式
代理模式定义Provide a surrogate or placeholder for another object to control access to it;提供一种代理以控制对这个对象的访问;分析代理模式实现了对功能对象的封装,在不影响调用者环境的前提下对功能对象发挥作用的环境进行改变以实现某种目的;同时它职责清晰,真实的角色就负责完成实际的任务,而与它相关(但...原创 2018-02-28 12:02:18 · 210 阅读 · 0 评论 -
原型模式
原型模式定义Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype;用原型实例制定创建对象的种类,通过拷贝这些原型创建新的对象;分析原型模式理解起来比较容易,由于原型模式是直接拷贝内存中的二进制流,...原创 2018-03-01 00:17:07 · 197 阅读 · 0 评论 -
中介者模式
中介者模式定义Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their in...原创 2018-03-01 15:51:24 · 247 阅读 · 0 评论 -
适配器模式
适配器模式定义Convert the interface of a class into another interface client expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.将一个类的接口变成客户端所期待的另一种接口,从而使...原创 2019-02-14 00:00:12 · 307 阅读 · 0 评论