
设计模式
文章平均质量分 73
寻梦的飞鱼
爱技术,爱生活
业精于勤,荒于嬉;行成于思,毁于随;
展开
-
六大设计原则
文档地址:《设计模式之禅》第1章 单一职责原则( Single Responsibility Principle,SRP) 定义: There should never be more than one reason for a class to change. 应该有且仅有一个原因引起类的变更; 好处: ● ...原创 2018-07-30 17:27:03 · 147 阅读 · 0 评论 -
迭代器模式 (Iterator Pattern)
文档地址:《设计模式之禅》切入故事: 整理项目信息——苦差事定义: Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.(它提供一种方法访问一个容器对象中各个元素, 而又不需暴露该对象的内部...原创 2018-10-09 15:45:41 · 116 阅读 · 0 评论 -
组合模式( Composite Pattern)
文档地址:《设计模式之禅》切入故事: 公司的人事架构是这样的吗定义: Compose objects into tree structures to represent part-whole hierarchies.Composite lets clients treat individual objects and compositions of objects uniformly.(将...原创 2018-10-10 15:07:27 · 157 阅读 · 0 评论 -
观察者模式( Observer Pattern)
文档地址:《设计模式之禅》切入故事: 韩非子身边的卧底是谁派来的定义: Define a one-to-many dependency between objects so that when one object changes state,all its dependents are notified and updated automatically.(定义对象间一种一...原创 2018-10-10 15:16:52 · 143 阅读 · 0 评论 -
门面模式 (Facade Pattern)
文档地址:《设计模式之禅》切入故事:我要投递信件定义: 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.(要求一个子系统的外部与其内部的...原创 2018-10-10 15:19:56 · 202 阅读 · 0 评论 -
备忘录模式 (Memento Pattern)
文档地址:《设计模式之禅》 切入故事: 如此追女孩子, 你还不乐 定义: Without violating encapsulation,capture and externalize an object's internal state so that the object can be restored to this stat...原创 2018-10-10 15:20:52 · 137 阅读 · 0 评论 -
访问者模式 (Visitor Pattern)
文档地址:《设计模式之禅》 切入故事: 员工的隐私何在 定义: Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without chan...原创 2018-10-10 15:22:15 · 484 阅读 · 0 评论 -
状态模式
文档地址:《设计模式之禅》 切入故事: 城市的纵向发展功臣——电梯 定义: Allow an object to alter its behavior when its internal state changes.The object will appear to change its class.(当一个对象内在状态改变时允许其...原创 2018-10-10 15:23:18 · 174 阅读 · 0 评论 -
解释器模式 (Interpreter Pattern)
文档地址:《设计模式之禅》 切入故事: 四则运算你会吗 定义: Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences...原创 2018-10-10 15:24:49 · 232 阅读 · 0 评论 -
享元模式 (Flyweight Pattern)
文档地址:《设计模式之禅》 切入故事: 内存溢出, 司空见惯 定义: Use sharing to support large numbers of fine-grained objects efficiently.(使用共享对象可有效地支持大量的细粒度的对象。 ) 通用类图: ...原创 2018-10-10 15:26:56 · 252 阅读 · 0 评论 -
适配器模式( Adapter Pattern)
文档地址:《设计模式之禅》切入故事: 业务发展——上帝才能控制定义: Convert the interface of a class into another interface clients expect.Adapter lets classes work together that couldn't otherwise because of incompatible ...原创 2018-10-09 15:44:38 · 129 阅读 · 0 评论 -
策略模式( Strategy Pattern) 也叫做政策模式(Policy Pattern)
文档地址:《设计模式之禅》定义: Define a family of algorithms,encapsulate each one,and make them interchangeable.(定义一组算法, 将每个算法都封装起来, 并且使它们之间可以互换。 )通用类图: ● Context封装角色...原创 2018-10-09 15:43:03 · 1180 阅读 · 0 评论 -
单例模式
文档地址:《设计模式之禅》第七章:单例模式( Singleton Pattern) 切入故事:唯一的皇帝 定义: Ensure a class has only one instance, and provide a global point of access to it.(确保某一个类只有一个实例, 而且自行实例化并向整个系统提供这个实例。...原创 2018-07-30 17:33:11 · 160 阅读 · 0 评论 -
工厂模式
文档地址:《设计模式之禅》第八章:工厂模式(Factory Pattern) 切入故事:女娲造人的故事 定义: Define an interface for creating an object,but let subclasses decide which class to instantiate.Factory Method lets a class d...原创 2018-07-30 17:40:48 · 107 阅读 · 0 评论 -
模板方法模式
文档地址:《设计模式之禅》第10章:模板方法模式( Template Method Pattern) 切入故事:辉煌工程——制造悍马 定义: Define the skeleton of an algorithm in an operation,deferring some steps to subclasses.Template Method lets subc...原创 2018-07-30 17:47:14 · 135 阅读 · 0 评论 -
建造者模式( Builder Pattern)
文档地址:《设计模式之禅》 切入故事:变化是永恒的 定义: Separate the construction of a complex object from its representation so that the sameconstruction process can create different representations.(将一个复杂对象的构建与它的表...原创 2018-10-09 15:10:57 · 108 阅读 · 0 评论 -
代理模式( Proxy Pattern)
文档地址:《设计模式之禅》切入故事: 我是游戏至尊定义: Provide a surrogate or placeholder for another object to control access to it.(为其他对象提供一种代理以控制对这个对象的访问。 )通用类图: ● Subject抽象主题角色 ...原创 2018-10-09 15:15:02 · 108 阅读 · 0 评论 -
原型模式(Prototype Pattern)
文档地址:《设计模式之禅》切入故事: 个性化电子账单定义: Specify the kinds of objects to create using a prototypical instance,and create new objects by copying this prototype.(用原型实例指定创建对象的种类, 并且通过拷贝这些原型创建新的对象。 )通用类...原创 2018-10-09 15:18:43 · 191 阅读 · 0 评论 -
中介模式
文档地址:《设计模式之禅》切入故事: 进销存管理是这个样子的吗?定义: Define an object that encapsulates how a set of objects interact.Mediator promotes loose coupling by keeping objects from referring to each other explici...原创 2018-10-09 15:29:28 · 150 阅读 · 0 评论 -
命令模式
文档地址:《设计模式之禅》切入故事: 项目经理也难当定义: Encapsulate a request as an object,thereby letting you parameterize clients with different requests,queue or log requests,and support undoable operations.(将一个请...原创 2018-10-09 15:31:12 · 207 阅读 · 1 评论 -
责任链模式
文档地址:《设计模式之禅》切入故事: 古代妇女的枷锁——“三从四德”定义: Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request.Chain the receiving objects and pass the ...原创 2018-10-09 15:33:34 · 386 阅读 · 0 评论 -
装饰模式(Decorator Pattern)
文档地址:《设计模式之禅》切入故事: 罪恶的成绩单定义: Attach additional responsibilities to an object dynamically keeping the same interface.Decorators provide a flexible alternative to subclassing for extending fu...原创 2018-10-09 15:40:58 · 155 阅读 · 0 评论 -
桥梁模式( Bridge Pattern)
文档地址:《设计模式之禅》 切入故事: 我有一个梦想…… 定义: Decouple an abstraction from its implementation so that the two can vary independently.(将抽象和实现解耦, 使得两者可以独立地变化。 ) 通用类图: ...原创 2018-10-10 15:28:32 · 441 阅读 · 0 评论