C#设计模式手册_V1.0

Size: px
Start display at page:

Download "C#设计模式手册_V1.0"

Transcription

1 第 1 章 (Design Pattern) 描述了软件开发过程中若干重复出现的问题的解决方案, 这些方案不是由过程 算法等底层程序构造实体实现, 而是由软件系统中类与类之间或不同类的对象之间的共生关系组成 可以帮助软件设计人员学习 重用前人的经验和成果 的分类整理最早见于 Erich Gamma 在德国慕尼黑大学的博士论文 1995 年, Erich Gamma,Richard Helm,Ralph Johnson,John Vlissides 合著的 Design Patterns:Elements of Reusable Object_Oriented Software 系统地整理和描述了 23 个精选的 (GOF 模式 ), 为的学习 研究和推广提供了良好的范例 第 2 章 GOF 创建型 Abstract Factory( 抽象工厂模式 ): 提供一个创建一系列相关或相互依赖对象的接口, 而无需指定它们具体的类 Builder( 生成器模式 ): 将一个复杂对象的构件与它的表示分离, 使得同样的构建过程可以创建不同的表述 Factory Method( 工厂模式 ): 定义一个用于创建对象的接口, 让子类决定将哪一个类实例化 Factory Method 使一个类的实例化延迟到其子类 Prototype( 原型模式 ): 用原型实例指定创建对象的种类, 并且通过拷贝这个原型来创建新的对象 Singleton( 单件模式 ): 保证一个类仅有一个实例, 并提供一个访问它的全局访问点 结构型 Adapter( 适配器模式 ): 将一个类的接口转换成客户希望的另外一个接口 Adapter 模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作 Bridge( 桥接模式 ): 将抽象部分与它的实现部分分离, 使它们都可以独立地变化 Composite( 组合模式 ): 将对象组合成树型结构以表示 部分 - 整体 的层次结构 Composite 使得客户对单个对象和复合对象的使用具有一致性 1

2 Decorator( 装饰模式 ): 动态地给一个对象添加一些额外的职责 就扩展功能而言, Decorator 模式比生成子类方式更为灵活 Facade( 外观模式 ): 为子系统中的一组接口提供一个一致的界面,Facade 模式定义了一个高层接口, 这个接口使得这一子系统更加容易使用 Flyweight( 享元模式 ): 运用共享技术有效地支持大量细粒度的对象 Proxy( 代理模式 ): 为其他对象提供一个代理以控制对这个对象的访问 行为型 Chain of Responsibility( 职责链模式 ): 为解除请求的发送者和接受者之间耦合, 而使多个对象都有机会处理这个请求 将这些对象连成一条链, 并沿着这条链传递该请求, 直到有一个对象处理它 Command( 命令模式 ): 将一个请求封装为一个对象, 从而使你可以用不同的请求对客户进行参数化 ; 对请求排队或记录请求日志, 以及支持可取消的操作 Interpreter( 解释器模式 ): 给定一个语言, 定义它的文法的一种表示, 并定义一个解释器, 该解释器使用该表示来解释语言中的句子 Iteartor( 迭代器模式 ): 提供一种方法顺序访问一个聚合对象中各个元素, 而又不需暴露该对象的内部表示 Mediator( 中介者模式 ): 用一个中介对象来封装一系列的对象交互 中介者使各对象不需要显式地相互引用, 从而使器耦合松散, 而且可以独立地改变它们之间的交互 Memento( 备忘录模式 ): 在不破坏封装性的前提下, 捕获一个对象的内部状态, 并在该对象之外保存这个状态 这样以后就可以将该对象恢复到保存的状态 Observer( 观察者模式 ): 定义对象间的一种一对多的依赖关系, 以便当一个对象的状态发生改变时, 所有依赖于它的对象都得到通知并自动刷新 State( 状态模式 ): 允许一个对象在其内部状态改变时改变它的行为 对象看起来似乎修改了它所属的类 Strategy( 策略模式 ): 定义一系列的算法, 把它们一个个封装起来, 并且使它们可相互替换 本模式使得算法的变化可独立于使用它的客户 TemplateMethod( 模板方法模式 ): 定义一个操作中的算法的骨架, 而将一些步骤延迟到子类中 Template Method 使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤 Visitor( 访问者模式 ): 定义一个操作中的算法的骨架, 而将一些步骤延迟到子类中 Template Method 使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤 创建型 2

3 2.1. 创建型 Abstract Factory( 抽象工厂模式 ) 意图 : 提供一个创建一系列相关或相互依赖对象的接口, 而无需指定它们具体的类 场景 : 一个系统要独立于它的产品的创建 组合和表示时 一个系统要由多个产品系列中的一个来配置时 当你要强调一系列相关的产品对象的设计以便进行联合使用时 当你提供一个产品类库, 而只想显示它们的接口而不是实现时 重构成本 : 中 代码 : using System; namespace GOF.Abstract.Structural 3

4 // MainApp test application class MainApp public static void Main() // Abstract factory #1 AbstractFactory factory1 = new ConcreteFactory1(); Client c1 = new Client(factory1); c1.run(); // Abstract factory #2 AbstractFactory factory2 = new ConcreteFactory2(); Client c2 = new Client(factory2); c2.run(); // Wait for user input Console.Read(); // "AbstractFactory" abstract class AbstractFactory public abstract AbstractProductA CreateProductA(); public abstract AbstractProductB CreateProductB(); // "ConcreteFactory1" class ConcreteFactory1 : AbstractFactory public override AbstractProductA CreateProductA() return new ProductA1(); public override AbstractProductB CreateProductB() return new ProductB1(); // "ConcreteFactory2" class ConcreteFactory2 : AbstractFactory public override AbstractProductA CreateProductA() return new ProductA2(); public override AbstractProductB CreateProductB() 4

5 return new ProductB2(); // "AbstractProductA" abstract class AbstractProductA // "AbstractProductB" abstract class AbstractProductB public abstract void Interact(AbstractProductA a); // "ProductA1" class ProductA1 : AbstractProductA // "ProductB1" class ProductB1 : AbstractProductB public override void Interact(AbstractProductA a) Console.WriteLine(this.GetType().Name + " interacts with " + a.gettype().name); // "ProductA2" class ProductA2 : AbstractProductA // "ProductB2" class ProductB2 : AbstractProductB public override void Interact(AbstractProductA a) Console.WriteLine(this.GetType().Name + " interacts with " + a.gettype().name); // "Client" - the interaction environment of the products class Client private AbstractProductA AbstractProductA; private AbstractProductB AbstractProductB; // Constructor 5

6 public Client(AbstractFactory factory) AbstractProductB = factory.createproductb(); AbstractProductA = factory.createproducta(); public void Run() AbstractProductB.Interact(AbstractProductA); 输出 ProductB1 interacts with ProductA1 ProductB2 interacts with ProductA Builder( 生成器模式 ) 意图 : 将一个复杂对象的构建与它的表示分离, 使得同样的构建过程可以创建不同的表示 场景 : 当创建复杂对象的算法应该独立于该对象的组成部分以及它们的装配方式时 当构造过程必须允许被构造的对象有不同的表示时 重构成本 : 低 代码 : using System; using System.Collections; namespace GOF.Builder.Structural 6

7 // MainApp test application public class MainApp public static void Main() // Create director and builders Director director = new Director(); Builder b1 = new ConcreteBuilder1(); Builder b2 = new ConcreteBuilder2(); // Construct two products director.construct(b1); Product p1 = b1.getresult(); p1.show(); director.construct(b2); Product p2 = b2.getresult(); p2.show(); // Wait for user Console.Read(); // "Director" class Director // Builder uses a complex series of steps public void Construct(Builder builder) builder.buildparta(); builder.buildpartb(); // "Builder" abstract class Builder public abstract void BuildPartA(); public abstract void BuildPartB(); public abstract Product GetResult(); // "ConcreteBuilder1" class ConcreteBuilder1 : Builder private Product product = new Product(); public override void BuildPartA() 7

8 product.add("parta"); public override void BuildPartB() product.add("partb"); public override Product GetResult() return product; // "ConcreteBuilder2" class ConcreteBuilder2 : Builder private Product product = new Product(); public override void BuildPartA() product.add("partx"); public override void BuildPartB() product.add("party"); public override Product GetResult() return product; // "Product" class Product ArrayList parts = new ArrayList(); public void Add(string part) parts.add(part); public void Show() Console.WriteLine("\nProduct Parts "); foreach (string part in parts) Console.WriteLine(part); 8

9 输出 Product Parts PartA PartB Product Parts PartX PartY Factory Method( 工厂模式 ) 意图 : 定义一个用于创建对象的接口, 让子类决定实例化哪一个类 Factory Method 使一个类的实例化延迟到其子类 场景 : 当一个类不知道它所必须创建的对象的类的时候 当一个类希望由它的子类来指定它所创建的对象的时候 当类将创建对象的职责委托给多个帮助子类中的某一个, 并且你希望将哪一个帮助子类 是代理者这一信息局部化的时候 重构成本 : 低 代码 : using System; using System.Collections; namespace GOF.Factory.Structural // MainApp test application class MainApp 9

10 static void Main() // An array of creators Creator[] creators = new Creator[2]; creators[0] = new ConcreteCreatorA(); creators[1] = new ConcreteCreatorB(); // Iterate over creators and create products foreach (Creator creator in creators) Product product = creator.factorymethod(); Console.WriteLine("Created 0", product.gettype().name); // Wait for user Console.Read(); // "Product" abstract class Product // "ConcreteProductA" class ConcreteProductA : Product // "ConcreteProductB" class ConcreteProductB : Product // "Creator" abstract class Creator public abstract Product FactoryMethod(); // "ConcreteCreator" class ConcreteCreatorA : Creator public override Product FactoryMethod() return new ConcreteProductA(); 10

11 // "ConcreteCreator" class ConcreteCreatorB : Creator public override Product FactoryMethod() return new ConcreteProductB(); 输出 Created ConcreteProductA Created ConcreteProductB Prototype( 原型模式 ) 意图 : 用原型实例指定创建对象的种类, 并且通过拷贝这些原型创建新的对象 场景 : 当一个系统应该独立于它的产品创建 构成和表示时, 要使用 Prototype 模式 当要实例化的类是在运行时刻指定时, 例如, 通过动态装载 ; 或者为了避免创建一个与产品类层次平行的工厂类层次时 ; 或者当一个类的实例只能有几个不同状态组合中的一种时 建立相应数目的原型并克隆它们可能比每次用合适的状态手工实例化该类更方便一些 重构成本 : 11

12 极低 代码 : using System; namespace GOF.Prototype.Structural // MainApp test application class MainApp static void Main() // Create two instances and clone each ConcretePrototype1 p1 = new ConcretePrototype1("I"); ConcretePrototype1 c1 = (ConcretePrototype1)p1.Clone(); Console.WriteLine("Cloned: 0", c1.id); ConcretePrototype2 p2 = new ConcretePrototype2("II"); ConcretePrototype2 c2 = (ConcretePrototype2)p2.Clone(); Console.WriteLine("Cloned: 0", c2.id); // Wait for user Console.Read(); // "Prototype" abstract class Prototype private string id; // Constructor public Prototype(string id) this.id = id; // Property public string Id get return id; public abstract Prototype Clone(); // "ConcretePrototype1" class ConcretePrototype1 : Prototype // Constructor public ConcretePrototype1(string id) : base(id) 12

13 public override Prototype Clone() // Shallow copy return (Prototype)this.MemberwiseClone(); // "ConcretePrototype2" class ConcretePrototype2 : Prototype // Constructor public ConcretePrototype2(string id) : base(id) public override Prototype Clone() // Shallow copy return (Prototype)this.MemberwiseClone(); 输出 Cloned: I Cloned: II Singleton( 单件模式 ) 意图 : 保证一个类仅有一个实例, 并提供一个访问它的全局访问点 场景 : 当类只能有一个实例而且客户可以从一个众所周知的访问点访问它时 当这个唯一实例应该是通过子类化可扩展的, 并且客户应该无需更改代码就能使用一个扩展的实例时 13

14 重构成本 : 极低 代码 : using System; namespace GOF.Singleton.Structural // MainApp test application class MainApp static void Main() // Constructor is protected -- cannot use new Singleton s1 = Singleton.Instance(); Singleton s2 = Singleton.Instance(); if (s1 == s2) Console.WriteLine("Objects are the same instance"); // Wait for user Console.Read(); // "Singleton" class Singleton private static Singleton instance; // Note: Constructor is 'protected' protected Singleton() public static Singleton Instance() // Use 'Lazy initialization' if (instance == null) instance = new Singleton(); return instance; 输出 14

15 Objects are the same instance 2.2. 结构型 Adapter( 适配器模式 ) 意图 : 将一个类的接口转换成客户希望的另外一个接口 Adapter 模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作 场景 : 你想使用一个已经存在的类, 而它的接口不符合你的需求 你想创建一个可以复用的类, 该类可以与其他不相关的类或不可预见的类 ( 即那些接口可能不一定兼容的类 ) 协同工作 ( 仅适用于对象 Adapter) 你想使用一些已经存在的子类, 但是不可能对每一个都进行子类化以匹配它们的接口 对象适配器可以适配它的父类接口 重构成本 : 低 代码 : using System; namespace GOF.Adapter.Structural // Mainapp test application class MainApp static void Main() 15

16 // Create adapter and place a request Target target = new Adapter(); target.request(); // Wait for user Console.Read(); // "Target" class Target public virtual void Request() Console.WriteLine("Called Target Request()"); // "Adapter" class Adapter : Target private Adaptee adaptee = new Adaptee(); public override void Request() // Possibly do some other work // and then call SpecificRequest adaptee.specificrequest(); // "Adaptee" class Adaptee public void SpecificRequest() Console.WriteLine("Called SpecificRequest()"); 输出 Called SpecificRequest() 16

17 Bridge( 桥接模式 ) 意图 : 将抽象部分与它的实现部分分离, 使它们都可以独立地变化 场景 : 你不希望在抽象和它的实现部分之间有一个固定的绑定关系 例如这种情况可能是因为, 在程序运行时刻实现部分应可以被选择或者切换 类的抽象以及它的实现都应该可以通过生成子类的方法加以扩充 这时 Bridge 模式使你可以对不同的抽象接口和实现部分进行组合, 并分别对它们进行扩充 对一个抽象的实现部分的修改应对客户不产生影响, 即客户的代码不必重新编译 (C++) 你想对客户完全隐藏抽象的实现部分 在 C++ 中, 类的表示在类接口中是可见的 有许多类要生成 这样一种类层次结构说明你必须将一个对象分解成两个部分 Rumbaugh 称这种类层次结构为 嵌套的普化 (nested generalizations ) 你想在多个对象间共享实现 ( 可能使用引用计数 ), 但同时要求客户并不知道这一点 重构成本 : 中 代码 : using System; namespace GOF.Bridge.Structural // MainApp test application class MainApp 17

18 static void Main() Abstraction ab = new RefinedAbstraction(); // Set implementation and call ab.implementor = new ConcreteImplementorA(); ab.operation(); // Change implemention and call ab.implementor = new ConcreteImplementorB(); ab.operation(); // Wait for user Console.Read(); // "Abstraction" class Abstraction protected Implementor implementor; // Property public Implementor Implementor set implementor = value; public virtual void Operation() implementor.operation(); // "Implementor" abstract class Implementor public abstract void Operation(); // "RefinedAbstraction" class RefinedAbstraction : Abstraction public override void Operation() implementor.operation(); // "ConcreteImplementorA" class ConcreteImplementorA : Implementor 18

19 public override void Operation() Console.WriteLine("ConcreteImplementorA Operation"); // "ConcreteImplementorB" class ConcreteImplementorB : Implementor public override void Operation() Console.WriteLine("ConcreteImplementorB Operation"); 输出 ConcreteImplementorA Operation ConcreteImplementorB Operation Composite( 组合模式 ) 意图 : 将对象组合成树形结构以表示 部分 - 整体 的层次结构 Composite 使得用户对单个对象和组合对象的使用具有一致性 场景 : 19

20 你想表示对象的部分 - 整体层次结构 你希望用户忽略组合对象与单个对象的不同, 用户将统一地使用组合结构中的所有对象 重构成本 : 高 代码 : using System; using System.Collections; namespace GOF.Composite.Structural // MainApp test application class MainApp static void Main() // Create a tree structure Composite root = new Composite("root"); root.add(new Leaf("Leaf A")); root.add(new Leaf("Leaf B")); Composite comp = new Composite("Composite X"); comp.add(new Leaf("Leaf XA")); comp.add(new Leaf("Leaf XB")); root.add(comp); root.add(new Leaf("Leaf C")); // Add and remove a leaf Leaf leaf = new Leaf("Leaf D"); root.add(leaf); root.remove(leaf); // Recursively display tree root.display(1); // Wait for user Console.Read(); // "Component" abstract class Component protected string name; // Constructor public Component(string name) this.name = name; 20

21 public abstract void Add(Component c); public abstract void Remove(Component c); public abstract void Display(int depth); // "Composite" class Composite : Component private ArrayList children = new ArrayList(); // Constructor public Composite(string name) : base(name) public override void Add(Component component) children.add(component); public override void Remove(Component component) children.remove(component); public override void Display(int depth) Console.WriteLine(new String('-', depth) + name); // Recursively display child nodes foreach (Component component in children) component.display(depth + 2); // "Leaf" class Leaf : Component // Constructor public Leaf(string name) : base(name) public override void Add(Component c) Console.WriteLine("Cannot add to a leaf"); 21

22 public override void Remove(Component c) Console.WriteLine("Cannot remove from a leaf"); public override void Display(int depth) Console.WriteLine(new String('-', depth) + name); 输出 -root ---Leaf A ---Leaf B ---Composite X -----Leaf XA -----Leaf XB ---Leaf C Decorator( 装饰模式 ) 意图 : 22

23 动态地给一个对象添加一些额外的职责 就增加功能来说,Decorator 模式相比生成子类更为灵活 场景 : 在不影响其他对象的情况下, 以动态 透明的方式给单个对象添加职责 处理那些可以撤消的职责 当不能采用生成子类的方法进行扩充时 一种情况是, 可能有大量独立的扩展, 为支持每一种组合将产生大量的子类, 使得子类数目呈爆炸性增长 另一种情况可能是因为类定义被隐藏, 或类定义不能用于生成子类 重构成本 : 低 代码 : using System; namespace GOF.Decorator.Structural // MainApp test application class MainApp static void Main() // Create ConcreteComponent and two Decorators ConcreteComponent c = new ConcreteComponent(); ConcreteDecoratorA d1 = new ConcreteDecoratorA(); ConcreteDecoratorB d2 = new ConcreteDecoratorB(); // Link decorators d1.setcomponent(c); d2.setcomponent(d1); d2.operation(); // Wait for user Console.Read(); // "Component" abstract class Component public abstract void Operation(); // "ConcreteComponent" class ConcreteComponent : Component public override void Operation() 23

24 Console.WriteLine("ConcreteComponent.Operation()"); // "Decorator" abstract class Decorator : Component protected Component component; public void SetComponent(Component component) this.component = component; public override void Operation() if (component!= null) component.operation(); // "ConcreteDecoratorA" class ConcreteDecoratorA : Decorator private string addedstate; public override void Operation() base.operation(); addedstate = "New State"; Console.WriteLine("ConcreteDecoratorA.Operation()"); // "ConcreteDecoratorB" class ConcreteDecoratorB : Decorator public override void Operation() base.operation(); AddedBehavior(); Console.WriteLine("ConcreteDecoratorB.Operation()"); void AddedBehavior() 24

25 输出 ConcreteComponent.Operation() ConcreteDecoratorA.Operation() ConcreteDecoratorB.Operation() Facade( 外观模式 ) 意图 : 为子系统中的一组接口提供一个一致的界面,Facade 模式定义了一个高层接口, 这个接口使得这一子系统更加容易使用 场景 : 当你要为一个复杂子系统提供一个简单接口时 子系统往往因为不断演化而变得越来越复杂 大多数模式使用时都会产生更多更小的类 这使得子系统更具可重用性, 也更容易对子系统进行定制, 但这也给那些不需要定制子系统的用户带来一些使用上的困难 Facade 可以提供一个简单的缺省视图, 这一视图对大多数用户来说已经足够, 而那些需要更多的可定制性的用户可以越过 Facade 层 客户程序与抽象类的实现部分之间存在着很大的依赖性 引入 Facade 将这个子系统与客户以及其他的子系统分离, 可以提高子系统的独立性和可移植性 当你需要构建一个层次结构的子系统时, 使用 Facade 模式定义子系统中每层的入口点 如果子系统之间是相互依赖的, 你可以让它们仅通过 Facade 进行通讯, 从而简化了它们之间的依赖关系 重构成本 : 25

26 高 代码 : using System; namespace GOF.Facade.Structural // Mainapp test application class MainApp public static void Main() Facade facade = new Facade(); facade.methoda(); facade.methodb(); // Wait for user Console.Read(); // "Subsystem ClassA" class SubSystemOne public void MethodOne() Console.WriteLine(" SubSystemOne Method"); // Subsystem ClassB" class SubSystemTwo public void MethodTwo() Console.WriteLine(" SubSystemTwo Method"); // Subsystem ClassC" class SubSystemThree public void MethodThree() Console.WriteLine(" SubSystemThree Method"); // Subsystem ClassD" class SubSystemFour 26

27 public void MethodFour() Console.WriteLine(" SubSystemFour Method"); // "Facade" class Facade SubSystemOne one; SubSystemTwo two; SubSystemThree three; SubSystemFour four; public Facade() one = new SubSystemOne(); two = new SubSystemTwo(); three = new SubSystemThree(); four = new SubSystemFour(); public void MethodA() Console.WriteLine("\nMethodA() ---- "); one.methodone(); two.methodtwo(); four.methodfour(); public void MethodB() Console.WriteLine("\nMethodB() ---- "); two.methodtwo(); three.methodthree(); 输出 MethodA() ---- SubSystemOne Method SubSystemTwo Method SubSystemFour Method MethodB()

28 SubSystemTwo Method SubSystemThree Method Flyweight( 享元模式 ) 意图 : 运用共享技术有效地支持大量细粒度的对象 场景 : 一个应用程序使用了大量的对象 完全由于使用大量的对象, 造成很大的存储开销 对象的大多数状态都可变为外部状态 如果删除对象的外部状态, 那么可以用相对较少的共享对象取代很多组对象 应用程序不依赖于对象标识 由于 Flyweight 对象可以被共享, 对于概念上明显有别的对象, 标识测试将返回真值 重构成本 : 低 代码 : using System; using System.Collections; namespace GOF.Flyweight.Structural // MainApp test application class MainApp static void Main() 28

