摘要: 概述: 提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类。模型图: 代码二个抽象接口:internalinterfaceFemaleShoes{StringName{get;set;}StringStyle{get;set;}voidDisplay();}internalinterfaceFemaleClothes{StringName{get;set;}StringCode{get;set;}voidDisplay();}具体实现类:internalclassFemaleClothShoes:FemaleShoes{privateStringname="布鞋&qu 阅读全文
posted @ 2012-01-18 18:08 Nopcn 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 概述 简单工厂存在着不少的缺点,工厂类就违反了“对扩展开放、对修改关闭”的原则。而工厂方法可以克服简单工厂的缺点。工厂方法通过定义一个用户创建对象的接口,让子类决定实例化哪一个类。Factory Method使一个类的实例化延迟到其子类。实现例子:产品接口:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleFactoryMethodDemo{internalinterfaceFemaleClothes{StringName{get;set;}Strin... 阅读全文
posted @ 2012-01-18 15:56 Nopcn 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 概述: 简单工厂,通过具体工厂类、抽象产品、具体产品类设计,封装具体产品。实现如下具体代码实现:接口(产品): internalinterfaceClothes{StringName{get;set;}StringCode{get;set;}voidDisplay(); }具体产品A:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleSimpleFactoryDemo{internalclassFemaleShirtClothes:Clothes{... 阅读全文
posted @ 2012-01-18 11:30 Nopcn 阅读(286) 评论(0) 推荐(0) 编辑