2008-01-14

Head first design pattern(State 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 with the change of the object state,as this,the coupling is very high,when the requirment changes, we ...
2007-12-20

Head first design patterns(Adapter pattern )

关键字: adapter and facade 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 of my love book at the schoollibrary.this chapter tells us about the Adapter and facade pattern,i fel ...
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 object ,thereby letting you parameterized other objects with the different requests,and support the undo ...
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 singleto ensures that a class has only one instance, and ...
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 simple factory,the second is factory method pattern ,and the last is ...
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 additional responsibilities to  an object  dynami ...
2007-10-29

GRASP模式

关键字: GRASP模式
GRASP是通用职责分配软件模式(General Responsibility Assignment Software patterns)的简称。它包含了9大 模式,分别如下所示:         1  创建者(Creator) :决定对象应该有谁来创建的问题。一般情况下是包含类创建被包含的类。         2  信息专家(Information expert):用此模式来确定如何给对象分配职责的问题。一般把职责分配 ...
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   the observer pattern is very important and usefull to ...
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 pattern,Frist of all ,we should   kno ...
2007-10-20

composition and inheritance

关键字: 设计技巧
       在面向对象的设计中,我们经常会用到组合和继承。我们只有合理的运用这两种机制, 才能使的我们的系统更具有可维护和可复用性。在具体的设计中,要遵循一些设计原则 , 比如要把变化的东西和不变的东西分开,不要将他们混合在一起。面向抽象,接口编程 , 以及组合优于继承等。其实至于继承和组合各有各的优点和缺点。对于继承来说,主要是 为了实现多态的,而对于组合来说关键就是用来将变化的东西从继承体系中移出出去,在 另外的类中实现变化的东西。这样我们就不会因为变化的部分而影响到了我们不变的部分 了。
2007-10-13

依赖倒装原则(面向对象的设计原则之一)(DIP)

关键字: 面向对象的设计原则
       依赖倒装原则是面向对象设计的很重要的原则之一。这个原则要求: 具体应该依赖于抽象,而不是抽象依赖于具体。只有我们做到了具体依 赖与抽象,这样的系统才可以是可维护,可复用的。传统的复用仅仅只 是限于对具体层次的复用,比如对算法,数据结构,或者对某一个小的 模块的复用。但是在当今面向对象的设计理念里,复用要向更高一个层 次。要复用抽象的东西,也就是复用不容易变化的东西。像现在的面向 接口编程,面向抽象编程等等,都是一种对依赖倒装原则的运用。我们 只有抽象出不变的东西,才能把握住系统的重点。这样到了具体 ...
2007-10-10

设计模式之单例模式

关键字: 创建模式
单例模式是一中常见的设计模式,使用它要满足以下条件: 第一 : 系统中只要求有一个实例。 第二 : 这个实例必须有单例类自己提供。 在JAVA中的单例设计模式有两种形式:可分为饿汉式单例和懒汉式单例。  1 饿汉式单例 java 代码 public class Singlon{                private static Singlon instan ...
2007-10-08

里氏代换原则(LSP)

关键字: 设计原则
         里氏代换原则要求任何基类能出现的地方,子类都可以出现。换句话说也就是子类可以  完全替代基类。当我们在继承复用的时侯应该好好考虑这一原则,它对设计出面向对象的系 统有很大的好处。          在JAVA语言中提供了继承机制。当我们要从一个基类继承的时候,我们不能改变被覆盖   (重写)方法的可见性。编译器强制要求我们这么做。而这么做的好处,也可以说是原因就  是我们可以符合 ...
面向对象的设计原则: 第一 : 开闭原则 第二 :里氏代换原则 第三 :依赖倒转原则 第四 :迪米特法则        开闭原则:一个系统要对扩展开放,而对修改关闭。这里的所指的意思就是在不修改以前已经写好的代码或者尽量不改的情况下来扩展系统的功能。       如何做到开闭原则:        第一 : 我们就要对系统进行分析,抽象出最本质的东西。抽象的越深,系统的可扩展性就越好。在当今主流软件开发平台(J2E ...
2007-08-20

设计模式之 ProtoType模式

关键字: 创建模式
ProtoType属于创建模式,所以当我们需要创建对象的时候可以考虑使用它,尤其是在程序中动态加载类时。在JAVA语言中是用克隆机制来实现的。此模式也是充分运用了OO语言的多态性,我们在创建对象时只与基类打交道,也就是只与我们打算创建的对象打交道。比如我们打算创建汽车,而我们又不想知道汽车是怎么创建的,我们就可以采用此模式。 public abstract class Car implements Cloneable{      public abstract  Car cloneCar(){    &n ...
2007-08-17

设计模式之Builder模式

关键字: 创建模式
Builder模式也属于一种创建模式,它主要用来产生比较复杂的对象。假如我们现在有 一个很复杂的对象,它有好多部件组成,如果我们用new在构造器中构建的话,这样 代码的耦合度很高,不能实现解耦的目的。这就要求我们将各个部件的生产和各个部 件的组装分开来做。就好比生产一台电脑,一些部门专门负责生产各种的部件(CPU, 显示卡,声卡,硬盘,显示器等),另外一些部门负责组装这些部件。就好比买个组 装电脑。要实现Builder模式,我们需要借助几个类来实现: public abstract class Builder{      &nbs ...
2007-08-15

工厂模式(Factory pattern)

关键字: 创建模式
工厂模式其实主要就是用来为我们创建对象用的。工厂模式分为工厂方法模式和抽象工厂模式。如果我们在程序中要用 到一个类,而这个类与其他类关系不是很紧密,那么我就可以考虑用工厂方法模式来解决。如果程序中用到的几个类之间 有一定的联系时,我们可以考虑用抽象工厂模式,就好比一个工厂可以生产不同的有一定联系的产品一样。 假如我们现在要创建Product类,当然我们可以直接用new Product( parameter )来创建。但是如果我们能把这个创建任务 交给一个方法,我们创建的时候之要告诉这个方法,我要创建这个类,然后这个方法就可以去给我创建了,至于具体怎么 创建的,我们不管,这也体现了封装 ...
狂放不羁
  • 浏览: 72518 次
  • 性别: Icon_minigender_1
  • 来自: 厦门大学
  • 详细资料
搜索本博客
我的相册
E980bbdc-37d2-46cd-b0ba-38638405a1b7-thumb
Head first design patterns
共 29 张
存档
最新评论