Fork me on GitHub

随笔分类 -  设计模式

设计模式学习
摘要:中介者模式(Mediator)也称为调停者模式,用一个中介对象封装一系列对象(同事)的交互,中介者使各个对象不需要显示的相互作用,从而使其耦合松散,而且对象可以独立地改变它们之间的交互。 观察者(Observer Pattern)模式也称发布订阅者模式,定义对象间一对多的依赖关系,使得每当一个对象改 阅读全文
posted @ 2018-04-27 15:31 秋夜雨巷 阅读(236) 评论(0) 推荐(0)
摘要:定义 解释器模式(Interpreter Pattern)是一种按照规定语法对表达式进行解析的方案,在项目中较少使用。 英文:Given a language,define a representation for its grammer along with an interpreter that 阅读全文
posted @ 2018-04-27 15:19 秋夜雨巷 阅读(274) 评论(0) 推荐(0)
摘要:定义 状态模式(State Pattern)又称为状态对象模式,该模式允许一个对象在其内部状态改变的时候改变行为。 英文:Allow an object to alert its behavior when its internal state changes.The object will app 阅读全文
posted @ 2018-04-26 15:42 秋夜雨巷 阅读(219) 评论(0) 推荐(0)
摘要:定义 访问者(Visitor Pattern)的目的是封装一些施加于某种数据结构元素之上的操作,即使这些操作需要修改,接收这个操作的数据结构却可以保持不变。 英文原话:Represent an operation to be performed on the elements of an objec 阅读全文
posted @ 2018-04-26 11:46 秋夜雨巷 阅读(256) 评论(0) 推荐(0)
摘要:定义 备忘录模式(Memento Pattern)又称为快照(Snapshot)模式或Token模式。 英文原话:Without violating encapsulation,capture and externalize an object's internal state so that th 阅读全文
posted @ 2018-04-25 16:53 秋夜雨巷 阅读(236) 评论(0) 推荐(0)
摘要:定义 观察者(Observer Pattern)模式也称为发布订阅模式,它是一种在项目中经常使用的模式。 英文原话:Define a one-to-many dependency between objects so that when one object changes state,all it 阅读全文
posted @ 2018-04-25 11:21 秋夜雨巷 阅读(245) 评论(0) 推荐(0)
摘要:定义 中介者模式(Mediator)也称调停者模式,是一种比较简单的模式。 英文:Define an object that encapsulates how a set of objects interact.Mediator promotes loose coupling by keeping 阅读全文
posted @ 2018-04-24 14:40 秋夜雨巷 阅读(243) 评论(0) 推荐(0)
摘要:模板方法(Template Pattern)定义一个操作中的算法的框架,而将一些步骤延迟到子类中,使得子类可以不改变一个算法的结构即可重新定义该算法某些特定步骤。 命令模式(Command)是一种高内聚的模式,将一个请求封装成一个对象,从而使用不通的请求把客户端参数化,对于请求排队或者记录请求日志, 阅读全文
posted @ 2018-04-23 07:54 秋夜雨巷 阅读(248) 评论(0) 推荐(0)
摘要:定义 迭代器模式(Iterator Pattern)是使用率最高的几个模式之一,被广泛地应用到Java的API中。例如:Java的集合(Collection)框架中,就广泛使用迭代器来遍历集合中元素。 英文原话:Provide a way to access the elements of an a 阅读全文
posted @ 2018-04-23 07:48 秋夜雨巷 阅读(253) 评论(0) 推荐(0)
摘要:定义 策略模式(Strategy Pattern)也叫政策模式,是一种比较简单的模式。 英文原话:Define a family of algorithms,encapsulate each one,and make them interchangeable. 翻译:定义一组算法,将每个算法都封装起 阅读全文
posted @ 2018-04-20 15:00 秋夜雨巷 阅读(347) 评论(0) 推荐(0)
摘要:定义 责任链模式(Chain of Responsibility Pattern)是一种常见的行为模式。 责任链模式英文原话是:Avoid coupling the sender of a request to its receiver by giving more than one object 阅读全文
posted @ 2018-04-20 11:22 秋夜雨巷 阅读(12491) 评论(0) 推荐(2)
摘要:定义 命令模式(Command Pattern)又称为行动(Action)模式或者交易(Transaction)模式。 英文原话:Encapsulate a request as an object,thereby letting you parameterize clients with diff 阅读全文
posted @ 2018-04-19 11:39 秋夜雨巷 阅读(315) 评论(0) 推荐(0)
摘要:行为型模式(Behavioral Pattern)是对不同的对象之间划分责任和算法的抽象化。行为型模式包括11种模式:模板方法模式、命令模式、责任链模式、策略模式、迭代器模式、中介者模式、观察者模式、备忘录模式、访问者模式、状态模式、解释器模式。 定义 模板方法模式(Template Method 阅读全文
posted @ 2018-04-18 10:31 秋夜雨巷 阅读(226) 评论(0) 推荐(0)
摘要:结构型模式有代理模式、装饰模式、适配器模式、组合模式、桥梁模式、外观模式、享元模式,共七种结构型设计模式。 代理模式(Proxy):为其他队形提供一种代理以控制对该对象的访问。 装饰模式(Decorator):动态地给一个对象添加一些额外的职责。就增加功能来说,装饰模式比生成子类更灵活。 适配器模式 阅读全文
posted @ 2018-01-22 07:37 秋夜雨巷 阅读(215) 评论(0) 推荐(0)
摘要:定义 享元模式(Flyweight Pattern)是池技术的重要实现方式,它可以降低大量重复的、细粒度的类在内存中的开销。英文原话是:Use sharing to support large numbers of fine-grained objects efficiently.意思是:使用共享对 阅读全文
posted @ 2018-01-11 21:08 秋夜雨巷 阅读(263) 评论(0) 推荐(0)
摘要:定义 外观模式(Facade Pattern)也叫门面模式,是一种比较常用同时也非常简单的设计模式。英文原话是:Provide a unified interface to a set of interfaces in a subsystem.Facade defines a higher-leve 阅读全文
posted @ 2018-01-09 07:45 秋夜雨巷 阅读(245) 评论(0) 推荐(0)
摘要:定义 桥梁结构(Bridge Pattern)也称桥接模式,是一种简单但不常使用的设计模式。 英文原话是:Decouple an abstraction from its implementation so that the two can vary independently.意思是:将抽象和实现 阅读全文
posted @ 2017-12-13 22:39 秋夜雨巷 阅读(197) 评论(0) 推荐(0)
摘要:定义 组合(Composite Pattern)模式也叫合成模式,用来描述部分与整体的关系。英文原话是:Compose objects into tree structures to represent part-whole hierarchies.Composite lets clients tr 阅读全文
posted @ 2017-12-07 23:12 秋夜雨巷 阅读(224) 评论(0) 推荐(0)
摘要:定义 适配器模式(Adapter Pattern)又叫变压器模式。在适配器模式下,变压器的作用是把一种电压变换为另一种电压。 英文原话是:Convert the interface of a class into another interface clients expect.Adapter le 阅读全文
posted @ 2017-12-03 12:18 秋夜雨巷 阅读(210) 评论(0) 推荐(0)
摘要:定义 装饰模式的英文原话是:Attach additional responsibilities to an object dynamically keeping the same interface.Decorators provide a flexible alternative to subc 阅读全文
posted @ 2017-11-24 07:47 秋夜雨巷 阅读(211) 评论(0) 推荐(0)