作者: Elisabeth Freeman / Eric Freeman / Bert Bates / Kathy Sierra / Elisabeth Robson
出版社: O'Reilly Media
出版年: 2004-11-1
页数: 688
定价: USD 49.99
装帧: Paperback
丛书: Head First
ISBN: 9780596007126
出版社: O'Reilly Media
出版年: 2004-11-1
页数: 688
定价: USD 49.99
装帧: Paperback
丛书: Head First
ISBN: 9780596007126
豆瓣成员常用的标签(共82个) · · · · · ·
喜欢读"Head First Design Patterns"的人也喜欢 · · · · · ·
按有用程度 按页码先后 最新笔记
-
第1页
《head first 设计模式》笔记 提纲: 一、各章节中出现的模式 二、剩下的模式 三、分类 四、OO原则 五、OO基础 六、其他 一、各章节中出现的模式: 1.装饰者 Decorator 包装一个对象,以提供新的行为。 动态地将责任附加到对象上。想要扩展功能,装饰者提供了有别于继承的另一种选择。 实例:星巴克的各种咖啡。 2.状态 state 封装了基于状态的行为,并使用委托在行为之间切换。 ... (更多)《head first 设计模式》笔记提纲:一、各章节中出现的模式二、剩下的模式三、分类四、OO原则五、OO基础六、其他一、各章节中出现的模式:1.装饰者 Decorator包装一个对象,以提供新的行为。动态地将责任附加到对象上。想要扩展功能,装饰者提供了有别于继承的另一种选择。实例:星巴克的各种咖啡。2.状态 state封装了基于状态的行为,并使用委托在行为之间切换。允许对象在内部状态改变时改变它的行为,对像看起来好像改变了它的类。实例:糖果机3.迭代器 Iterator在对象的集合中游走,而不暴露集合的实现。提供一种方法顺序访问一个聚合对象中的各个元素,而又不暴露其内部的表示。实例:两家店的菜单合并(遍历数组,ArrayList)。4.组合 Composite客户用一致的方法处理对象集合和单个对象。允许你将对象组成树形结构来表现 “整体/部分”的层次结构。组合能让客户以一致的方式处理个别对象和对象组合。实例:两家店的菜单合并,午餐菜单中加入甜点菜单。 mvc中视图的层级架构5.外观 Facade简化一群类的接口。提供了一个统一的接口,用来访问子系统中的一群接口。外观定义了一个高层接口,让子系统更容易使用。实例:家庭影院6.策略 Strategy封装可以互换的行为,并使用委托来决定使用哪一个。定义算法族,分别封装起来,让它们之间可以互相替换,此模式让算法的变化独立于使用算法的客户。实例:各种鸭子, RPG换武器, mvc中一个视图可换多个控制器7.代理 Proxy包装对象,以控制对此对象的访问。为另一个对象提供一个替身或占位符以访问这个对象。实例:糖果机远程监控。8.工厂方法 Factory Method由子类决定要创建的具体类是哪一个。定义了一个创建对象的接口,但由子类决定要实例化的类似哪一个。工厂方法让类把实例化推迟到子类。实例:两个地区的披萨饼店9.抽象工厂 Abstract Method允许客户创建对象的家族,而无需指定他们的具体类。提供一个接口,用于创建相关或依赖对象的家族,而不需要明确指定具体类。实例:两个地区的披萨饼店,有各种口味的披萨10.适配器 Adaptor封装对象,并提供不同的接口。将一个类的接口,转化成客户期望的另一个接口。适配器让原本不兼容的类可以合作无间。实例:火鸡变鸭子11.观察者 Observer让对象能够在状态改变时被通知。在对象之间建立一对多的依赖,这样一来,当一个对象改变状态,依赖它的对象都会收到通知,并自动更新。实例:气象监测通知; mvc中模型实现了观察者模式,状态改变时,相关的一个或多个视图更新。12.模板方法 Template Method由子类决定如何实现一个算法中步骤。在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以在不改变算法结构的情况下,重新定义算法中的某些步骤。实例: 星巴克的冲茶步骤和冲咖啡的步骤,排序算法。13.单件 Singleton确保有且只有一个对象被创建确保一个类只有一个实例,并提供全局访问点。实例:线程池,缓存,对话框,处理偏好设置和注册表对象,日志,打印机、显卡等设备的驱动程序。14.命令 Command封装请求成为对象。将请求封装成对象,这可以让你使用不同的请求、队列,或者日志请求来参数化其他对象。命令模式也可以支持撤销。实例:电源控制器上的每一个按键都被设定来打开或关闭一些开关。【15.复合模式 composed patterns】复合模式结合两个或两个以上的模式,组成一个解决方案,解决一再发生的一般性问题。实例:生物学家观察一群鸭子,MVC,model2(浏览器/服务器模型, 使用Servlet和JSP技术实现)。二、剩下的模式:1.桥接 Bridge使用桥接模式不只改变你的实现,也改变你的抽象。实例:不同型号的电视都有自己的遥控器实现。2.生成器 Builder封装一个产品的构造过程,并允许按步骤构造。实例:为“模式乐园”指定度假计划,客人可以选择旅馆、门票、餐厅和各种特殊活动。3.责任链 Chain of Resposibility让一个以上的对象有机会能够处理某个请求实例:糖果公司处理玩家,玩家父母,店家的邮件和垃圾邮件。 处理鼠标、键盘事件。4.蝇量 Flyweight让某个类的一个实例能用来提供许多“虚拟实例”实例:景观设计中加入非常多的树5.解释器 Interpreter为语言创建解释器实例:实现一个简单的语言。6.中介者 Mediato集中相关对象之间复杂的沟通和控制方式。实例:未来屋闹钟,日历,咖啡壶,碰头之间的协调7.备忘录 Mementor让对象返回之前的状态(“撤销”)实例:RPG游戏回到上一个存档。8.原型 Prototype当创建给定类的实例的过程很昂贵或很复杂时,就使用原型模式实例:RPG游戏中创造新的怪兽时,复制旧怪兽并添加修改属性9.访问者 Visitor想要为一个对象的组合增加新的能力,且封装并不重要时,就好似用访问者模式。实例:顾客想知道餐厅每个菜及其原料的营养成分。三、分类:1.创建型(创建型模式涉及到将对象实例化,这类模式都提供一个方法,将客户从所需要实例化的对象中解耦)Abstract Factory; Singleton; Factory Method; Builder; Prototype;2.行为型(只要是行为型模式,都涉及到类和对象如何交互及分配职责)Observer; Strategy; State; Template Method; Command; Iterator; Chain of Responsibility; Interpreter; Mediator; Memento; Visitor;3.结构型(结构型模式可以让你把类或对象组合到更大的结构中)Composite; Decorator; Adapter; Proxy; Facade; Bridge; Flyweight;四、OO原则封装变化多用组合,少用继承针对接口编程,不针对实现编程为交互对象之间的松耦合设计而努力类应该对扩展开放,对修改关闭依赖抽象,不要依赖具体类只和朋友交谈别找我,我会找你类应该只有一个改变的理由五、OO基础抽象、封装、多态、继承六、其他:模式是在某情境(context)下,针对某问题的某种解决方案。情境、问题(约束)、解决方案。May the force be with you.用模式思考保持简单(Keep It Simple/KISS)设计模式并非万灵丹:事实上,什么丹都不是。你知道何时需要模式……重构的时间就是模式的时间!拿掉你所不需要的,不要害怕将一个设计模式从你的设计中删除。如果你现在不需要,就别做。初学者的心智:我要为Hello World找个模式中级人员的心智:或许这里我需要一个单件模式悟道者的心智:这里采用装饰者模式相当自然资源:四人组的《设计模式》《The Timeless way of Building》《A pattern Language》 http://c2.com/cgi/wiki?WelcomVisitors http://hillside.net/反模式告诉你如何采用一个不好的解决方案解决一个问题。 (收起)2011-10-23 17:51:48 回应
-
第610页
Google (静下来总会是有收获的)
OO(Object Orentied) Basics: Abstraction Encapsulation Polymorphism Inheritance OO Principles: 1. Identify the aspects of your application that vary and separate them from what stays the same. 2. Program to an interface, not an implementation. 3. Favor composition over inheritance. 4. Strive for loosely coupled designs between objects that interact. 5. Classes should be open for exten... (更多)OO(Object Orentied) Basics:AbstractionEncapsulationPolymorphismInheritanceOO Principles:1. Identify the aspects of your application that vary and separate them from what stays the same.2. Program to an interface, not an implementation.3. Favor composition over inheritance.4. Strive for loosely coupled designs between objects that interact.5. Classes should be open for extension, but closed for modification.6. Depend upon abstractions. Do not depend upon concrete classes.(Dependency Inversion Principle) i: No variable should hold a reference to a concrete class. Use a factory to get around that. ii: No class should derive from a concrete class. Derive from an abstraction, like an interface or an abstract class. iii: No method should override an implemented method of any of its base classes. Those methods implemented in the base class are meant to be shared by all your subclasses.7. The Hollywood Principle - Don't call us, we'll call you.8. A class should have only one reason to change.OO Patterns:1. Strategy Patterndefines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.Encapsulates interchangeable behaviors and use delegation to decide which one to use.2. Observer Patterndefines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.Allows objects to be notified when state changes.3. Decorator Patternattaches additional responsibilities to an object dynamically. Decorator provide a flexible alternative to subclassing for extending functionality.Wraps an object to provide new behavior.4. Factory Method Patterndefines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.Subclasses decide which concrete classes to create.5. Abstract Factory Patternprovides an interface for creating families of related or dependent objets without specifying their concrete classes.Allows a client to create families of objects without specifying their concrete classes.6. Singleton Patternensures a class only has one instance and provides a global point of access to it.Ensures one and only object is created.7. Command Patternencapusulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.Encapsulates a request as an object.8. Adapter Patternconverts the interface of a class into another interface the client expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.Wraps an object and provides a different interface to it.9. Facade Patternprovides a unified interface to a set of interfaces in a subsystem. Facace defines a higher-level interface that makes the subsystem easier to use.Simplifies the interface of a set of classes.10. Template Method Patterndefines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.Subclasses decide how to implement steps in an algorithm.11. Iterator Patternprovides a way to access the elements of an aggreate object sequentially without exposing its underlying representation.Provides a way to traverse a collection of objects without exposing its implementation.12. Composite Patternallows you to compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.Clients treat collections of objects and individual objects uniformly.13. State Patternallows an object to alter its behavior when its internal state changes. The object will appear to change its classes.Encapsulates stat-based behaviors and uses delegation to switch between behaviors.14. Proxy Patternprovides a surrogate or placeholder for another object to control access to it.Wraps an object to control access to it. (收起)2011-06-24 00:50:58 回应
-
第1页
《head first 设计模式》笔记 提纲: 一、各章节中出现的模式 二、剩下的模式 三、分类 四、OO原则 五、OO基础 六、其他 一、各章节中出现的模式: 1.装饰者 Decorator 包装一个对象,以提供新的行为。 动态地将责任附加到对象上。想要扩展功能,装饰者提供了有别于继承的另一种选择。 实例:星巴克的各种咖啡。 2.状态 state 封装了基于状态的行为,并使用委托在行为之间切换。 ... (更多)《head first 设计模式》笔记提纲:一、各章节中出现的模式二、剩下的模式三、分类四、OO原则五、OO基础六、其他一、各章节中出现的模式:1.装饰者 Decorator包装一个对象,以提供新的行为。动态地将责任附加到对象上。想要扩展功能,装饰者提供了有别于继承的另一种选择。实例:星巴克的各种咖啡。2.状态 state封装了基于状态的行为,并使用委托在行为之间切换。允许对象在内部状态改变时改变它的行为,对像看起来好像改变了它的类。实例:糖果机3.迭代器 Iterator在对象的集合中游走,而不暴露集合的实现。提供一种方法顺序访问一个聚合对象中的各个元素,而又不暴露其内部的表示。实例:两家店的菜单合并(遍历数组,ArrayList)。4.组合 Composite客户用一致的方法处理对象集合和单个对象。允许你将对象组成树形结构来表现 “整体/部分”的层次结构。组合能让客户以一致的方式处理个别对象和对象组合。实例:两家店的菜单合并,午餐菜单中加入甜点菜单。 mvc中视图的层级架构5.外观 Facade简化一群类的接口。提供了一个统一的接口,用来访问子系统中的一群接口。外观定义了一个高层接口,让子系统更容易使用。实例:家庭影院6.策略 Strategy封装可以互换的行为,并使用委托来决定使用哪一个。定义算法族,分别封装起来,让它们之间可以互相替换,此模式让算法的变化独立于使用算法的客户。实例:各种鸭子, RPG换武器, mvc中一个视图可换多个控制器7.代理 Proxy包装对象,以控制对此对象的访问。为另一个对象提供一个替身或占位符以访问这个对象。实例:糖果机远程监控。8.工厂方法 Factory Method由子类决定要创建的具体类是哪一个。定义了一个创建对象的接口,但由子类决定要实例化的类似哪一个。工厂方法让类把实例化推迟到子类。实例:两个地区的披萨饼店9.抽象工厂 Abstract Method允许客户创建对象的家族,而无需指定他们的具体类。提供一个接口,用于创建相关或依赖对象的家族,而不需要明确指定具体类。实例:两个地区的披萨饼店,有各种口味的披萨10.适配器 Adaptor封装对象,并提供不同的接口。将一个类的接口,转化成客户期望的另一个接口。适配器让原本不兼容的类可以合作无间。实例:火鸡变鸭子11.观察者 Observer让对象能够在状态改变时被通知。在对象之间建立一对多的依赖,这样一来,当一个对象改变状态,依赖它的对象都会收到通知,并自动更新。实例:气象监测通知; mvc中模型实现了观察者模式,状态改变时,相关的一个或多个视图更新。12.模板方法 Template Method由子类决定如何实现一个算法中步骤。在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以在不改变算法结构的情况下,重新定义算法中的某些步骤。实例: 星巴克的冲茶步骤和冲咖啡的步骤,排序算法。13.单件 Singleton确保有且只有一个对象被创建确保一个类只有一个实例,并提供全局访问点。实例:线程池,缓存,对话框,处理偏好设置和注册表对象,日志,打印机、显卡等设备的驱动程序。14.命令 Command封装请求成为对象。将请求封装成对象,这可以让你使用不同的请求、队列,或者日志请求来参数化其他对象。命令模式也可以支持撤销。实例:电源控制器上的每一个按键都被设定来打开或关闭一些开关。【15.复合模式 composed patterns】复合模式结合两个或两个以上的模式,组成一个解决方案,解决一再发生的一般性问题。实例:生物学家观察一群鸭子,MVC,model2(浏览器/服务器模型, 使用Servlet和JSP技术实现)。二、剩下的模式:1.桥接 Bridge使用桥接模式不只改变你的实现,也改变你的抽象。实例:不同型号的电视都有自己的遥控器实现。2.生成器 Builder封装一个产品的构造过程,并允许按步骤构造。实例:为“模式乐园”指定度假计划,客人可以选择旅馆、门票、餐厅和各种特殊活动。3.责任链 Chain of Resposibility让一个以上的对象有机会能够处理某个请求实例:糖果公司处理玩家,玩家父母,店家的邮件和垃圾邮件。 处理鼠标、键盘事件。4.蝇量 Flyweight让某个类的一个实例能用来提供许多“虚拟实例”实例:景观设计中加入非常多的树5.解释器 Interpreter为语言创建解释器实例:实现一个简单的语言。6.中介者 Mediato集中相关对象之间复杂的沟通和控制方式。实例:未来屋闹钟,日历,咖啡壶,碰头之间的协调7.备忘录 Mementor让对象返回之前的状态(“撤销”)实例:RPG游戏回到上一个存档。8.原型 Prototype当创建给定类的实例的过程很昂贵或很复杂时,就使用原型模式实例:RPG游戏中创造新的怪兽时,复制旧怪兽并添加修改属性9.访问者 Visitor想要为一个对象的组合增加新的能力,且封装并不重要时,就好似用访问者模式。实例:顾客想知道餐厅每个菜及其原料的营养成分。三、分类:1.创建型(创建型模式涉及到将对象实例化,这类模式都提供一个方法,将客户从所需要实例化的对象中解耦)Abstract Factory; Singleton; Factory Method; Builder; Prototype;2.行为型(只要是行为型模式,都涉及到类和对象如何交互及分配职责)Observer; Strategy; State; Template Method; Command; Iterator; Chain of Responsibility; Interpreter; Mediator; Memento; Visitor;3.结构型(结构型模式可以让你把类或对象组合到更大的结构中)Composite; Decorator; Adapter; Proxy; Facade; Bridge; Flyweight;四、OO原则封装变化多用组合,少用继承针对接口编程,不针对实现编程为交互对象之间的松耦合设计而努力类应该对扩展开放,对修改关闭依赖抽象,不要依赖具体类只和朋友交谈别找我,我会找你类应该只有一个改变的理由五、OO基础抽象、封装、多态、继承六、其他:模式是在某情境(context)下,针对某问题的某种解决方案。情境、问题(约束)、解决方案。May the force be with you.用模式思考保持简单(Keep It Simple/KISS)设计模式并非万灵丹:事实上,什么丹都不是。你知道何时需要模式……重构的时间就是模式的时间!拿掉你所不需要的,不要害怕将一个设计模式从你的设计中删除。如果你现在不需要,就别做。初学者的心智:我要为Hello World找个模式中级人员的心智:或许这里我需要一个单件模式悟道者的心智:这里采用装饰者模式相当自然资源:四人组的《设计模式》《The Timeless way of Building》《A pattern Language》 http://c2.com/cgi/wiki?WelcomVisitors http://hillside.net/反模式告诉你如何采用一个不好的解决方案解决一个问题。 (收起)2011-10-23 17:51:48 回应
-
第610页
Google (静下来总会是有收获的)
OO(Object Orentied) Basics: Abstraction Encapsulation Polymorphism Inheritance OO Principles: 1. Identify the aspects of your application that vary and separate them from what stays the same. 2. Program to an interface, not an implementation. 3. Favor composition over inheritance. 4. Strive for loosely coupled designs between objects that interact. 5. Classes should be open for exten... (更多)OO(Object Orentied) Basics:AbstractionEncapsulationPolymorphismInheritanceOO Principles:1. Identify the aspects of your application that vary and separate them from what stays the same.2. Program to an interface, not an implementation.3. Favor composition over inheritance.4. Strive for loosely coupled designs between objects that interact.5. Classes should be open for extension, but closed for modification.6. Depend upon abstractions. Do not depend upon concrete classes.(Dependency Inversion Principle) i: No variable should hold a reference to a concrete class. Use a factory to get around that. ii: No class should derive from a concrete class. Derive from an abstraction, like an interface or an abstract class. iii: No method should override an implemented method of any of its base classes. Those methods implemented in the base class are meant to be shared by all your subclasses.7. The Hollywood Principle - Don't call us, we'll call you.8. A class should have only one reason to change.OO Patterns:1. Strategy Patterndefines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.Encapsulates interchangeable behaviors and use delegation to decide which one to use.2. Observer Patterndefines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.Allows objects to be notified when state changes.3. Decorator Patternattaches additional responsibilities to an object dynamically. Decorator provide a flexible alternative to subclassing for extending functionality.Wraps an object to provide new behavior.4. Factory Method Patterndefines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.Subclasses decide which concrete classes to create.5. Abstract Factory Patternprovides an interface for creating families of related or dependent objets without specifying their concrete classes.Allows a client to create families of objects without specifying their concrete classes.6. Singleton Patternensures a class only has one instance and provides a global point of access to it.Ensures one and only object is created.7. Command Patternencapusulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.Encapsulates a request as an object.8. Adapter Patternconverts the interface of a class into another interface the client expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.Wraps an object and provides a different interface to it.9. Facade Patternprovides a unified interface to a set of interfaces in a subsystem. Facace defines a higher-level interface that makes the subsystem easier to use.Simplifies the interface of a set of classes.10. Template Method Patterndefines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.Subclasses decide how to implement steps in an algorithm.11. Iterator Patternprovides a way to access the elements of an aggreate object sequentially without exposing its underlying representation.Provides a way to traverse a collection of objects without exposing its implementation.12. Composite Patternallows you to compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.Clients treat collections of objects and individual objects uniformly.13. State Patternallows an object to alter its behavior when its internal state changes. The object will appear to change its classes.Encapsulates stat-based behaviors and uses delegation to switch between behaviors.14. Proxy Patternprovides a surrogate or placeholder for another object to control access to it.Wraps an object to control access to it. (收起)2011-06-24 00:50:58 回应
-
第1页
《head first 设计模式》笔记 提纲: 一、各章节中出现的模式 二、剩下的模式 三、分类 四、OO原则 五、OO基础 六、其他 一、各章节中出现的模式: 1.装饰者 Decorator 包装一个对象,以提供新的行为。 动态地将责任附加到对象上。想要扩展功能,装饰者提供了有别于继承的另一种选择。 实例:星巴克的各种咖啡。 2.状态 state 封装了基于状态的行为,并使用委托在行为之间切换。 ... (更多)《head first 设计模式》笔记提纲:一、各章节中出现的模式二、剩下的模式三、分类四、OO原则五、OO基础六、其他一、各章节中出现的模式:1.装饰者 Decorator包装一个对象,以提供新的行为。动态地将责任附加到对象上。想要扩展功能,装饰者提供了有别于继承的另一种选择。实例:星巴克的各种咖啡。2.状态 state封装了基于状态的行为,并使用委托在行为之间切换。允许对象在内部状态改变时改变它的行为,对像看起来好像改变了它的类。实例:糖果机3.迭代器 Iterator在对象的集合中游走,而不暴露集合的实现。提供一种方法顺序访问一个聚合对象中的各个元素,而又不暴露其内部的表示。实例:两家店的菜单合并(遍历数组,ArrayList)。4.组合 Composite客户用一致的方法处理对象集合和单个对象。允许你将对象组成树形结构来表现 “整体/部分”的层次结构。组合能让客户以一致的方式处理个别对象和对象组合。实例:两家店的菜单合并,午餐菜单中加入甜点菜单。 mvc中视图的层级架构5.外观 Facade简化一群类的接口。提供了一个统一的接口,用来访问子系统中的一群接口。外观定义了一个高层接口,让子系统更容易使用。实例:家庭影院6.策略 Strategy封装可以互换的行为,并使用委托来决定使用哪一个。定义算法族,分别封装起来,让它们之间可以互相替换,此模式让算法的变化独立于使用算法的客户。实例:各种鸭子, RPG换武器, mvc中一个视图可换多个控制器7.代理 Proxy包装对象,以控制对此对象的访问。为另一个对象提供一个替身或占位符以访问这个对象。实例:糖果机远程监控。8.工厂方法 Factory Method由子类决定要创建的具体类是哪一个。定义了一个创建对象的接口,但由子类决定要实例化的类似哪一个。工厂方法让类把实例化推迟到子类。实例:两个地区的披萨饼店9.抽象工厂 Abstract Method允许客户创建对象的家族,而无需指定他们的具体类。提供一个接口,用于创建相关或依赖对象的家族,而不需要明确指定具体类。实例:两个地区的披萨饼店,有各种口味的披萨10.适配器 Adaptor封装对象,并提供不同的接口。将一个类的接口,转化成客户期望的另一个接口。适配器让原本不兼容的类可以合作无间。实例:火鸡变鸭子11.观察者 Observer让对象能够在状态改变时被通知。在对象之间建立一对多的依赖,这样一来,当一个对象改变状态,依赖它的对象都会收到通知,并自动更新。实例:气象监测通知; mvc中模型实现了观察者模式,状态改变时,相关的一个或多个视图更新。12.模板方法 Template Method由子类决定如何实现一个算法中步骤。在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以在不改变算法结构的情况下,重新定义算法中的某些步骤。实例: 星巴克的冲茶步骤和冲咖啡的步骤,排序算法。13.单件 Singleton确保有且只有一个对象被创建确保一个类只有一个实例,并提供全局访问点。实例:线程池,缓存,对话框,处理偏好设置和注册表对象,日志,打印机、显卡等设备的驱动程序。14.命令 Command封装请求成为对象。将请求封装成对象,这可以让你使用不同的请求、队列,或者日志请求来参数化其他对象。命令模式也可以支持撤销。实例:电源控制器上的每一个按键都被设定来打开或关闭一些开关。【15.复合模式 composed patterns】复合模式结合两个或两个以上的模式,组成一个解决方案,解决一再发生的一般性问题。实例:生物学家观察一群鸭子,MVC,model2(浏览器/服务器模型, 使用Servlet和JSP技术实现)。二、剩下的模式:1.桥接 Bridge使用桥接模式不只改变你的实现,也改变你的抽象。实例:不同型号的电视都有自己的遥控器实现。2.生成器 Builder封装一个产品的构造过程,并允许按步骤构造。实例:为“模式乐园”指定度假计划,客人可以选择旅馆、门票、餐厅和各种特殊活动。3.责任链 Chain of Resposibility让一个以上的对象有机会能够处理某个请求实例:糖果公司处理玩家,玩家父母,店家的邮件和垃圾邮件。 处理鼠标、键盘事件。4.蝇量 Flyweight让某个类的一个实例能用来提供许多“虚拟实例”实例:景观设计中加入非常多的树5.解释器 Interpreter为语言创建解释器实例:实现一个简单的语言。6.中介者 Mediato集中相关对象之间复杂的沟通和控制方式。实例:未来屋闹钟,日历,咖啡壶,碰头之间的协调7.备忘录 Mementor让对象返回之前的状态(“撤销”)实例:RPG游戏回到上一个存档。8.原型 Prototype当创建给定类的实例的过程很昂贵或很复杂时,就使用原型模式实例:RPG游戏中创造新的怪兽时,复制旧怪兽并添加修改属性9.访问者 Visitor想要为一个对象的组合增加新的能力,且封装并不重要时,就好似用访问者模式。实例:顾客想知道餐厅每个菜及其原料的营养成分。三、分类:1.创建型(创建型模式涉及到将对象实例化,这类模式都提供一个方法,将客户从所需要实例化的对象中解耦)Abstract Factory; Singleton; Factory Method; Builder; Prototype;2.行为型(只要是行为型模式,都涉及到类和对象如何交互及分配职责)Observer; Strategy; State; Template Method; Command; Iterator; Chain of Responsibility; Interpreter; Mediator; Memento; Visitor;3.结构型(结构型模式可以让你把类或对象组合到更大的结构中)Composite; Decorator; Adapter; Proxy; Facade; Bridge; Flyweight;四、OO原则封装变化多用组合,少用继承针对接口编程,不针对实现编程为交互对象之间的松耦合设计而努力类应该对扩展开放,对修改关闭依赖抽象,不要依赖具体类只和朋友交谈别找我,我会找你类应该只有一个改变的理由五、OO基础抽象、封装、多态、继承六、其他:模式是在某情境(context)下,针对某问题的某种解决方案。情境、问题(约束)、解决方案。May the force be with you.用模式思考保持简单(Keep It Simple/KISS)设计模式并非万灵丹:事实上,什么丹都不是。你知道何时需要模式……重构的时间就是模式的时间!拿掉你所不需要的,不要害怕将一个设计模式从你的设计中删除。如果你现在不需要,就别做。初学者的心智:我要为Hello World找个模式中级人员的心智:或许这里我需要一个单件模式悟道者的心智:这里采用装饰者模式相当自然资源:四人组的《设计模式》《The Timeless way of Building》《A pattern Language》 http://c2.com/cgi/wiki?WelcomVisitors http://hillside.net/反模式告诉你如何采用一个不好的解决方案解决一个问题。 (收起)2011-10-23 17:51:48 回应
-
第610页
Google (静下来总会是有收获的)
OO(Object Orentied) Basics: Abstraction Encapsulation Polymorphism Inheritance OO Principles: 1. Identify the aspects of your application that vary and separate them from what stays the same. 2. Program to an interface, not an implementation. 3. Favor composition over inheritance. 4. Strive for loosely coupled designs between objects that interact. 5. Classes should be open for exten... (更多)OO(Object Orentied) Basics:AbstractionEncapsulationPolymorphismInheritanceOO Principles:1. Identify the aspects of your application that vary and separate them from what stays the same.2. Program to an interface, not an implementation.3. Favor composition over inheritance.4. Strive for loosely coupled designs between objects that interact.5. Classes should be open for extension, but closed for modification.6. Depend upon abstractions. Do not depend upon concrete classes.(Dependency Inversion Principle) i: No variable should hold a reference to a concrete class. Use a factory to get around that. ii: No class should derive from a concrete class. Derive from an abstraction, like an interface or an abstract class. iii: No method should override an implemented method of any of its base classes. Those methods implemented in the base class are meant to be shared by all your subclasses.7. The Hollywood Principle - Don't call us, we'll call you.8. A class should have only one reason to change.OO Patterns:1. Strategy Patterndefines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.Encapsulates interchangeable behaviors and use delegation to decide which one to use.2. Observer Patterndefines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.Allows objects to be notified when state changes.3. Decorator Patternattaches additional responsibilities to an object dynamically. Decorator provide a flexible alternative to subclassing for extending functionality.Wraps an object to provide new behavior.4. Factory Method Patterndefines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.Subclasses decide which concrete classes to create.5. Abstract Factory Patternprovides an interface for creating families of related or dependent objets without specifying their concrete classes.Allows a client to create families of objects without specifying their concrete classes.6. Singleton Patternensures a class only has one instance and provides a global point of access to it.Ensures one and only object is created.7. Command Patternencapusulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.Encapsulates a request as an object.8. Adapter Patternconverts the interface of a class into another interface the client expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.Wraps an object and provides a different interface to it.9. Facade Patternprovides a unified interface to a set of interfaces in a subsystem. Facace defines a higher-level interface that makes the subsystem easier to use.Simplifies the interface of a set of classes.10. Template Method Patterndefines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.Subclasses decide how to implement steps in an algorithm.11. Iterator Patternprovides a way to access the elements of an aggreate object sequentially without exposing its underlying representation.Provides a way to traverse a collection of objects without exposing its implementation.12. Composite Patternallows you to compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.Clients treat collections of objects and individual objects uniformly.13. State Patternallows an object to alter its behavior when its internal state changes. The object will appear to change its classes.Encapsulates stat-based behaviors and uses delegation to switch between behaviors.14. Proxy Patternprovides a surrogate or placeholder for another object to control access to it.Wraps an object to control access to it. (收起)2011-06-24 00:50:58 回应
书评 · · · · · · (共65条) 我来评论这本书
热门评论 最新评论
Head First Design Patterns让设计模式走向大众
-
- 红眼睛阿义 本影印版刚拿到手,感觉沉甸甸的,第一印象就不错,网上评价也很好。恰巧快到春节,于是在书架一大堆的书籍中,我只选择这本比较厚重的,塞到我的行李包中。 翻开一看,真如Erich Camma所说,简直欲罢不能.本书是Oreilly的Head First系列中的一本,本系列书籍的特点是采用大量的插图、图例来进行辅助讲解,...... (2回应)2006-02-08 15/16有用
入门看这本书的话很不错
-
- Luffy Lee(scrum me!!!) 写得很有趣,图文并茂,比起四人帮的那本,好懂了不知道多少倍。 计算机世界的head first系列让我想起了阿呆系列,话说新的一集the big bang theory里面lennerd学习橄榄球的时候也有一本阿呆啊,哈哈,跑题了 不过只看书学明白设计模式是不可能的,这些只是前人的总结,我们唯有实践实践再实...... (5回应)2009-11-14 14/17有用来自 中国电力出版社2007版
让人欲罢不能的一本书
-
- nokivan 极易入门的一本书,把设计模式讲的通俗易懂。配合大量图片,整本书显得生动有趣。让人读起来很是享受。 但是这也使得整本书给人有点“不够夯实”的感觉,尽管书里讲的内容还是很权威的。大量异国文化的例子让人感觉很是陌生(什么鸭子,或者皮萨饼等等)。现编现用的例子给人感觉有点随意。个人觉得设计模式还是在有一定代码量的情况下学习效......2012-02-11 来自 中国电力出版社2007版
这本书不错
-
- addition 呵呵,这本书还不错,就是我水平有限,经常看得云里雾里的,实在搞不通,又没处可问。跑百度知道里发贴,也经常很久没人理或者有人来答非所问的。挺烦的。后来到处查,发现一个“猎豹网校”上有类似的课程,有老师教,那种视频课程,跟看土豆网的视频差不多,不过效果可要清楚多了。听了一下老师的讲解,这才明白了好多看不懂的地方。你别说,咱......2012-02-01 来自 中国电力出版社2007版
如果你想学习设计模式, 又看不进去传统的设计书籍, ...
-
- xing-xing(寻找充实) 这是一本很轻松的书籍, 不属于难啃的学院派风格. 但我还是断断续续看了接近一个月才看完, 工作实在太忙了, 每天只有在地铁上抽出一点时间来阅读. 这期间我总是看着看着就乐了, 就这样开心了一个月, 对设计模式也摸到了门道. 书中介绍的都是一些基本的设计模式, 以附录的形式给出了部分较高级的模式. 看完这本书, ......2011-12-31 来自 东南大学2005版
这本书还不错!
-
- rubbish 这是一本不错的书,可是自己看了2个多月,都没搞明白。有一次无意间到当当书城逛,看到下边评论,说有个叫猎豹网校的,教计算机课程。进网站看了一下。对我帮助真是太大了。是视频教程的那种,老师讲解的很详细,非常容易懂。现在想一想自己还觉的挺好笑,自己在哪白白啃了2个月的死书,浪费时间!推荐一下猎豹网校。真的很不错。对了,上边还......2011-12-15 来自 中国电力出版社2007版
有保留的推荐,美国式思维
-
- 东东 Head First系列。书的出发点很好,想让你知其然,更知其所以然。也确实做了比较大的努力。所以看起来和“传统的”技术书籍差别很大。遗憾的是,书中举得例子(如披萨店)和叙述、思维方式都是美国式的。如果你熟悉美国文化并具备美国式的交流和思维方式的能力。这本书无疑是非常适合的。但如果你和我一样,可能会稍有些不习惯。觉得还......2011-12-02 来自 中国电力出版社2007版
"Head First Design Patterns"的论坛 · · · · · ·
这本书的其他版本 · · · · · · ( 全部5 )
- 中国电力出版社版 2007-9 / 942人读过 / 有售
- 东南大学版 2005-11 / 782人读过 / 有售
- 天瓏版 41人读过
- O'Reilly Media版 2004-10-01 / 1人读过
以下豆列推荐 · · · · · · (全部)
- 程序员最应该读的图书(原版) (hongqn)
- 程序员必读经典书籍 (Felven)
- Programmer's Bookshelf (number5)
- Head First Series (nolearning)
- 公司书架 (number5)
谁读这本书?
喜欢这本书的人常去的小组 · · · · · ·

- Vim (6198)

- O'Reilly爱好者 (2803)

- Python编程 (19003)

- Java&Android移动应用编程 (5515)

- Ruby (2861)

- 分享计算机书籍 (5290)

- 设计模式 (912)

- MongoDB (2146)
喜欢这本书的人关注的活动 · · · · · ·
订阅关于Head First Design Patterns的评论:
feed: rss 2.0











