[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 will have to change a lot of code.Fortunately,we could use the state pattern to low the coupling.
Here is the offical defination,the state pattern allows an object to alter its behavior when its internal state changes.it use a state object to encapsulate the object's behavior.the state pattern encapsulate the altering parts to seperate the steady parts with them.
this pattern need state object to alter its behavior.the state object konw how to change to another state,what'more ,the state object contains the behavior with the state,so we can use the polymorphism to
change the behavior dynamicly
分享到:
相关推荐
Head First Design Pattern
深入浅出设计模式 (Head First Design Pattern)_带书签 深入浅出设计模式 (Head First Design Pattern)_带书签
headfirst design pattern C++ code
比现在csdn上的headfirst design pattern要清晰得多
Head First design pattern(中文版).part4.rar
Head First design pattern(中文版).part7.rar
著名的《Head First Design Pattern》学习笔记,摘要这本书中的设计思路。由于书本过长,整理出笔记帮助回想起设计模式。文件是docx格式,只能由OFFICE Word 2007之后的版本打开,内附Visio类图文件。本文由个人整理...
Head First design pattern(中文版).part6.rar
Head First Design Patterns 中文版 带目录 设计模式经典书籍
又名: Head First Design Patterns 作者: (美)弗里曼(Freeman,E.) 副标题: Head First Design Patterns 简介 ······ 你不想重新发明车轮(或者更差的是,没有充气车胎的轮子),所以你从设计模式中寻求...
本书是Head First design pattern的非扫描版 原生版 用java语言写的,非常的棒,希望大家喜欢。
head first design pattern(chinese version) 1 what is the design pattern 2 why to use 3 how to use 4 questions when use,and how to resolve 5 funny when reading
如果你曾经读过任何一本深入浅出(Head First)系列书籍, 你就会知道能够从本书中得到的是:透过丰富的视觉效果让你的大脑充分地运作。本书的编写运用许多最新的研究,包括神经生物学、认知科学以及学习理论, 这...
Head First design pattern(中文版).part5.rar
Head First design pattern(中文版).part1.rar
注意本书可是Head First design pattern的非扫描版 原生版 用java语言写的,非常的棒,希望大家喜欢
很好的一本设计模式教程,形象易懂。很多抽象的设计模式概念在书中只用一个生动的例子就讲清楚了。不可多得,不可错过。
Observer HeadFirst design pattern C++ version