29 // Arbitrary extrinsic state int extrinsicstate = 22; FlyweightFactory f = new FlyweightFactory(); // Work with different flyweight instances Flyweight fx = f.getflyweight("x"); fx.operation(--extrinsicstate); Flyweight fy = f.getflyweight("y"); fy.operation(--extrinsicstate); Flyweight fz = f.getflyweight("z"); fz.operation(--extrinsicstate); UnsharedConcreteFlyweight fu = new UnsharedConcreteFlyweight(); fu.operation(--extrinsicstate); // Wait for user Console.Read(); // "FlyweightFactory" class FlyweightFactory private Hashtable flyweights = new Hashtable(); // Constructor public FlyweightFactory() flyweights.add("x", new ConcreteFlyweight()); flyweights.add("y", new ConcreteFlyweight()); flyweights.add("z", new ConcreteFlyweight()); public Flyweight GetFlyweight(string key) return ((Flyweight)flyweights[key]); // "Flyweight" abstract class Flyweight public abstract void Operation(int extrinsicstate); // "ConcreteFlyweight" class ConcreteFlyweight : Flyweight public override void Operation(int extrinsicstate) 29

30 Console.WriteLine("ConcreteFlyweight: " + extrinsicstate); // "UnsharedConcreteFlyweight" class UnsharedConcreteFlyweight : Flyweight public override void Operation(int extrinsicstate) Console.WriteLine("UnsharedConcreteFlyweight: " + extrinsicstate); 输出 ConcreteFlyweight: 21 ConcreteFlyweight: 20 ConcreteFlyweight: 19 UnsharedConcreteFlyweight: Proxy( 代理模式 ) 意图 : 为其他对象提供一种代理以控制对这个对象的访问 场景 : 在需要用比较通用和复杂的对象指针代替简单的指针的时候, 使用 Proxy 模式 下面是一些可以使用 Proxy 模式常见情况 : 30

31 远程代理 (Remote Proxy ) 为一个对象在不同的地址空间提供局部代表 虚代理 (Virtual Proxy ) 根据需要创建开销很大的对象 保护代理 (Protection Proxy ) 控制对原始对象的访问 保护代理用于对象应该有不同的访问权限的时候 智能指引 (Smart Reference ) 取代了简单的指针, 它在访问对象时执行一些附加操作 它的典型用途包括 : 对指向实际对象的引用计数, 这样当该对象没有引用时, 可以自动释放它 当第一次引用一个持久对象时, 将它装入内存 在访问一个实际对象前, 检查是否已经锁定了它, 以确保其他对象不能改变它 重构成本 : 低 代码 : using System; namespace GOF.Proxy.Structural // MainApp test application class MainApp static void Main() // Create proxy and request a service Proxy proxy = new Proxy(); proxy.request(); // Wait for user Console.Read(); // "Subject" abstract class Subject public abstract void Request(); // "RealSubject" class RealSubject : Subject public override void Request() Console.WriteLine("Called RealSubject.Request()"); 31

32 // "Proxy" class Proxy : Subject RealSubject realsubject; public override void Request() // Use 'lazy initialization' if (realsubject == null) realsubject = new RealSubject(); realsubject.request(); 输出 Called RealSubject.Request() 2.3. 行为型 Chain of Responsibility( 职责链模式 ) 意图 : 使多个对象都有机会处理请求, 从而避免请求的发送者和接收者之间的耦合关系 将这些对象连成一条链, 并沿着这条链传递该请求, 直到有一个对象处理它为止 场景 : 有多个的对象可以处理一个请求, 哪个对象处理该请求运行时刻自动确定 你想在不明确指定接收者的情况下, 向多个对象中的一个提交一个请求 可处理一个请求的对象集合应被动态指定 重构成本 : 32

33 中 代码 : using System; namespace GOF.Chain.Structural // MainApp test application class MainApp static void Main() // Setup Chain of Responsibility Handler h1 = new ConcreteHandler1(); Handler h2 = new ConcreteHandler2(); Handler h3 = new ConcreteHandler3(); h1.setsuccessor(h2); h2.setsuccessor(h3); // Generate and process request int[] requests = 2, 5, 14, 22, 18, 3, 27, 20 ; foreach (int request in requests) h1.handlerequest(request); // Wait for user Console.Read(); // "Handler" abstract class Handler protected Handler successor; public void SetSuccessor(Handler successor) this.successor = successor; public abstract void HandleRequest(int request); // "ConcreteHandler1" class ConcreteHandler1 : Handler public override void HandleRequest(int request) if (request >= 0 && request < 10) Console.WriteLine("0 handled request 1", 33

34 this.gettype().name, request); else if (successor!= null) successor.handlerequest(request); // "ConcreteHandler2" class ConcreteHandler2 : Handler public override void HandleRequest(int request) if (request >= 10 && request < 20) Console.WriteLine("0 handled request 1", this.gettype().name, request); else if (successor!= null) successor.handlerequest(request); // "ConcreteHandler3" class ConcreteHandler3 : Handler public override void HandleRequest(int request) if (request >= 20 && request < 30) Console.WriteLine("0 handled request 1", this.gettype().name, request); else if (successor!= null) successor.handlerequest(request); 输出 34

35 ConcreteHandler1 handled request 2 ConcreteHandler1 handled request 5 ConcreteHandler2 handled request 14 ConcreteHandler3 handled request 22 ConcreteHandler2 handled request 18 ConcreteHandler1 handled request 3 ConcreteHandler3 handled request 27 ConcreteHandler3 handled request Command( 命令模式 ) 意图 : 将一个请求封装为一个对象, 从而使你可用不同的请求对客户进行参数化 ; 对请求排队或记录请求日志, 以及支持可撤消的操作 场景 : 抽象出待执行的动作以参数化某对象 你可用过程语言中的回调 (Call back) 函数表达这种参数化机制 所谓回调函数是指函数先在某处注册, 而它将在稍后某个需要的时候被调用 Command 模式是回调机制的一个面向对象的替代品 在不同的时刻指定 排列和执行请求 一个 Command 对象可以有一个与初始请求无关的生存期 如果一个请求的接收者可用一种与地址空间无关的方式表达, 那么就可将负责该请求的命令对象传送给另一个不同的进程并在那儿实现该请求 支持取消操作 Command 的 Excute 操作可在实施操作前将状态存储起来, 在取消操作时这个状态用来消除该操作的影响 Command 接口必须添加一个 Unexcute 操作, 该操作取消上一次 Excute 调用的效果 执行的命令被存储在一个历史列表中 可通过向后和向前遍历这一列表并分别调用 Unexcute 和 Excute 来实现重数不限的 35

36 取消 和 重做 支持修改日志, 这样当系统崩溃时, 这些修改可以被重做一遍 在 Command 接口中添加装载操作和存储操作, 可以用来保持变动的一个一致的修改日志 从崩溃中恢复的过程包括从磁盘中重新读入记录下来的命令并用 Excute 操作重新执行它们 用构建在原语操作上的高层操作构造一个系统 这样一种结构在支持事务 (transaction) 的信息系统中很常见 一个事务封装了对数据的一组变动 模式提供了对事务进行建模的方法 Command 有一个公共的接口, 使得你可以用同一种方式调用所有的事务 同时使用该模式也易于添加新事务以扩展系统 重构成本 : 高 代码 : using System; namespace GOF.Command.Structural // MainApp test applicatio class MainApp static void Main() // Create receiver, command, and invoker Receiver receiver = new Receiver(); Command command = new ConcreteCommand(receiver); Invoker invoker = new Invoker(); // Set and execute command invoker.setcommand(command); invoker.executecommand(); // Wait for user Console.Read(); // "Command" abstract class Command protected Receiver receiver; // Constructor public Command(Receiver receiver) this.receiver = receiver; public abstract void Execute(); 36

37 // "ConcreteCommand" class ConcreteCommand : Command // Constructor public ConcreteCommand(Receiver receiver) : base(receiver) public override void Execute() receiver.action(); // "Receiver" class Receiver public void Action() Console.WriteLine("Called Receiver.Action()"); // "Invoker" class Invoker private Command command; public void SetCommand(Command command) this.command = command; public void ExecuteCommand() command.execute(); 输出 Called Receiver.Action() 37

38 Interpreter( 解释器模式 ) 意图 : 给定一个语言, 定义它的文法的一种表示, 并定义一个解释器, 这个解释器使用该表示来解释语言中的句子 场景 : 当有一个语言需要解释执行, 并且你可将该语言中的句子表示为一个抽象语法树时, 可使用解释器模式 而当存在以下情况时该模式效果最好 : 该文法简单对于复杂的文法, 文法的类层次变得庞大而无法管理 此时语法分析程序生成器这样的工具是更好的选择 它们无需构建抽象语法树即可解释表达式, 这样可以节省空间而且还可能节省时间 效率不是一个关键问题最高效的解释器通常不是通过直接解释语法分析树实现的, 而是首先将它们转换成另一种形式 例如, 正则表达式通常被转换成状态机 但即使在这种情况下, 转换器仍可用解释器模式实现, 该模式仍是有用的 重构成本 : 高 代码 : using System; using System.Collections; namespace GOF.Interpreter.Structural // MainApp test application class MainApp static void Main() Context context = new Context(); // Usually a tree ArrayList list = new ArrayList(); // Populate 'abstract syntax tree' list.add(new TerminalExpression()); 38

39 list.add(new NonterminalExpression()); list.add(new TerminalExpression()); list.add(new TerminalExpression()); // Interpret foreach (AbstractExpression exp in list) exp.interpret(context); // Wait for user Console.Read(); // "Context" class Context // "AbstractExpression" abstract class AbstractExpression public abstract void Interpret(Context context); // "TerminalExpression" class TerminalExpression : AbstractExpression public override void Interpret(Context context) Console.WriteLine("Called Terminal.Interpret()"); // "NonterminalExpression" class NonterminalExpression : AbstractExpression public override void Interpret(Context context) Console.WriteLine("Called Nonterminal.Interpret()"); 输出 Called Terminal.Interpret() Called Nonterminal.Interpret() Called Terminal.Interpret() Called Terminal.Interpret() 39

40 Iteartor( 迭代器模式 ) 意图 : 提供一种方法顺序访问一个聚合对象中各个元素, 而又不需暴露该对象的内部表示 场景 : 访问一个聚合对象的内容而无需暴露它的内部表示 支持对聚合对象的多种遍历 为遍历不同的聚合结构提供一个统一的接口 ( 即, 支持多态迭代 ) 重构成本 : 中 代码 : using System; using System.Collections; namespace GOF.Iterator.Structural // MainApp test application class MainApp static void Main() ConcreteAggregate a = new ConcreteAggregate(); a[0] = "Item A"; a[1] = "Item B"; a[2] = "Item C"; a[3] = "Item D"; 40

