
设计模式
qishuangquan
专注.net开发
展开
-
设计模式系列(一)序言
<br />最近谢了个坦克大战的小游戏,快写完了。但是回头一看,代码竟然有点“惨不忍睹”。忽然想起以前幸得一本叫做《大话设计模式》的书。今天翻出来看看。看了第一章,觉得收获颇丰,竟然那么小的计算器程序也可以写出如此精彩的代码。回头看看自己写的代码,更加惨不忍睹。于是乎,我决定要把这本书从头至尾的看完。并记录下关键知识点以备“不时之需”。其实不能叫“不时”,“时时”更贴切一点。好了,话不多说,以上就是序言。原创 2010-11-08 12:49:00 · 516 阅读 · 0 评论 -
大话设计模式读书笔记(一)简单工厂
仅学习使用。转载 2010-11-08 17:50:00 · 722 阅读 · 0 评论 -
大话设计模式读书笔记(二)策略模式
<br />简单工厂实现商场收费<br /><br /> <br />现金收取工厂类(CashFactory):<br />using System;using System.Collections.Generic;using System.Text;namespace 商场管理软件{ //现金收取工厂 class CashFactory { //根据条件返回相应的对象 public static CashSuper cr原创 2010-11-10 13:39:00 · 1247 阅读 · 0 评论 -
Dot Net 设计模式—简单工厂
<br />1.前言<br />1.1概要<br /> 简单工厂的作用是实例化对象,而不需要客户了解这个对象属于哪个具体的子类。<br /> 在GOF的设计模式中并没有简单工厂,而是将其作为工厂方法的一个特例加以解释。可以这样理解,简单工厂是参数化的工厂方法。<br />1.2使用场合<br /> 简单工厂实例化的类具有相同的接口,类类有限并且基本不需要扩展时,可以使用简单工厂。例如,数据库连接对象,常用的数据库类类可以预知,则使用简单工厂。<br />1.3效转载 2010-11-08 17:54:00 · 735 阅读 · 0 评论 -
大话设计模式读书笔记(六)
工厂方法计算器结构图:工厂方法计算器代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 工厂模式{ class Program { static void Main(string[] args) { IFactory operFactory = new AddFact转载 2010-11-12 09:38:00 · 1039 阅读 · 0 评论 -
大话设计模式(五)代理模式
<br />代理模式(Proxy),为其他对象提供一种代理以控制对这个对象的访问。<br /><br /> <br /> <br />代理模式基本代码:<br />using System;using System.Collections.Generic;using System.Text;namespace 代理模式{ class Program { static void Main(string[] args) {转载 2010-11-11 17:32:00 · 1014 阅读 · 0 评论 -
大话设计模式读书笔记(三)策略模式
<br />策略模式实现商场收费:<br />策略模式基本代码<br />using System;using System.Collections.Generic;using System.Text;namespace 策略模式{ class Program { static void Main(string[] args) { Context context; contex原创 2010-11-11 12:07:00 · 1242 阅读 · 0 评论 -
大话设计模式(四)装饰模式
<br />装饰模式结构图:<br /><br /> <br />装饰模式基本代码:<br />using System;using System.Collections.Generic;using System.Text;namespace 装饰模式{ class Program { static void Main(string[] args) { ConcreteComponent c = new C原创 2010-11-11 12:18:00 · 974 阅读 · 0 评论