
UML&GOF Patterns
xmuzyu
这个作者很懒,什么都没留下…
展开
-
工厂模式(Factory pattern)
工厂模式其实主要就是用来为我们创建对象用的。工厂模式分为工厂方法模式和抽象工厂模式。如果我们在程序中要用到一个类,而这个类与其他类关系不是很紧密,那么我就可以考虑用工厂方法模式来解决。如果程序中用到的几个类之间有一定的联系时,我们可以考虑用抽象工厂模式,就好比一个工厂可以生产不同的有一定联系的产品一样。假如我们现在要创建Product类,当然我们可以直接用new Product( param...2007-08-15 02:07:39 · 111 阅读 · 0 评论 -
Head first design patterns(Adapter pattern )
Recently,I have been reading the Head first design patterns,unconsciously,i have finish the seven chapters.and here i will review the whati just read tonight. Tonight,i read the seventh chapter ...2007-12-20 01:06:45 · 145 阅读 · 0 评论 -
One note of Head first design pattern(Command pattern)
I read the sixth chapter of Head first design pattern a few days ago.I want to review it at the present. First,here is the official definition.The commond pattern enscuplates a request as a obj...2007-12-09 23:36:22 · 128 阅读 · 0 评论 -
one note of Head first design patterns(singleton pattern)
I read the singleto pattern with the head first design pattern yestarday evening.i will review it . First of all ,we should konw about the offical definition of the pattern,here is it .the sin...2007-11-22 21:47:51 · 111 阅读 · 0 评论 -
one note of Head first design patterns(factory pattern)
I read the chapter 4 of head first design pattern just now.I just sum up my thought about the factory pattern. The factory pattern contains three pattern in general.here are they.the first is s...2007-11-21 00:25:28 · 143 阅读 · 0 评论 -
one note of Head first design patterns(Decorator pattern)
I read the chapter three of head first design patterns yesterday,this chapter tell us how to use decorator pattern.here is the defination of this pattern: The decorator pattern attaches additi...2007-11-01 22:15:33 · 122 阅读 · 0 评论 -
GRASP模式
GRASP是通用职责分配软件模式(General Responsibility Assignment Software patterns)的简称。它包含了9大模式,分别如下所示: 1 创建者(Creator) :决定对象应该有谁来创建的问题。一般情况下是包含类创建被包含的类。 2 信息专家(Information expert):用此模式来确定如何给对象分配职...2007-10-29 22:32:57 · 178 阅读 · 0 评论 -
One onte of Head first design patterns(Observer pattern)
I read the chapter two of Head first design pattern just now,next ,i will just make a record. This chapter tells us how to use the observer pattern.after read it ,i realized that theobserv...2007-10-27 01:06:20 · 163 阅读 · 0 评论 -
One Note of Head first design patterns (Strategy pattern)
Today ,I read the chapter one of the Head first design pattern,and i found the book was a exicting book.now i just want to sum it up. The chapter one tell us a pattern called Strategy patt...2007-10-23 22:02:43 · 141 阅读 · 0 评论 -
composition and inheritance
在面向对象的设计中,我们经常会用到组合和继承。我们只有合理的运用这两种机制,才能使的我们的系统更具有可维护和可复用性。在具体的设计中,要遵循一些设计原则 ,比如要把变化的东西和不变的东西分开,不要将他们混合在一起。面向抽象,接口编程 ,以及组合优于继承等。其实至于继承和组合各有各的优点和缺点。对于继承来说,主要是为了实现多态的,而对于组合来说关键就是用来将变化的东西从继承体系...2007-10-20 00:22:47 · 126 阅读 · 0 评论 -
依赖倒装原则(面向对象的设计原则之一)(DIP)
依赖倒装原则是面向对象设计的很重要的原则之一。这个原则要求:具体应该依赖于抽象,而不是抽象依赖于具体。只有我们做到了具体依赖与抽象,这样的系统才可以是可维护,可复用的。传统的复用仅仅只是限于对具体层次的复用,比如对算法,数据结构,或者对某一个小的模块的复用。但是在当今面向对象的设计理念里,复用要向更高一个层次。要复用抽象的东西,也就是复用不容易变化的东西。像现在的面向接口...2007-10-13 16:39:09 · 448 阅读 · 0 评论 -
设计模式之单例模式
单例模式是一中常见的设计模式,使用它要满足以下条件:第一 : 系统中只要求有一个实例。第二 : 这个实例必须有单例类自己提供。在JAVA中的单例设计模式有两种形式:可分为饿汉式单例和懒汉式单例。 1 饿汉式单例java 代码 public class Singlon{ private static Singlon instanc...2007-10-10 22:01:25 · 95 阅读 · 0 评论 -
里氏代换原则(LSP)
里氏代换原则要求任何基类能出现的地方,子类都可以出现。换句话说也就是子类可以 完全替代基类。当我们在继承复用的时侯应该好好考虑这一原则,它对设计出面向对象的系统有很大的好处。 在JAVA语言中提供了继承机制。当我们要从一个基类继承的时候,我们不能改变被覆盖 (重写)方法的可见性。编译器强制要求我们这么做。而这么做的好处,也可以说是原因就 是我们可以符合...2007-10-08 20:37:34 · 138 阅读 · 0 评论 -
开闭原则(面向对象设计原则之一)
面向对象的设计原则:第一 : 开闭原则第二 :里氏代换原则第三 :依赖倒转原则第四 :迪米特法则 开闭原则:一个系统要对扩展开放,而对修改关闭。这里的所指的意思就是在不修改以前已经写好的代码或者尽量不改的情况下来扩展系统的功能。 如何做到开闭原则: 第一 : 我们就要对系统进行分析,抽象出最本质的东西。抽象的越深,系统的可扩展性就越好。在当今主流软件...2007-10-07 22:13:18 · 251 阅读 · 0 评论 -
设计模式之 ProtoType模式
ProtoType属于创建模式,所以当我们需要创建对象的时候可以考虑使用它,尤其是在程序中动态加载类时。在JAVA语言中是用克隆机制来实现的。此模式也是充分运用了OO语言的多态性,我们在创建对象时只与基类打交道,也就是只与我们打算创建的对象打交道。比如我们打算创建汽车,而我们又不想知道汽车是怎么创建的,我们就可以采用此模式。public abstract class Car implement...2007-08-20 21:01:41 · 108 阅读 · 0 评论 -
设计模式之Builder模式
Builder模式也属于一种创建模式,它主要用来产生比较复杂的对象。假如我们现在有一个很复杂的对象,它有好多部件组成,如果我们用new在构造器中构建的话,这样代码的耦合度很高,不能实现解耦的目的。这就要求我们将各个部件的生产和各个部件的组装分开来做。就好比生产一台电脑,一些部门专门负责生产各种的部件(CPU,显示卡,声卡,硬盘,显示器等),另外一些部门负责组装这些部件。就好比买个组装电脑...2007-08-17 19:16:34 · 113 阅读 · 0 评论 -
Head first design pattern(State pattern)
[u][/u]I read the State pattern in the Head first design pattern a few days ago,At the present,i will just sum it up. Without state pattern,we just use "if-else" controlling construct to treat ...2008-01-14 17:26:46 · 115 阅读 · 0 评论