41 // Create Iterator and provide aggregate ConcreteIterator i = new ConcreteIterator(a); Console.WriteLine("Iterating over collection:"); object item = i.first(); while (item!= null) Console.WriteLine(item); item = i.next(); // Wait for user Console.Read(); // "Aggregate" abstract class Aggregate public abstract Iterator CreateIterator(); // "ConcreteAggregate" class ConcreteAggregate : Aggregate private ArrayList items = new ArrayList(); public override Iterator CreateIterator() return new ConcreteIterator(this); // Property public int Count get return items.count; // Indexer public object this[int index] get return items[index]; set items.insert(index, value); // "Iterator" abstract class Iterator public abstract object First(); public abstract object Next(); 41

42 public abstract bool IsDone(); public abstract object CurrentItem(); // "ConcreteIterator" class ConcreteIterator : Iterator private ConcreteAggregate aggregate; private int current = 0; // Constructor public ConcreteIterator(ConcreteAggregate aggregate) this.aggregate = aggregate; public override object First() return aggregate[0]; public override object Next() object ret = null; if (current < aggregate.count - 1) ret = aggregate[++current]; return ret; public override object CurrentItem() return aggregate[current]; public override bool IsDone() return current >= aggregate.count? true : false; 输出 Iterating over collection: Item A Item B Item C Item D 42

43 Mediator( 中介者模式 ) 意图 : 用一个中介对象来封装一系列的对象交互 中介者使各对象不需要显式地相互引用, 从而使其耦合松散, 而且可以独立地改变它们之间的交互 场景 : 一组对象以定义良好但是复杂的方式进行通信 产生的相互依赖关系结构混乱且难以理解 一个对象引用其他很多对象并且直接与这些对象通信, 导致难以复用该对象 想定制一个分布在多个类中的行为, 而又不想生成太多的子类 重构成本 : 中 代码 : using System; using System.Collections; namespace GOF.Mediator.Structural // Mainapp test application class MainApp static void Main() ConcreteMediator m = new ConcreteMediator(); ConcreteColleague1 c1 = new ConcreteColleague1(m); ConcreteColleague2 c2 = new ConcreteColleague2(m); m.colleague1 = c1; m.colleague2 = c2; c1.send("how are you?"); c2.send("fine, thanks"); // Wait for user 43

44 Console.Read(); // "Mediator" abstract class Mediator public abstract void Send(string message, Colleague colleague); // "ConcreteMediator" class ConcreteMediator : Mediator private ConcreteColleague1 colleague1; private ConcreteColleague2 colleague2; public ConcreteColleague1 Colleague1 set colleague1 = value; public ConcreteColleague2 Colleague2 set colleague2 = value; public override void Send(string message, Colleague colleague) if (colleague == colleague1) colleague2.notify(message); else colleague1.notify(message); // "Colleague" abstract class Colleague protected Mediator mediator; // Constructor public Colleague(Mediator mediator) this.mediator = mediator; 44

45 // "ConcreteColleague1" class ConcreteColleague1 : Colleague // Constructor public ConcreteColleague1(Mediator mediator) : base(mediator) public void Send(string message) mediator.send(message, this); public void Notify(string message) Console.WriteLine("Colleague1 gets message: " + message); // "ConcreteColleague2" class ConcreteColleague2 : Colleague // Constructor public ConcreteColleague2(Mediator mediator) : base(mediator) public void Send(string message) mediator.send(message, this); public void Notify(string message) Console.WriteLine("Colleague2 gets message: " + message); 输出 Colleague2 gets message: How are you? Colleague1 gets message: Fine, thanks 45

46 Memento( 备忘录模式 ) 意图 : 在不破坏封装性的前提下, 捕获一个对象的内部状态, 并在该对象之外保存这个状态 这样以后就可将该对象恢复到原先保存的状态 场景 : 必须保存一个对象在某一个时刻的 ( 部分 ) 状态, 这样以后需要时它才能恢复到先前的状态 如果一个用接口来让其它对象直接得到这些状态, 将会暴露对象的实现细节并破坏对象的封装性 重构成本 : 低 代码 : using System; namespace GOF.Memento.Structural // MainApp test application class MainApp static void Main() Originator o = new Originator(); o.state = "On"; // Store internal state Caretaker c = new Caretaker(); c.memento = o.creatememento(); // Continue changing originator o.state = "Off"; // Restore saved state o.setmemento(c.memento); // Wait for user Console.Read(); 46

47 // "Originator" class Originator private string state; // Property public string State get return state; set state = value; Console.WriteLine("State = " + state); public Memento CreateMemento() return (new Memento(state)); public void SetMemento(Memento memento) Console.WriteLine("Restoring state:"); State = memento.state; // "Memento" class Memento private string state; // Constructor public Memento(string state) this.state = state; // Property public string State get return state; // "Caretaker" class Caretaker private Memento memento; 47

48 // Property public Memento Memento set memento = value; get return memento; 输出 State = On State = Off Restoring state: State = On Observer( 观察者模式 ) 意图 : 定义对象间的一种一对多的依赖关系, 当一个对象的状态发生改变时, 所有依赖于它的对象都得到通知并被自动更新 场景 : 当一个抽象模型有两个方面, 其中一个方面依赖于另一方面 将这二者封装在独立的对象中以使它们可以各自独立地改变和复用 当对一个对象的改变需要同时改变其它对象, 而不知道具体有多少对象有待改变 48

49 当一个对象必须通知其它对象, 而它又不能假定其它对象是谁 换言之, 你不希望这些对象是紧密耦合的 重构成本 : 高 代码 : using System; using System.Collections; namespace GOF.Observer.Structural // MainApp test application class MainApp static void Main() // Configure Observer pattern ConcreteSubject s = new ConcreteSubject(); s.attach(new ConcreteObserver(s, "X")); s.attach(new ConcreteObserver(s, "Y")); s.attach(new ConcreteObserver(s, "Z")); // Change subject and notify observers s.subjectstate = "ABC"; s.notify(); // Wait for user Console.Read(); // "Subject" abstract class Subject private ArrayList observers = new ArrayList(); public void Attach(Observer observer) observers.add(observer); public void Detach(Observer observer) observers.remove(observer); public void Notify() foreach (Observer o in observers) o.update(); 49

50 // "ConcreteSubject" class ConcreteSubject : Subject private string subjectstate; // Property public string SubjectState get return subjectstate; set subjectstate = value; // "Observer" abstract class Observer public abstract void Update(); // "ConcreteObserver" class ConcreteObserver : Observer private string name; private string observerstate; private ConcreteSubject subject; // Constructor public ConcreteObserver( ConcreteSubject subject, string name) this.subject = subject; this.name = name; public override void Update() observerstate = subject.subjectstate; Console.WriteLine("Observer 0's new state is 1", name, observerstate); // Property public ConcreteSubject Subject get return subject; set subject = value; 50

51 输出 Observer X's new state is ABC Observer Y's new state is ABC Observer Z's new state is ABC State( 状态模式 ) 意图 : 允许一个对象在其内部状态改变时改变它的行为 对象看起来似乎修改了它的类 场景 : 一个对象的行为取决于它的状态, 并且它必须在运行时刻根据状态改变它的行为 一个操作中含有庞大的多分支的条件语句, 且这些分支依赖于该对象的状态 这个状态通常用一个或多个枚举常量表示 通常, 有多个操作包含这一相同的条件结构 State 模式将每一个条件分支放入一个独立的类中 这使得你可以根据对象自身的情况将对象的状态作为一个对象, 这一对象可以不依赖于其他对象而独立变化 重构成本 : 中 代码 : using System; namespace GOF.State.RealWorld // MainApp test application class MainApp static void Main() 51

52 // Open a new account Account account = new Account("Jim Johnson"); // Apply financial transactions account.deposit(500.0); account.deposit(300.0); account.deposit(550.0); account.payinterest(); account.withdraw( ); account.withdraw( ); // Wait for user Console.Read(); // "State" abstract class State protected Account account; protected double balance; protected double interest; protected double lowerlimit; protected double upperlimit; // Properties public Account Account get return account; set account = value; public double Balance get return balance; set balance = value; public abstract void Deposit(double amount); public abstract void Withdraw(double amount); public abstract void PayInterest(); // "ConcreteState" // Account is overdrawn class RedState : State double servicefee; // Constructor public RedState(State state) 52

53 this.balance = state.balance; this.account = state.account; Initialize(); private void Initialize() // Should come from a datasource interest = 0.0; lowerlimit = ; upperlimit = 0.0; servicefee = 15.00; public override void Deposit(double amount) balance += amount; StateChangeCheck(); public override void Withdraw(double amount) amount = amount - servicefee; Console.WriteLine("No funds available for withdrawal!"); public override void PayInterest() // No interest is paid private void StateChangeCheck() if (balance > upperlimit) account.state = new SilverState(this); // "ConcreteState" // Silver is non-interest bearing state class SilverState : State // Overloaded constructors public SilverState(State state) : this(state.balance, state.account) 53

54 public SilverState(double balance, Account account) this.balance = balance; this.account = account; Initialize(); private void Initialize() // Should come from a datasource interest = 0.0; lowerlimit = 0.0; upperlimit = ; public override void Deposit(double amount) balance += amount; StateChangeCheck(); public override void Withdraw(double amount) balance -= amount; StateChangeCheck(); public override void PayInterest() balance += interest * balance; StateChangeCheck(); private void StateChangeCheck() if (balance < lowerlimit) account.state = new RedState(this); else if (balance > upperlimit) account.state = new GoldState(this); // "ConcreteState" // Interest bearing state class GoldState : State 54

55 // Overloaded constructors public GoldState(State state) : this(state.balance, state.account) public GoldState(double balance, Account account) this.balance = balance; this.account = account; Initialize(); private void Initialize() // Should come from a database interest = 0.05; lowerlimit = ; upperlimit = ; public override void Deposit(double amount) balance += amount; StateChangeCheck(); public override void Withdraw(double amount) balance -= amount; StateChangeCheck(); public override void PayInterest() balance += interest * balance; StateChangeCheck(); private void StateChangeCheck() if (balance < 0.0) account.state = new RedState(this); else if (balance < lowerlimit) account.state = new SilverState(this); 55

56 // "Context" class Account private State state; private string owner; // Constructor public Account(string owner) // New accounts are 'Silver' by default this.owner = owner; state = new SilverState(0.0, this); // Properties public double Balance get return state.balance; public State State get return state; set state = value; public void Deposit(double amount) state.deposit(amount); Console.WriteLine("Deposited 0:C --- ", amount); Console.WriteLine(" Balance = 0:C", this.balance); Console.WriteLine(" Status = 0\n", this.state.gettype().name); Console.WriteLine(""); public void Withdraw(double amount) state.withdraw(amount); Console.WriteLine("Withdrew 0:C --- ", amount); Console.WriteLine(" Balance = 0:C", this.balance); Console.WriteLine(" Status = 0\n", this.state.gettype().name); public void PayInterest() state.payinterest(); Console.WriteLine("Interest Paid --- "); 56

57 Console.WriteLine(" Balance = 0:C", this.balance); Console.WriteLine(" Status = 0\n", this.state.gettype().name); 输出 Deposited $ Balance = $ Status = SilverState Deposited $ Balance = $ Status = SilverState Deposited $ Balance = $1, Status = GoldState Interest Paid --- Balance = $1, Status = GoldState Withdrew $2, Balance = ($582.50) Status = RedState No funds available for withdrawal! Withdrew $1, Balance = ($582.50) Status = RedState 57

