
design patterns
zeroones-
放下手机,关掉直播。
展开
-
设计模式_备忘录模式
Mememento Pattern Without violating encapsulation,capture and externalize an object's internal state so that the object can be restored to this state later.(在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个原创 2015-07-25 14:35:01 · 867 阅读 · 0 评论 -
面向对象五大原则_5.迪米特原则
朋友类? 定义:出现在成员变量,方法输入输出参数中的类,而出现在方法内部的内部不称为朋友类。 类就是人,人就是类,换个角度,类是实例的接口。 人的关系有朋友,那么类也有朋友。所以我们称之为朋友类,朋友类的关系从耦合,组合,聚合,依赖等衍生出来。直接的朋友? 调用于你内部是什么样子,我一概不关心。 I.我只对你说Only talk to your i原创 2015-07-13 22:10:28 · 576 阅读 · 0 评论 -
设计模式_模板方法模式
Template Method Pattern Define the skeleton of an algorithm in an operation,defering some steps to subclasses.Template Method lets subclasses redefine certain steps of an algorithm without ch原创 2015-07-18 20:25:58 · 591 阅读 · 0 评论 -
设计模式_代理模式
代理 在客户端和目标对象之间起到中介的作用,并且可以通过代理对象去掉客户不能看到的内容和服务或者添加客户需要的额外服务例如structs2里面的拦截器,网络代理,翻墙等等。这里就不多叙述其他高级的代理模式了,学的很肤浅,没有实际应用到项目中去,这个暑假,只是拓宽一下眼界而已,让自己有个印象。普通代理(静态代理)public abstract class IGameP原创 2015-07-19 14:07:58 · 635 阅读 · 0 评论 -
设计模式_原型模式
Prototype Patttern specify the kinds of objects to create using a prototypical instance,and create new objects by coping this prototype.(用原型实例实例指定创建对象的种类,并且通过拷贝这个原型创建新的对象)实现Clonable接口,实现clone方原创 2015-07-20 09:55:46 · 755 阅读 · 0 评论 -
设计模式_装饰模式
Decorator Pattern Attach additional responsibilities to an object dynamically keeping the same interface. Decorators provide a flexible alternative to subclassing for extending functionality.原创 2015-07-20 17:55:34 · 602 阅读 · 0 评论 -
设计模式_命令模式
定义 Encapsulate a request as an object ,thereby letting you parameterize clients with different requests,queue or log requests,and support undoable operations.(将一个请求封装成一个对象,从而让你使用不同的请求把客户端参数化,对请求排原创 2015-07-20 11:42:23 · 665 阅读 · 0 评论 -
设计模式_责任链模式
定义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 request along the chain until an obj原创 2015-07-20 17:22:04 · 689 阅读 · 0 评论 -
设计模式_中介者模式
定义Define an object that encapsulates how a set of objects interact. Mediator promptes loose coupling by keeping objects from referring to each other explicitly,and it lets you vary their interact原创 2015-07-20 10:48:12 · 702 阅读 · 0 评论 -
设计模式_策略模式
Strategy Pattern Define a family of algorithms,encapsulate each one,and make them interchangeable.(定义一组算法,将每个算法都封装起来,并且使它们之间可以交换)Context : 上下文角色Strategy : 策略,算法家族的抽象,通常为接口ConcreteStra原创 2015-07-21 23:28:26 · 549 阅读 · 0 评论 -
设计模式_适配器模式
Adapter Pattern Converl the interface of a class into another interface clients expect.Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.(将一个类的接口变换成原创 2015-07-21 23:33:46 · 510 阅读 · 0 评论 -
设计模式_抽象工厂模式
铺垫 要知道抽象模式最大的优点必须先了解什么是产品等级和产品族 在上面的类图中,两厢车和三厢车称为两个不同的等级结构;而2.0排量车和2.4排量车则称为两个不同的产品族。再具体一点,2.0排量两厢车和2.4排量两厢车属于同一个等级结构,2.0排量三厢车和2.4排量三厢车属于另一个等级结构;而2.0排量两厢车和2.0排量三厢车属于同一个产品族,2.4排量两厢车和2.4排量三原创 2015-07-18 15:33:31 · 736 阅读 · 0 评论 -
面向对象五大原则_3.依赖倒置&4.接口隔离
依赖倒置原则:Dependence Inversion Principle,DIP 1.高层模板不依赖低层模板,俩者依赖抽象 2.抽象不依赖细节3.细节依赖抽象 翻译成java风格就是: 面向接口编程 模块间的依赖通过接口或抽象类产生 接口和抽象类不依赖与实现类 实现类依赖接口或抽象类倒置是什么? 倒置的反义词就是正原创 2015-07-13 21:01:18 · 872 阅读 · 0 评论 -
设计模式_建造者模式
Builder Pattern Separate the construction of a complex object from its representation so that the same construction process can create different representations. 将一个复杂对象的构建与它的表示分离,使得同样的构造过程可以创建原创 2015-07-18 21:33:35 · 535 阅读 · 0 评论 -
设计模式_状态模式
State Pattern Allow an object to alter its behavior when its internal state changes.The object will appear to change its class.(当一个对象内在状态改变时,允许其改变行为,这个对象看起来像改变了其类)要说建造者模式是按照客户提供的顺序执行,那么这个是应对多原创 2015-07-26 11:10:46 · 642 阅读 · 0 评论 -
设计模式_桥梁模式
Bridge Pattern Decouple an abstraction from its implementation so that the two can vary independently.(将抽象和实现解耦,使得倆者可以独立的变化)例子"天下熙熙,皆为利来;天下攘攘,皆为利往" 现实和结构分开服装公司 ="服装"+"公司" ="服装公司" 解耦之前原创 2015-07-26 11:20:25 · 712 阅读 · 0 评论 -
设计模式_观察者模式
Observer Pattern Define a ont-to-many dependency between objects so that when one object changes state,all its dependents are notified and updated automatically.(定义对象间一种一对多的依赖关系,使得每当一个对象改变状态时,原创 2015-07-25 14:26:57 · 843 阅读 · 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.(要求一个子系统的外部与其内部的通信必须通过一个统一的对象进行,门原创 2015-07-25 14:28:14 · 988 阅读 · 0 评论 -
设计模式_访问者模式
Visitor Pattern Repressent an operation to be performed on the elements of an object structure.Visitor lets you define a new operation without changing the classees of the elements on which it原创 2015-07-25 14:39:08 · 918 阅读 · 0 评论 -
设计模式_享元模式
Flyweight Pattern use sharing to support large unmbers of fine-grained objects efficiently(使用共享对象可有效地支持大量的细粒度的对象)例子“三哥,厂商人员已经定位出了,OutOfMemory内存溢出,没查到有内存泄漏的情况,现 在还在跟踪……是突然暴涨的,都是在繁忙期出现问题原创 2015-07-26 11:16:18 · 739 阅读 · 0 评论 -
面向对象五大原则_1.单一职责原则&2.里氏替换原则
单一职责原则:Single Responsibility Principle (SRP)一个类,只有一个引起它变化的原因。应该只有一个职责。每一个职责都是变化的一个轴线,如果一个类有一个以上的职责,这些职责就耦合在了一起。这会导致脆弱的设计。当一个职责发生变化时,可能会影响其它的职责。另外,多个职责耦合在一起,会影响复用性。例如:要实现逻辑和界面的分离。T负责两个不同的职责原创 2015-07-13 11:17:25 · 1035 阅读 · 0 评论 -
面向对象五大原则_基石_开闭原则
1988年,勃兰特·梅耶(Bertrand Meyer)在他的著作《面向对象软件构造(Object Oriented Software Construction)》中提出了开闭原则,它的原文是这样:“Software entities should be open for extension,but closed for modification”。翻译过来就是:“软件实体应当对扩展开放,对修原创 2015-07-14 12:31:28 · 859 阅读 · 0 评论 -
设计模式_单例模式
Singleton PatternEnsure a class has one instance,and provide a global point of access to it. 确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。皇帝只有一个首先我们来想想,如何获取一个对象,一般是通过new来实现,高级的通过反射,但是该如何禁止外部创建对象。answe原创 2015-07-18 10:05:28 · 638 阅读 · 0 评论 -
设计模式_工厂模式
Define an interface for creating on object, but let subclasses decide which class to instantiate Factory Method lets a class defer instantiation to subclasses.定义一个用于创建对象的接口,让子类决定实例化哪一类。抽象产品类Pr原创 2015-07-18 11:56:13 · 659 阅读 · 0 评论 -
设计模式_组合模式
Composite Pattern Compose objects into tree structures to represent part-whole hierarchies.Composite lets clients treat individual objects and compositions of objects uniformly.(将对象组合成树形结构以表示"原创 2015-07-21 23:36:57 · 595 阅读 · 0 评论