重构29式Ⅲ
摘要:重构学习笔记22.分解方法概念:本文中的”分解方法”是指把我们所做的这个功能不停的分解方法,直到将一个大方法分解为名字有意义且可读性更好的若干个小方法。重构学习笔记23.引入参数对象概念:本文中的“引入参数对象”是指当一个方法的参数过多或者过为复杂时,可以考虑把这些参数封装成一个单独的类,如果一个方法所需要的参数大于5个,理解该方法的签名就变得比较困...
阅读全文
浅入浅出设计模式--策略模式篇
摘要:浅入浅出设计模式简介 GoF(“四人帮”Gang of Four,指Erich Gamma, Richard Helm, Ralph Johnson & John Vlissides四人)的《设计模式》(1995年出版)是第一次将设计模式提升到理论高度,并将之规范化。本书提出了23种基本设计模式,自此,在可复用面向对象...
阅读全文
浅尝DesignPattern_ChainOfResponsibility
摘要:UML:通过让多个对象都有机会处理该请求,来避免耦合请求的发送者的接收器,。链接接收对象并且通过链来传递请求直到一个对象处理它。Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receivin...
阅读全文
浅尝DesignPattern_Template
摘要:UML:AbstractClass() defines abstract primitive operations that concrete subclasses define to implement steps of an algorithm 定义一个抽象的原始操作,来使子类实现算法步骤implements a template method defining the skeleton of...
阅读全文
浅尝DesignPattern_Prototype
摘要:UML:Sample:Prototype() declares an interface for cloning itself 定义复制对象的接口ConcretePrototype() implements an operation for cloning itself 实现复制自己的操作Client() creates a new object by asking a prototype to ...
阅读全文
浅尝DesignPattern_Proxy
摘要:UML:Proxy (MathProxy) maintains a reference that lets the proxy access the real subject. Proxy may refer to a Subject if the RealSubject and Subject interfaces are the same. 维持一个引用让代理访问真正的Subject。代理可以...
阅读全文
浅尝DesignPattern_Decorator
摘要:UML:Component:定义一个对象接口,可以给这些对象动态的添加职责ContreteComponent:定义了一个具体的对象,也可以给这个对象添加一些职责Decorator:装饰抽象类,继承了Component,从外类来扩展Component类的功能,但对于Component来说,是无需知道Decrator的存在的ContreteDecoratorA和ContreteDecoratorB都是...
阅读全文
浅尝DesignPattern_OCP&DIP
摘要:开放封闭原则(OCP,Open Closed Principle)都是所有面向对象原则的核心。软件设计本身所追求的目标就是封装变化、降低耦合,而开放封闭原则正是对这一目标的最直接体现。 核心的思想是:软件实体应该是可扩展,而不可修改的。也就是说,对扩展是开放的,而对修改是封闭的。因此,对扩展开放,意味着有新的需求或变化时,可以对现有代码进行扩展,以适应新的情况。 基本思路:实现开放封闭的核心思...
阅读全文
浅尝DesignPattern_Factory
摘要:UML:-------------------------------------------------------------------------------------------PARTICIPANTS:Product(Page) defines the interface of objects the factory method creates定义工厂方法创造的对象接口Concre...
阅读全文
浅尝DesignPattern_Strategy
摘要:UML:----------------------------------------------------------------------------------------------SAMPLE:Strategy.cs[代码]ConcreteStrategyA.cs[代码]ConcreteStrategyB.cs[代码]ConcreteStrategyC.cs[代码]Context....
阅读全文
浅尝DesignPattern_AbstractFactory
摘要:AbstractFactory-------------------------------------------------------------------------------------------------------UML:本图来自dofactory-----------------------------------------------------------------...
阅读全文