58 Strategy( 策略模式 ) 意图 : 定义一系列的算法, 把它们一个个封装起来, 并且使它们可相互替换 本模式使得算法可独立于使用它的客户而变化 场景 : 许多相关的类仅仅是行为有异 策略 提供了一种用多个行为中的一个行为来配置一个类的方法 需要使用一个算法的不同变体 例如, 你可能会定义一些反映不同的空间 / 时间权衡的算法 当这些变体实现为一个算法的类层次时, 可以使用策略模式 算法使用客户不应该知道的数据 可使用策略模式以避免暴露复杂的 与算法相关的数据结构 一个类定义了多种行为, 并且这些行为在这个类的操作中以多个条件语句的形式出现 将相关的条件分支移入它们各自的 Strategy 类中以代替这些条件语句 重构成本 : 中 代码 : using System; namespace GOF.Strategy.Structural // MainApp test application class MainApp static void Main() Context context; // Three contexts following different strategies context = new Context(new ConcreteStrategyA()); context.contextinterface(); context = new Context(new ConcreteStrategyB()); context.contextinterface(); 58

59 context = new Context(new ConcreteStrategyC()); context.contextinterface(); // Wait for user Console.Read(); // "Strategy" abstract class Strategy public abstract void AlgorithmInterface(); // "ConcreteStrategyA" class ConcreteStrategyA : Strategy public override void AlgorithmInterface() Console.WriteLine( "Called ConcreteStrategyA.AlgorithmInterface()"); // "ConcreteStrategyB" class ConcreteStrategyB : Strategy public override void AlgorithmInterface() Console.WriteLine( "Called ConcreteStrategyB.AlgorithmInterface()"); // "ConcreteStrategyC" class ConcreteStrategyC : Strategy public override void AlgorithmInterface() Console.WriteLine( "Called ConcreteStrategyC.AlgorithmInterface()"); // "Context" class Context Strategy strategy; // Constructor public Context(Strategy strategy) 59

60 this.strategy = strategy; public void ContextInterface() strategy.algorithminterface(); 输出 Called ConcreteStrategyA.AlgorithmInterface() Called ConcreteStrategyB.AlgorithmInterface() Called ConcreteStrategyC.AlgorithmInterface() TemplateMethod( 模板方法模式 ) 意图 : 定义一个操作中的算法的骨架, 而将一些步骤延迟到子类中 TemplateMethod 使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤 场景 : 一次性实现一个算法的不变的部分, 并将可变的行为留给子类来实现 各子类中公共的行为应被提取出来并集中到一个公共父类中以避免代码重复 这是 Opdyke 和 Johnson 所描述过的 重分解以一般化 的一个很好的例子 首先识别现有代码中的不同之处, 并且将不同之处分离为新的操作 最后, 用一个调用这些新的操作的模板方法来替换这些不同的代码 控制子类扩展 模板方法只在特定点调用 hook 操作, 这样就只允许在这些点进行扩展 60

61 重构成本 : 低 代码 : using System; namespace GOF.Template.Structural // MainApp test application class MainApp static void Main() AbstractClass c; c = new ConcreteClassA(); c.templatemethod(); c = new ConcreteClassB(); c.templatemethod(); // Wait for user Console.Read(); // "AbstractClass" abstract class AbstractClass public abstract void PrimitiveOperation1(); public abstract void PrimitiveOperation2(); // The "Template method" public void TemplateMethod() PrimitiveOperation1(); PrimitiveOperation2(); Console.WriteLine(""); // "ConcreteClass" class ConcreteClassA : AbstractClass public override void PrimitiveOperation1() Console.WriteLine("ConcreteClassA.PrimitiveOperation1()"); public override void PrimitiveOperation2() Console.WriteLine("ConcreteClassA.PrimitiveOperation2()"); 61

62 class ConcreteClassB : AbstractClass public override void PrimitiveOperation1() Console.WriteLine("ConcreteClassB.PrimitiveOperation1()"); public override void PrimitiveOperation2() Console.WriteLine("ConcreteClassB.PrimitiveOperation2()"); 输出 ConcreteClassA.PrimitiveOperation1() ConcreteClassA.PrimitiveOperation2() ConcreteClassB.PrimitiveOperation1() ConcreteClassB.PrimitiveOperation2() 62

63 Visitor( 访问者模式 ) 意图 : 表示一个作用于某对象结构中的各元素的操作 它使你可以在不改变各元素的类的前提下定义作用于这些元素的新操作 场景 : 一个对象结构包含很多类对象, 它们有不同的接口, 而你想对这些对象实施一些依赖于其具体类的操作 需要对一个对象结构中的对象进行很多不同的并且不相关的操作, 而你想避免让这些操作 污染 这些对象的类 Vi s i t o r 使得你可以将相关的操作集中起来定义在一个类中 当该对象结构被很多应用共享时, 用 Vi s i t o r 模式让每个应用仅包含需要用到的操作 定义对象结构的类很少改变, 但经常需要在此结构上定义新的操作 改变对象结构类需要重定义对所有访问者的接口, 这可能需要很大的代价 如果对象结构类经常 63

64 改变, 那么可能还是在这些类中定义这些操作较好 重构成本 : 中 代码 : using System; using System.Collections; namespace GOF.Visitor.Structural // MainApp test application class MainApp static void Main() // Setup structure ObjectStructure o = new ObjectStructure(); o.attach(new ConcreteElementA()); o.attach(new ConcreteElementB()); // Create visitor objects ConcreteVisitor1 v1 = new ConcreteVisitor1(); ConcreteVisitor2 v2 = new ConcreteVisitor2(); // Structure accepting visitors o.accept(v1); o.accept(v2); // Wait for user Console.Read(); // "Visitor" abstract class Visitor public abstract void VisitConcreteElementA( ConcreteElementA concreteelementa); public abstract void VisitConcreteElementB( ConcreteElementB concreteelementb); // "ConcreteVisitor1" class ConcreteVisitor1 : Visitor public override void VisitConcreteElementA( ConcreteElementA concreteelementa) Console.WriteLine("0 visited by 1", concreteelementa.gettype().name, this.gettype().name); 64

65 public override void VisitConcreteElementB( ConcreteElementB concreteelementb) Console.WriteLine("0 visited by 1", concreteelementb.gettype().name, this.gettype().name); // "ConcreteVisitor2" class ConcreteVisitor2 : Visitor public override void VisitConcreteElementA( ConcreteElementA concreteelementa) Console.WriteLine("0 visited by 1", concreteelementa.gettype().name, this.gettype().name); public override void VisitConcreteElementB( ConcreteElementB concreteelementb) Console.WriteLine("0 visited by 1", concreteelementb.gettype().name, this.gettype().name); // "Element" abstract class Element public abstract void Accept(Visitor visitor); // "ConcreteElementA" class ConcreteElementA : Element public override void Accept(Visitor visitor) visitor.visitconcreteelementa(this); public void OperationA() // "ConcreteElementB" class ConcreteElementB : Element public override void Accept(Visitor visitor) 65

66 visitor.visitconcreteelementb(this); public void OperationB() // "ObjectStructure" class ObjectStructure private ArrayList elements = new ArrayList(); public void Attach(Element element) elements.add(element); public void Detach(Element element) elements.remove(element); public void Accept(Visitor visitor) foreach (Element e in elements) e.accept(visitor); 输出 ConcreteElementA visited by ConcreteVisitor1 ConcreteElementB visited by ConcreteVisitor1 ConcreteElementA visited by ConcreteVisitor2 ConcreteElementB visited by ConcreteVisitor2 66

设计模式_Patterns in Java_.doc

设计模式_Patterns in Java_.doc 1 1: 2:GoF A. Prototype( ) Builder Builder Singleton( ), B. Composite. Jive Decorator Decorator,. Bridge " (,, ), ( ) Flyweight Java,. C. Template Java,. Memento,. Observer Java API Observer 2 Chain of

More information

欢迎访问动力节点官方网站,动力节点java0基础免费学习半个月,java就业班免费学习一个月,满意后再交学费,请稊等,正在为您接入咨询老师

欢迎访问动力节点官方网站,动力节点java0基础免费学习半个月,java就业班免费学习一个月,满意后再交学费,请稊等,正在为您接入咨询老师 JDK 中的设计模式应用实例在 JDK(Java Development Kit) 类库中, 开发人员使用了大量设计模式, 正因为如此, 我们可以在不修改 JDK 源码的前提下开发出自己的应用软件, 本文列出了部分 JDK 中的模式应用实例, 有兴趣的同学可以深入研究, 看看前 Sun 公司的开发人员是如何在实际框架开发中运用设计模式的,Sunny 认为, 研究 JDK 类库中的模式实例也不失为学习如何使用设计模式的一个好方式.

More information

<4D F736F F D20D0C2B0E6C9E8BCC6C4A3CABDCAD6B2E15B43235D2E646F63>

