设计模式公司荣誉出品?
您的设计模式?
我们的设计模式?
?
CBF4LIFE?
2009年5月?
?
?
?
我希望这本书的阅读者具备最基本的代码编写能力,您是一个初级的coder,可以从中领会到怎么设计一段优秀的代码;您是一个高级程序员,可以从中全面了解到设计模式以及Java的边角技术的使用;您是一个顶级的系统分析师,可以从中获得共鸣,寻找到项目公共问题的解决办法,呀,是不是把牛吹大了?!?
?
目????录?
?
第?1?章?
第?2?章?
第?3?章?
第?4?章?
第?5?章?
第?6?章?
第?7?章?
第?8?章?
第?9?章?策略模式【STRATEGY?PATTERN】?..........................................................................................................?4?代理模式【PROXY?PATTERN】?...............................................................................................................?8?单例模式【SINGLETON?PATTERN】?......................................................................................................?12?多例模式【MULTITION?PATTERN】?......................................................................................................?16?工厂方法模式【FACTORY?METHOD?PATTERN】?...................................................................................?19?抽象工厂模式【ABSTRACT?FACTORY?PATTERN】?.................................................................................?31?门面模式【FACADE?PATTERN】?...........................................................................................................?44?适配器模式【ADAPTER?PATTERN】?.....................................................................................................?51?模板方法模式【TEMPLATE?METHOD?PATTERN】?.................................................................................?63?第?10?章?建造者模式【BUILDER?PATTERN】?......................................................................................................?82?第?11?章?桥梁模式【BRIDGE?PATTERN】?............................................................................................................?97?第?12?章?命令模式【COMMAND?PATTERN】?...................................................................................................?112?第?13?章?装饰模式【DECORATOR?PATTERN】?..................................................................................................?126?第?14?章?迭代器模式【ITERATOR?PATTERN】?..................................................................................................?137?第?15?章?组合模式【COMPOSITE?PATTERN】?...................................................................................................?147?第?16?章?观察者模式【OBSERVER?PATTERN】?.................................................................................................?175?第?17?章?责任链模式【CHAIN?OF?RESPONSIBILITY?PATTERN】?.........................................................................?194?第?18?章?访问者模式【VISITOR?PATTERN】?.....................................................................................................?210?第?19?章?状态模式【STATE?PATTERN】?............................................................................................................?236?第?20?章?原型模式【PROTOTYPE?PATTERN】?...................................................................................................?255?第?21?章?中介者模式【MEDIATOR?PATTERN】?.................................................................................................?268?第?22?章?解释器模式【INTERPRETER?PATTERN】?.............................................................................................?286?第?23?章?亨元模式【FLYWEIGHT?PATTERN】?....................................................................................................?298?第?24?章?备忘录模式【MEMENTO?PATTERN】?.................................................................................................?299?第?25?章?模式大PK?...........................................................................................................................................?300?第?26?章?六大设计原则?....................................................................................................................................?301?26.1?
26.2?单一职责原则【SINGLE?RESPONSIBILITY?PRINCIPLE】?............................................................................................?301?里氏替换原则【LISKOV?SUBSTITUTION?PRINCIPLE】?..............................................................................................?308?
26.3?依赖倒置原则【DEPENDENCE?
?
INVERSION?PRINCIPLE】?.....................................................................................................................................................?320?26.4?
26.5?
26.6?接口隔离原则【INTERFACE?SEGREGATION?PRINCIPLE】?..........................................................................................?321?迪米特法则【LOW?OF?DEMETER】?.....................................................................................................................?331?开闭原则【OPEN?CLOSE?PRINCIPLE】?..................................................................................................................?341?
混编模式讲解?....................................................................................................................................?358?第?27?章?
第?28?章?更新记录:?.......................................................................................................................................?360?相关说明?...............................................................................................................................................................?361?相关说明?...............................................................................................................................................................?361?第?29?章?后序?...................................................................................................................................................?362??
?
第?1?章 策略模式【Strategy?Pattern】?
刘备要到江东娶老婆了,走之前诸葛亮给赵云(伴郎)三个锦囊妙计,说是按天机拆开解决棘手问题,嘿,还别说,真是解决了大问题,搞到最后是周瑜陪了夫人又折兵呀,那咱们先看看这个场景是什么样子的。
先说这个场景中的要素:三个妙计,一个锦囊,一个赵云,妙计是小亮同志给的,妙计是放置在锦囊里,俗称就是锦囊妙计嘛,那赵云就是一个干活的人,从锦囊中取出妙计,执行,然后获胜,用JAVA程序
怎么表现这个呢?我们先看类图:
?
三个妙计是同一类型的东东,那咱就写个接口: