随笔分类 - Design Patterns
摘要:将对象组合成树形结构以表示“部分-整体”的层次结构。Composite使得用户对单个对象和组合对象的使用具有一致性。 Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of...
        阅读全文
                
摘要:接口支持多继承; 抽象类支持缺省实现; is-a vs can-do ; Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 public interface ITh 2 { 3 voi...
        阅读全文
                
摘要:1.静态工厂通过静态方法创建对象,但是不符合OCP Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 public class StaticFactory 2 3 { 4 5 public static Book Cr...
        阅读全文
                
摘要:1. Constructor Injection public class Boy { private IDog smallDog; public Boy(IDog smallDog) { this.smallDog = smallDog; } } public interface ID...
        阅读全文
                
摘要:1.代码如下: 1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 5 namespace DelegateImplementObserverPattern 6 { 7 public class War 8 { 9 static void Ma...
        阅读全文
                
摘要:2003年6月荣获美国《软件开发》第13届震憾(Jolt)大奖! 在本书中,享誉全球的软件开发专家和软件工程大师Robert C.Martin将向您展示如何解决软件开发人员、项目经理及软件项目领导们所面临的最棘手的问题。这本综合性、实用性的敏捷开发和极限编程方面的指南,是由敏捷开发的创始人之一所撰写的。 特色内容: ●讲述在预算和时间要求下,软件开发人员和项目经理如何使用敏捷开发完成项目...
        阅读全文
                
摘要:Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structu...
        阅读全文
                
摘要:内容简介:你不想重新发明车轮(或者更差的是,没有充气车胎的轮子),所以你从设计模式中寻求帮助——设计模式是过去人们面对同样的软件设计问题所得到的经验。 有了设计模式,就可以利用其他人的实践经验的精华,因此省下的时间可以用在其他的事情上,如:更有挑战性的事情、更复杂的事情以及更有趣的事情。你想要学习: ·重要的模式 ·何时使用某个模式,为何使用该模式 ·如何在你自己的设计中马上采用这些模式 ·...
        阅读全文
                
摘要:Definea family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
        阅读全文
                
摘要:Define a one to many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
        阅读全文
                
摘要:Provide a unified interface to a set of interfaces in a subsystem.Facade defines a high level interface that makes the subsystem easier to use. EJB中可以用Facade模式减少远程调用的次数!
        阅读全文
                
摘要:Provide a surrogate or placeholder for another object to control access to it. 代理类型: 远程代理(Remote Proxy) .NET Remoting, JAVA RMI 虚拟代理(Virtual Proxy)It will not be created until needed. Copy on write...
        阅读全文
                
摘要:Attach additional responsibilities to an object dynamically.Decorators provide a flexible alternative to subclassing for extending functionality. 动态地给一个对象增加一些额外的职责。就增加功 能而言,Decorator模式比生成子类更为灵活。 ——《...
        阅读全文
                
摘要:将一个类的接口转换成客户希望的另一个接口,Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。 convert the interface of class into another interface clients expect.Adapter lets classes work together that could not otherwise because of...
        阅读全文
                
摘要:specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype. 依赖关系的倒置 – 抽象A直接依赖于实现细节b 抽象不应该依赖于实现细节,实现细节应该依赖于抽象。 –抽象A依赖于抽象B,实 现细节b依赖于抽象B Member...
        阅读全文
                
摘要:将一个复杂对象的构建与其表示相分离,使得同样的构建过程可以创建不同的表示。《设计模式》GoF seperate the construction of a complex object from it representation so that the same construction process can create different representions. Builder 模...
        阅读全文
                
摘要:保证一个类仅有一个实例,并提供一个该实例的全局访问点。——《设计模式》GoF ensure that a class has only one intstance Singleton模式中的实例构造器可以设置为protected以允 许子类派生。 • Singleton模式一般不要支持ICloneable接口,因为这可能 会导致多个对象实例,与Singleton模式的初衷违背。 •...
        阅读全文
                
摘要:Define an interface for creating an object, but let subclass decide which class to instantiate. Factory mothed lets class defer instantiation to subclass. Factory Method模式的几个要点 • Factory Method模式主...
        阅读全文
                
摘要:提供一个接口,让该接口负责创建一系列“相关或者 相互依赖的对象”,无需指定它们具体的类。——《设计模式》GoF Provide an interface for creating families of related or dependent objects without specifying their concrete classes. 常规的对象创建方法: // 创建一个Road ...
        阅读全文
                
 
                    
                
 浙公网安备 33010602011771号
浙公网安备 33010602011771号