<4D F736F F D20D0C2B0E6C9E8BCC6C4A3CABDCAD6B2E15B43235D2E646F63> 新版设计模式手册 [C#] 目 录 一. 创建型模式...3 1. 单件模式...3 2. 抽象工厂...7 3. 建造者模式...14 4. 工厂方法模式...21 5. 原型模式...27 二. 结构型模式...32 6. 适配器模式...32 7. 桥接模式...38 8. 组合模式...45 9. 装饰模式...51 10. 外观模式...58 11. 享元模式...64 12. 代理模式...71

More information

1 c o m m u n i c a t i n g o b j e c t ( ) ( ) / 2 1.1 Christopher Alexander [ A I S + 77 10 ] A l e x a n d e r 1. pattern name 2. (problem) 3. (solution) 4. (consequences) h a s h 1 3 C++ S m a l l

More information

OOP with Java 通知 Project 4: 4 月 18 日晚 9 点 关于抄袭 没有分数

OOP with Java 通知 Project 4: 4 月 18 日晚 9 点 关于抄袭 没有分数 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 4 月 18 日晚 9 点 关于抄袭 没有分数 复习 类的复用 组合 (composition): has-a 关系 class MyType { public int i; public double d; public char c; public void set(double

More information

EJB-Programming-3.PDF

EJB-Programming-3.PDF :, JBuilder EJB 2.x CMP EJB Relationships JBuilder EJB Test Client EJB EJB Seminar CMP Entity Beans Value Object Design Pattern J2EE Design Patterns Value Object Value Object Factory J2EE EJB Test Client

More information

JBuilder Weblogic

JBuilder Weblogic JUnit ( bliu76@yeah.net) < >6 JUnit Java Erich Gamma Kent Beck JUnit JUnit 1 JUnit 1.1 JUnit JUnit java XUnit JUnit 1.2 JUnit JUnit Erich Gamma Kent Beck Erich Gamma Kent Beck XP Extreme Programming CRC

More information

Microsoft PowerPoint - ch6 [相容模式]

Microsoft PowerPoint - ch6 [相容模式] UiBinder wzyang@asia.edu.tw UiBinder Java GWT UiBinder XML UI i18n (widget) 1 2 UiBinder HelloWidget.ui.xml: UI HelloWidgetBinder HelloWidget.java XML UI Owner class ( Composite ) UI XML UiBinder: Owner

More information

OOP with Java 通知 Project 4: 4 月 19 日晚 9 点

OOP with Java 通知 Project 4: 4 月 19 日晚 9 点 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 4 月 19 日晚 9 点 复习 类的复用 组合 (composition): has-a 关系 class MyType { public int i; public double d; public char c; public void set(double x) { d

More information

SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 "odps-sdk" 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基

SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 odps-sdk 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基 开放数据处理服务 ODPS SDK SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 "odps-sdk" 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基础功能的主体接口, 搜索关键词 "odpssdk-core" 一些

More information

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii 前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii C# 7 More Effective C# C# C# C# C# C# Common Language Runtime CLR just-in-time

More information

untitled

untitled 1 Outline 料 類 說 Tang, Shih-Hsuan 2006/07/26 ~ 2006/09/02 六 PM 7:00 ~ 9:30 聯 ives.net@gmail.com www.csie.ntu.edu.tw/~r93057/aspnet134 度 C# 力 度 C# Web SQL 料 DataGrid DataList 參 ASP.NET 1.0 C# 例 ASP.NET 立

More information

面向对象技术

面向对象技术 1 Design Pattern (3) 设计模式 (3) 摘要 2 Design Patterns Why, What, How Creational, Structural and Behavioral Patterns Behavioral Patterns 3 行为模式是对在不同的对象之间划分责任和算法的抽象化 行为模式不仅仅是关于类和对象的, 而且关注它们之间的通信模式 类的行为模式 :

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

无类继承.key

无类继承.key 无类继承 JavaScript 面向对象的根基 周爱 民 / aimingoo aiming@gmail.com https://aimingoo.github.io https://github.com/aimingoo rand = new Person("Rand McKinnon",... https://docs.oracle.com/cd/e19957-01/816-6408-10/object.htm#1193255

More information

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

Microsoft Word - ch04三校.doc

Microsoft Word - ch04三校.doc 4-1 4-1-1 (Object) (State) (Behavior) ( ) ( ) ( method) ( properties) ( functions) 4-2 4-1-2 (Message) ( ) ( ) ( ) A B A ( ) ( ) ( YourCar) ( changegear) ( lowergear) 4-1-3 (Class) (Blueprint) 4-3 changegear

More information

EJB-Programming-4-cn.doc

EJB-Programming-4-cn.doc EJB (4) : (Entity Bean Value Object ) JBuilder EJB 2.x CMP EJB Relationships JBuilder EJB Test Client EJB EJB Seminar CMP Entity Beans Session Bean J2EE Session Façade Design Pattern Session Bean Session

More information

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information

untitled

untitled 1 Outline 類别 欄 (1) 類 類 狀 更 易 類 理 若 類 利 來 利 using 來 namespace 類 ; (2) namespace IBM class Notebook namespace Compaq class Notebook 類别 類 來 類 列 欄 (field) (property) (method) (event) 類 例 立 來 車 類 類 立 車 欄 料

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc Java C++ Pascal C# C# if if if for while do while foreach while do while C# 3.1.1 ; 3-1 ischeck Test() While ischeck while static bool ischeck = true; public static void Test() while (ischeck) ; ischeck

More information

Value Chain ~ (E-Business RD / Pre-Sales / Consultant) APS, Advanc

Value Chain ~ (E-Business RD / Pre-Sales / Consultant) APS, Advanc Key @ Value Chain fanchihmin@yahoo.com.tw 1 Key@ValueChain 1994.6 1996.6 2000.6 2000.10 ~ 2004.10 (E- RD / Pre-Sales / Consultant) APS, Advanced Planning & Scheduling CDP, Collaborative Demand Planning

More information

面向对象技术

面向对象技术 1 Design Pattern (2) 设计模式 (2) 摘要 2 Design Patterns Why, What, How Creational, Structural and Behavioral Patterns Structural Patterns 3 结构模式描述如何将类或者对象结合在一起形成更大的结构 类的结构模式 : 结构型类模式使用继承机制来组合接口或实现 对象的结构模式 :

More information

人 物 訪 中 華 技 術 I N T E R V I E W 壹 前 言 當 您 搭 乘 台 鐵 縱 貫 線 南 下 列 車, 於 駛 入 高 雄 岡 山 地 區 時, 映 入 眼 簾 的 是 一 座 佔 地 約 30,000 坪 的 綠 色 巨 型 鋼 構 廠 房 及 碩 大 的 皆 豪 鋼 構

人 物 訪 中 華 技 術 I N T E R V I E W 壹 前 言 當 您 搭 乘 台 鐵 縱 貫 線 南 下 列 車, 於 駛 入 高 雄 岡 山 地 區 時, 映 入 眼 簾 的 是 一 座 佔 地 約 30,000 坪 的 綠 色 巨 型 鋼 構 廠 房 及 碩 大 的 皆 豪 鋼 構 源 自 民 國 66 年 間 財 團 法 人 中 華 顧 問 工 程 司 ( 以 下 簡 稱 中 華 顧 問 ), 入 首 台 HP-000 電 腦, 開 啟 我 國 工 程 顧 問 業 應 用 電 腦 之 先 河, 歷 經 電 腦 主 機 系 統 及 主 從 式 系 統 架 構 等 的 調 整, 目 前 已 進 入 網 際 網 路 化 的 資 訊 系 統 建 構 台 灣 世 曦 工 程 顧 問 股

More information

OOP with Java 通知 Project 4: 5 月 2 日晚 9 点

OOP with Java 通知 Project 4: 5 月 2 日晚 9 点 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 5 月 2 日晚 9 点 复习 类的复用 组合 (composition): has-a 关系 class MyType { public int i; public double d; public char c; public void set(double x) { d =

More information

基于ECO的UML模型驱动的数据库应用开发1.doc

基于ECO的UML模型驱动的数据库应用开发1.doc ECO UML () Object RDBMS Mapping.Net Framework Java C# RAD DataSetOleDbConnection DataGrod RAD Client/Server RAD RAD DataReader["Spell"].ToString() AObj.XXX bug sql UML OR Mapping RAD Lazy load round trip

More information

新・解きながら学ぶJava

新・解きながら学ぶJava 481! 41, 74!= 40, 270 " 4 % 23, 25 %% 121 %c 425 %d 121 %o 121 %x 121 & 199 && 48 ' 81, 425 ( ) 14, 17 ( ) 128 ( ) 183 * 23 */ 3, 390 ++ 79 ++ 80 += 93 + 22 + 23 + 279 + 14 + 124 + 7, 148, 16 -- 79 --

More information

OOP with Java 通知 Project 3: 3 月 29 日晚 9 点 4 月 1 日上课

OOP with Java 通知 Project 3: 3 月 29 日晚 9 点 4 月 1 日上课 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 3: 3 月 29 日晚 9 点 4 月 1 日上课 复习 Java 包 创建包 : package 语句, 包结构与目录结构一致 使用包 : import restaurant/ - people/ - Cook.class - Waiter.class - tools/ - Fork.class

More information

软件工程文档编制

软件工程文档编制 实训抽象类 一 实训目标 掌握抽象类的定义 使用 掌握运行时多态 二 知识点 抽象类的语法格式如下 : public abstract class ClassName abstract void 方法名称 ( 参数 ); // 非抽象方法的实现代码 在使用抽象类时需要注意如下几点 : 1 抽象类不能被实例化, 实例化的工作应该交由它的子类来完成 2 抽象方法必须由子类来进行重写 3 只要包含一个抽象方法的抽象类,

More information

エスポラージュ株式会社 住所 : 東京都江東区大島 東急ドエルアルス大島 HP: ******************* * 关于 Java 测试试题 ******

エスポラージュ株式会社 住所 : 東京都江東区大島 東急ドエルアルス大島 HP:  ******************* * 关于 Java 测试试题 ****** ******************* * 关于 Java 测试试题 ******************* 問 1 运行下面的程序, 选出一个正确的运行结果 public class Sample { public static void main(string[] args) { int[] test = { 1, 2, 3, 4, 5 ; for(int i = 1 ; i System.out.print(test[i]);

More information

基于CDIO一体化理念的课程教学大纲设计

基于CDIO一体化理念的课程教学大纲设计 Java 语 言 程 序 设 计 课 程 教 学 大 纲 Java 语 言 程 序 设 计 课 程 教 学 大 纲 一 课 程 基 本 信 息 1. 课 程 代 码 :52001CC022 2. 课 程 名 称 :Java 语 言 程 序 设 计 3. 课 程 英 文 名 称 :Java Programming 4. 课 程 类 别 : 理 论 课 ( 含 实 验 上 机 或 实 践 ) 5. 授

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Java application Java main applet Web applet Runnable Thread CPU Thread 1 Thread 2 Thread 3 CUP Thread 1 Thread 2 Thread 3 ,,. (new) Thread (runnable) start( ) CPU (running) run ( ) blocked CPU sleep(

More information

untitled

untitled Ogre Rendering System http://antsam.blogone.net AntsamCGD@hotmail.com geometry systemmaterial systemshader systemrendering system API API DirectX OpenGL API Pipeline Abstraction API Pipeline Pipeline configurationpipeline

More information

Microsoft Word - 物件導向編程精要.doc

Microsoft Word - 物件導向編程精要.doc Essential Object-Oriented Programming Josh Ko 2007.03.11 object-oriented programming C++ Java OO class object OOP Ruby duck typing complexity abstraction paradigm objects objects model object-oriented

More information

epub 32-2

epub 32-2 2 L e x i W Y S I W Y G L e x i 8 2-1 L e x i 2-1 Lexi L e x i C a l d e r D o c [ C L 92 ] 2 23 2.1 L e x i 1) L e x i 2) L e x i 3) L e x i W Y S I W Y G L e x i 4 ) ( l o o k - a n d - f e e l )L e

More information

软件设计模式 网络学院考题.doc

软件设计模式 网络学院考题.doc 学习中心 姓名 学号 西安电子科技大学网络与继续教育学院 软件设计模式 全真试题 ( 闭卷 90 分钟 ) 题号 一 二 三 四 五 总分 题分 10 20 20 30 20 得分 一 简答题 (10 分 ) 1.1(3 分 ) 什么是设计模式? 设计模式的目标是什么? 1.2(3 分 ) 设计模式具有哪三大特点? 1.3(4 分 )GOF 设计模式常用的有几种?GOF 设计模式按照模式的目的可 第

More information

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit Tomcat Web JUnit Cactus JUnit Java Cactus JUnit 26.1 JUnit Java JUnit JUnit Java JSP Servlet JUnit Java Erich Gamma Kent Beck xunit JUnit boolean JUnit Java JUnit Java JUnit Java 26.1.1 JUnit JUnit How

More information

ebook140-9

ebook140-9 9 VPN VPN Novell BorderManager Windows NT PPTP V P N L A V P N V N P I n t e r n e t V P N 9.1 V P N Windows 98 Windows PPTP VPN Novell BorderManager T M I P s e c Wi n d o w s I n t e r n e t I S P I

More information

ebook140-8

ebook140-8 8 Microsoft VPN Windows NT 4 V P N Windows 98 Client 7 Vintage Air V P N 7 Wi n d o w s NT V P N 7 VPN ( ) 7 Novell NetWare VPN 8.1 PPTP NT4 VPN Q 154091 M i c r o s o f t Windows NT RAS [ ] Windows NT4

More information

AL-M200 Series

AL-M200 Series NPD4754-00 TC ( ) Windows 7 1. [Start ( )] [Control Panel ()] [Network and Internet ( )] 2. [Network and Sharing Center ( )] 3. [Change adapter settings ( )] 4. 3 Windows XP 1. [Start ( )] [Control Panel

More information

epub83-1

epub83-1 C++Builder 1 C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r 1.1 1.1.1 1-1 1. 1-1 1 2. 1-1 2 A c c e s s P a r a d o x Visual FoxPro 3. / C / S 2 C + + B u i l d e r / C

More information

Logitech Wireless Combo MK45 English

Logitech Wireless Combo MK45 English Logitech Wireless Combo MK45 Setup Guide Logitech Wireless Combo MK45 English................................................................................... 7..........................................

More information

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F 1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET 2.0 2.0.NET Framework.NET Framework 2.0 ( 3).NET Framework 2.0.NET Framework ( System ) o o o o o o Boxing UnBoxing() o

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Fortran Algol Pascal Modula-2 BCPL C Simula SmallTalk C++ Ada Java C# C Fortran 5.1 message A B 5.2 1 class Vehicle subclass Car object mycar public class Vehicle extends Object{ public int WheelNum

More information

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile.. WebSphere Studio Application Developer IBM Portal Toolkit... 1/21 WebSphere Studio Application Developer IBM Portal Toolkit Portlet Doug Phillips (dougep@us.ibm.com),, IBM Developer Technical Support Center

More information

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1 21 , 7, Windows,,,, : 010-62782989 13501256678 13801310933,,,, ;,, ( CIP) /,,. : ;, 2005. 11 ( 21 ) ISBN 7-81082 - 634-4... - : -. TP316-44 CIP ( 2005) 123583 : : : : 100084 : 010-62776969 : 100044 : 010-51686414

More information

OOP with Java 通知 Project 3 提交时间 3 月 29 日晚 9 点 Piazza Project 2 投票

OOP with Java 通知 Project 3 提交时间 3 月 29 日晚 9 点 Piazza Project 2 投票 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 3 提交时间 3 月 29 日晚 9 点 Piazza Project 2 投票 复习 创建对象 构造函数 函数重载 : 函数 = 函数名 + 参数列表 public class MyType { int i; double d; char c; void set(double x)

More information

Microsoft PowerPoint - 08_OO_CJC.ppt

Microsoft PowerPoint - 08_OO_CJC.ppt C++ 中的 Hello World! C 程序设计语言 第 8 章 OO 与 C++ Java C# 孙志岗 sun@hit.edu.cn http://sunner.cn 兼容 C 语言的 : #include int main() printf("hello,, world!\n"); return 0; 更具 C++ 味道的 : #include int

More information

1 1 大概思路 创建 WebAPI 创建 CrossMainController 并编写 Nuget 安装 microsoft.aspnet.webapi.cors 跨域设置路由 编写 Jquery EasyUI 界面 运行效果 2 创建 WebAPI 创建 WebAPI, 新建 -> 项目 ->

1 1 大概思路 创建 WebAPI 创建 CrossMainController 并编写 Nuget 安装 microsoft.aspnet.webapi.cors 跨域设置路由 编写 Jquery EasyUI 界面 运行效果 2 创建 WebAPI 创建 WebAPI, 新建 -> 项目 -> 目录 1 大概思路... 1 2 创建 WebAPI... 1 3 创建 CrossMainController 并编写... 1 4 Nuget 安装 microsoft.aspnet.webapi.cors... 4 5 跨域设置路由... 4 6 编写 Jquery EasyUI 界面... 5 7 运行效果... 7 8 总结... 7 1 1 大概思路 创建 WebAPI 创建 CrossMainController

More information

untitled

untitled 1 Outline ArrayList 類 列類 串類 類 類 例 理 MSDN Library MSDN Library 量 例 參 列 [ 說 ] [] [ 索 ] [] 來 MSDN Library 了 類 類 利 F1 http://msdn.microsoft.com/library/ http://msdn.microsoft.com/library/cht/ Object object

More information

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1 C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 月 3 日 1 1 INPUTOUTPUT 1 InputOutput 题目描述 用 cin 输入你的姓名 ( 没有空格 ) 和年龄 ( 整数 ), 并用 cout 输出 输入输出符合以下范例 输入 master 999 输出 I am master, 999 years old. 注意 "," 后面有一个空格,"." 结束,

More information

RunPC2_.doc

RunPC2_.doc PowerBuilder 8 (5) PowerBuilder Client/Server Jaguar Server Jaguar Server Connection Cache Thin Client Internet Connection Pooling EAServer Connection Cache Connection Cache Connection Cache Connection

More information

Microsoft PowerPoint - L17_Inheritance_v4.pptx

Microsoft PowerPoint - L17_Inheritance_v4.pptx C++ Programming Lecture 17 Wei Liu ( 刘 威 ) Dept. of Electronics and Information Eng. Huazhong University of Science and Technology May. 2015 Lecture 17 Chapter 20. Object-Oriented Programming: Inheritance

More information

untitled

untitled ADF Web ArcGIS Server ADF GeocodeConnection control 4-2 Web ArcGIS Server Application Developer Framework (ADF).NET interop semblies.net Web ADF GIS Server 4-3 .NET ADF Web Represent the views in ArcMap

More information

eBOOK

eBOOK 设计模式可 复用面向对 象软件基础 序 言 所有结构良好的面向对象软件体系结构中都包含了许多模式 实际上, 当我评估一个面向对象系统的质量时, 所使用的方法之一就是要判断系统的设计者是否强调了对象之间的公共协同关系 在系统开发阶段强调这种机制的优势在于, 它能使所生成的系统体系结构更加精巧 简洁和易于理解, 其程度远远超过了未使用模式的体系结构 模式在构造复杂系统时的重要性早已在其他领域中被认可 特别地,Christopher

More information

Microsoft PowerPoint - string_kruse [兼容模式]

Microsoft PowerPoint - string_kruse [兼容模式] Strings Strings in C not encapsulated Every C-string has type char *. Hence, a C-string references an address in memory, the first of a contiguous set of bytes that store the characters making up the string.

More information

<4D F736F F D20C9E8BCC6C4A3CABDBEABBDE2A3A8476F D6D6C9E8BCC6BDE2CEF6B8BD432B2BCAB5CFD6D4B4C2EBA3A9>

<4D F736F F D20C9E8BCC6C4A3CABDBEABBDE2A3A8476F D6D6C9E8BCC6BDE2CEF6B8BD432B2BCAB5CFD6D4B4C2EBA3A9> 设计模式精解 -GoF 23 种设计模式解析附 C++ 实现源码 目 录 0 引言...2 0.1 设计模式解析 ( 总序 )...2 0.2 设计模式解析后记...2 0.3 与作者联系...5 1 创建型模式...5 1.1 Factory 模式...5 1.2 AbstactFactory 模式...11 1.3 Singleton 模式...16 1.4 Builder 模式...18 1.5

More information

IoC容器和Dependency Injection模式.doc

IoC容器和Dependency Injection模式.doc IoC Dependency Injection /Martin Fowler / Java Inversion of Control IoC Dependency Injection Service Locator Java J2EE open source J2EE J2EE web PicoContainer Spring Java Java OO.NET service component

More information

《大话设计模式》第一章

《大话设计模式》第一章 第 1 章 代 码 无 错 就 是 优? 简 单 工 厂 模 式 1.1 面 试 受 挫 小 菜 今 年 计 算 机 专 业 大 四 了, 学 了 不 少 软 件 开 发 方 面 的 东 西, 也 学 着 编 了 些 小 程 序, 踌 躇 满 志, 一 心 要 找 一 个 好 单 位 当 投 递 了 无 数 份 简 历 后, 终 于 收 到 了 一 个 单 位 的 面 试 通 知, 小 菜 欣 喜

More information

Microsoft PowerPoint - ARC110_栾跃.ppt

Microsoft PowerPoint - ARC110_栾跃.ppt ARC110 软 件 构 架 设 计 的 原 则 和 指 南 课 程 内 容 概 述 介 绍 和 引 言 软 件 构 架 和 构 架 师 软 件 构 架 的 设 计 模 式 框 架 和 参 照 设 计 自 我 介 绍 第 一 代 自 费 留 学 生 : 美 国 南 伊 利 诺 州 立 大 学 (SIUE) 电 机 工 程 学 士 (1984) 及 硕 士 学 位 (1985) 历 任 OwensIllinois,

More information

<4D6963726F736F667420506F776572506F696E74202D20332D322E432B2BC3E6CFF2B6D4CFF3B3CCD0F2C9E8BCC6A1AAD6D8D4D8A1A2BCCCB3D0A1A2B6E0CCACBACDBEDBBACF2E707074>

<4D6963726F736F667420506F776572506F696E74202D20332D322E432B2BC3E6CFF2B6D4CFF3B3CCD0F2C9E8BCC6A1AAD6D8D4D8A1A2BCCCB3D0A1A2B6E0CCACBACDBEDBBACF2E707074> 程 序 设 计 实 习 INFO130048 3-2.C++ 面 向 对 象 程 序 设 计 重 载 继 承 多 态 和 聚 合 复 旦 大 学 计 算 机 科 学 与 工 程 系 彭 鑫 pengxin@fudan.edu.cn 内 容 摘 要 方 法 重 载 类 的 继 承 对 象 引 用 和 拷 贝 构 造 函 数 虚 函 数 和 多 态 性 类 的 聚 集 复 旦 大 学 计 算 机 科 学

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

01-场景节点.doc

01-场景节点.doc OpenSceneGraph 场景节点 一 OSG 场景节点简介及组合模式介绍 OSG 中的场景是树形结构表示的层次结构, 如下图所示 : Figure 1.1 OpenSceneGraph 场景树形层次结构 根据其源码中的注释得知,OSG 中场景节点的管理采用了组合 (Composite) 模式 先简要 介绍一下组合模式, 其类图为 : Figure 1.2 Composite Pattern's

More information

mvc

mvc Build an application Tutor : Michael Pan Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist - UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication

More information

1.ai

1.ai HDMI camera ARTRAY CO,. LTD Introduction Thank you for purchasing the ARTCAM HDMI camera series. This manual shows the direction how to use the viewer software. Please refer other instructions or contact

More information

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入 100 年 特 種 考 試 地 方 政 府 公 務 人 員 考 試 試 題 等 別 : 三 等 考 試 類 科 : 資 訊 處 理 科 目 : 系 統 分 析 與 設 計 一 請 參 考 下 列 旅 館 管 理 系 統 的 使 用 案 例 圖 (Use Case Diagram) 撰 寫 預 約 房 間 的 使 用 案 例 規 格 書 (Use Case Specification), 繪 出 入

More information

untitled

untitled 1 行 行 行 行.NET 行 行 類 來 行 行 Thread 類 行 System.Threading 來 類 Thread 類 (1) public Thread(ThreadStart start ); Name 行 IsAlive 行 行狀 Start 行 行 Suspend 行 Resume 行 行 Thread 類 (2) Sleep 行 CurrentThread 行 ThreadStart

More information

Olav Lundström MicroSCADA Pro Marketing & Sales 2005 ABB - 1-1MRS755673

Olav Lundström MicroSCADA Pro Marketing & Sales 2005 ABB - 1-1MRS755673 Olav Lundström MicroSCADA Pro Marketing & Sales 2005 ABB - 1 - Contents MicroSCADA Pro Portal Marketing and sales Ordering MicroSCADA Pro Partners Club 2005 ABB - 2 - MicroSCADA Pro - Portal Imagine that

More information

Kubenetes 系列列公开课 2 每周四晚 8 点档 1. Kubernetes 初探 2. 上 手 Kubernetes 3. Kubernetes 的资源调度 4. Kubernetes 的运 行行时 5. Kubernetes 的 网络管理理 6. Kubernetes 的存储管理理 7.

Kubenetes 系列列公开课 2 每周四晚 8 点档 1. Kubernetes 初探 2. 上 手 Kubernetes 3. Kubernetes 的资源调度 4. Kubernetes 的运 行行时 5. Kubernetes 的 网络管理理 6. Kubernetes 的存储管理理 7. Kubernetes 包管理理 工具 Helm 蔺礼强 Kubenetes 系列列公开课 2 每周四晚 8 点档 1. Kubernetes 初探 2. 上 手 Kubernetes 3. Kubernetes 的资源调度 4. Kubernetes 的运 行行时 5. Kubernetes 的 网络管理理 6. Kubernetes 的存储管理理 7. Kubernetes

More information

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

More information

USPTO Academic research Corporate needs Global/International Inventors Libraries News Media/Publication Patent Attorney or Agent USPTO e (ebusiness Ce

USPTO Academic research Corporate needs Global/International Inventors Libraries News Media/Publication Patent Attorney or Agent USPTO e (ebusiness Ce I 2002.03.27 2 http://www.uspto.gov/ http://www.wipo.org/ http://ipdl.wipo.int/ esp@cenet http://www.european-patent-office.org/ http://ep.espacenet.com/ http://www.cpo.cn.net/ 3 4 USPTO USPTO First time

More information

Microsoft Word - Learn Objective-C.doc

Microsoft Word - Learn Objective-C.doc Learn Objective C http://cocoadevcentral.com/d/learn_objectivec/ Objective C Objective C Mac C Objective CC C Scott Stevenson [object method]; [object methodwithinput:input]; output = [object methodwithoutput];

More information

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

KillTest 质量更高 服务更好 学习资料   半年免费更新服务 KillTest 质量更高 服务更好 学习资料 http://www.killtest.cn 半年免费更新服务 Exam : 70-536Chinese(C++) Title : TS:MS.NET Framework 2.0-Application Develop Foundation Version : DEMO 1 / 10 1. Exception A. Data B. Message C.

More information

CHAPTER 1

CHAPTER 1 CHAPTER 1 1-1 System Development Life Cycle; SDLC SDLC Waterfall Model Shelly 1995 1. Preliminary Investigation 2. System Analysis 3. System Design 4. System Development 5. System Implementation and Evaluation

More information

Microsoft PowerPoint - Lecture7II.ppt

Microsoft PowerPoint - Lecture7II.ppt Lecture 8II SUDOKU PUZZLE SUDOKU New Play Check 軟體實作與計算實驗 1 4x4 Sudoku row column 3 2 } 4 } block 1 4 軟體實作與計算實驗 2 Sudoku Puzzle Numbers in the puzzle belong {1,2,3,4} Constraints Each column must contain

More information

Strings

Strings Inheritance Cheng-Chin Chiang Relationships among Classes A 類 別 使 用 B 類 別 學 生 使 用 手 機 傳 遞 訊 息 公 司 使 用 金 庫 儲 存 重 要 文 件 人 類 使 用 交 通 工 具 旅 行 A 類 別 中 有 B 類 別 汽 車 有 輪 子 三 角 形 有 三 個 頂 點 電 腦 內 有 中 央 處 理 單 元 A

More information

<4D6963726F736F667420506F776572506F696E74202D20C8EDBCFEBCDCB9B9CAA6D1D0D0DEBDB2D7F92E707074>

<4D6963726F736F667420506F776572506F696E74202D20C8EDBCFEBCDCB9B9CAA6D1D0D0DEBDB2D7F92E707074> 软 件 架 构 师 研 修 讲 座 胡 协 刚 软 件 架 构 师 UML/RUP 专 家 szjinco@public.szptt.net.cn 中 国 软 件 架 构 师 网 东 软 培 训 中 心 小 故 事 : 七 人 分 粥 当 前 软 件 团 队 的 开 发 现 状 和 面 临 的 问 题 软 件 项 目 的 特 点 解 决 之 道 : 从 瀑 布 模 型 到 迭 代 模 型 解 决 项

More information

chap07.key

chap07.key #include void two(); void three(); int main() printf("i'm in main.\n"); two(); return 0; void two() printf("i'm in two.\n"); three(); void three() printf("i'm in three.\n"); void, int 标识符逗号分隔,

More information

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco Windows RTEMS 1 Danilliu MMI TCP/IP 80486 QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos ecos Email www.rtems.com RTEMS ecos RTEMS RTEMS Windows

More information

9, : Java 19., [4 ]. 3 Apla2Java Apla PAR,Apla2Java Apla Java.,Apla,,, 1. 1 Apla Apla A[J ] Get elem (set A) A J A B Intersection(set A,set B) A B A B

9, : Java 19., [4 ]. 3 Apla2Java Apla PAR,Apla2Java Apla Java.,Apla,,, 1. 1 Apla Apla A[J ] Get elem (set A) A J A B Intersection(set A,set B) A B A B 25 9 2008 9 M ICROEL ECTRON ICS & COMPU TER Vol. 25 No. 9 September 2008 J ava 1,2, 1,2, 1,2 (1, 330022 ; 2, 330022) :,. Apla - Java,,.. : PAR ;Apla - Java ; ;CMP ; : TP311 : A : 1000-7180 (2008) 09-0018

More information

INTRODUCTION TO COM.DOC

INTRODUCTION TO COM.DOC How About COM & ActiveX Control With Visual C++ 6.0 Author: Curtis CHOU mahler@ms16.hinet.net This document can be freely release and distribute without modify. ACTIVEX CONTROLS... 3 ACTIVEX... 3 MFC ACTIVEX

More information

untitled

untitled OGRE http://antsam.blogone.net AntsamCGD@hotmail.com OGRE OGRE listener listener target listener target Dispatcher Processor Input Reader Event class view Event Class view Input Event ctrlaltshift ascoll

More information

SL2511 SR Plus 操作手冊_單面.doc

SL2511 SR Plus 操作手冊_單面.doc IEEE 802.11b SL-2511 SR Plus SENAO INTERNATIONAL CO., LTD www.senao.com - 1 - - 2 - .5 1-1...5 1-2...6 1-3...6 1-4...7.9 2-1...9 2-2 IE...11 SL-2511 SR Plus....13 3-1...13 3-2...14 3-3...15 3-4...16-3

More information

國家圖書館典藏電子全文

國家圖書館典藏電子全文 EAI EAI Middleware EAI 3.1 EAI EAI Client/Server Internet,www,Jav a 3.1 EAI Message Brokers -Data Transformation Business Rule XML XML 37 3.1 XML XML XML EAI XML 1. XML XML Java Script VB Script Active

More information

Guava学习之Resources

Guava学习之Resources Resources 提供提供操作 classpath 路径下所有资源的方法 除非另有说明, 否则类中所有方法的参数都不能为 null 虽然有些方法的参数是 URL 类型的, 但是这些方法实现通常不是以 HTTP 完成的 ; 同时这些资源也非 classpath 路径下的 下面两个函数都是根据资源的名称得到其绝对路径, 从函数里面可以看出,Resources 类中的 getresource 函数都是基于

More information

untitled

untitled 1 MSDN Library MSDN Library 量 例 參 列 [ 說 ] [] [ 索 ] [] 來 MSDN Library 了 類 類 利 F1 http://msdn.microsoft.com/library/ http://msdn.microsoft.com/library/cht/ Object object 參 類 都 object 參 object Boxing 參 boxing

More information

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

KillTest 质量更高 服务更好 学习资料   半年免费更新服务 KillTest 质量更高 服务更好 学习资料 http://www.killtest.cn 半年免费更新服务 Exam : 310-065Big5 Title : Sun Certified Programmer for the Java 2 Platform, SE 6.0 Version : Demo 1 / 14 1. 35. String #name = "Jane Doe"; 36. int

More information

提纲 1 2 OS Examples for 3

提纲 1 2 OS Examples for 3 第 4 章 Threads2( 线程 2) 中国科学技术大学计算机学院 October 28, 2009 提纲 1 2 OS Examples for 3 Outline 1 2 OS Examples for 3 Windows XP Threads I An Windows XP application runs as a seperate process, and each process may

More information

WTO

WTO 10384 X0115018 UDC MBA 2004 5 14 2004 6 1 WTO 2004 2006 7 2 Abstract According to the promise after our country enter into WTO, our country will open the readymade oil retail market in the end of 2004

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

More information

2007

2007 2007 年 上 半 年 软 件 评 测 师 考 试 浅 析 作 者 : 陈 嘉 祥 方 耀 公 司 : 广 东 亿 迅 科 技 有 限 公 司 ( 质 量 管 理 部 ) 1 简 介 1.1 目 的 本 文 章 主 要 介 绍 软 件 评 测 师 考 试 的 范 围 内 容 以 及 其 重 要 性, 还 有 相 关 的 试 题 分 析 1.2 适 用 范 围 有 意 参 与 或 将 来 有 意 参

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM CHAPTER 6 SQL SQL SQL 6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM 3. 1986 10 ANSI SQL ANSI X3. 135-1986

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

IP505SM_manual_cn.doc

IP505SM_manual_cn.doc IP505SM 1 Introduction 1...4...4...4...5 LAN...5...5...6...6...7 LED...7...7 2...9...9...9 3...11...11...12...12...12...14...18 LAN...19 DHCP...20...21 4 PC...22...22 Windows...22 TCP/IP -...22 TCP/IP

More information

Software Engineering 5.

Software Engineering 5. Software Engineering 5. 目录 Contents 5.1 5.2 5.3 Page. 3 软件体系结构包括一组软件部件 软件部件的外部的可见特性及其相互关系, 其中软件外部的可见特性是指软件部件提供的服务 性能 特性 错误处理 共享资源使用等 系统的总体组织结构和全局控制结构 通信 同步和数据访问的协议 设计元素的组成与功能分配 非功能需求 系统的物理部署 备选设计方案的选择

More information

(procedure-oriented)?? 2

(procedure-oriented)?? 2 1 (procedure-oriented)?? 2 (Objected-Oriented) (class)? (method)? 3 : ( 4 ???? 5 OO 1966 Kisten Nygaard Ole-Johan Dahl Simula Simula 爲 6 Smalltalk Alan Kay 1972 PARC Smalltalk Smalltalk 爲 Smalltalk 爲 Smalltalk

More information

Guide to Install SATA Hard Disks

Guide to Install SATA Hard Disks SATA RAID 1. SATA. 2 1.1 SATA. 2 1.2 SATA 2 2. RAID (RAID 0 / RAID 1 / JBOD).. 4 2.1 RAID. 4 2.2 RAID 5 2.3 RAID 0 6 2.4 RAID 1.. 10 2.5 JBOD.. 16 3. Windows 2000 / Windows XP 20 1. SATA 1.1 SATA Serial

More information

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 Java V1.0.1 2007 4 10 1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 6.2.10 6.3..10 6.4 11 7.12 7.1

More information