很好的OOP、Design Pattern入门书_深入浅出设计模式(影印版)书评-查字典图书网
查字典图书网
当前位置: 查字典 > 图书网 > > 深入浅出设计模式(影印版) > 很好的OOP、Design Pattern入门书
Wuqifu 深入浅出设计模式(影印版) 的书评 发表时间:2011-07-16 21:07:02

很好的OOP、Design Pattern入门书

《Head first design pattern》向读者很好地展现了OOP的基本原则和常见的几种设计模式。对比经典但却晦涩难懂的GoF《设计模式》,可以发现Java比C++能更好解释设计模式,我想这应归功于Java的对象引用机制和interface关键字。当然这也跟本书中的例子浅显易懂,GoF中的例子来源于实际开发项目有关。若是想学习设计模式的话,这本书不可错过。这本书的写作风格与排版也很有创意,值得一看!

赞同书末尾提到的Keep it simple(KISS)原则。学会了设计模式后不要手里拿着把锤子,看什么都成钉子,一遇到问题就想用设计模式去解决。设计模式是通过引入抽象层来提高代码的灵活性,但抽象层作为间接层在提高了代码的灵活性的同时也增加了复杂性,如果简洁的方案能解决问题就没必要杀鸡用牛刀动用设计模式。If you don't need it now, don't do it now.

本书可以和GoF的《设计模式》、Bob大叔的《敏捷软件开发》交叉阅读,这几本书在内容上相互补充相得益彰。

读书笔记:
A Pattern is a solution to a problem in a context.

Design Principle
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.(Observer)
5, Classes should be open for extension, but closed for modification.(decorator)
6, Depend upon abstractions. Do not depend upon concrete classes.(Abstract Factory)
7, Least Knowledge Principle: Talk only to your immediate friends(Facade)
8, The Hollywood Principle: Don't call us, we'll call you.(Template Method)
9, Single responsibility Principle: A class should have only one reason to change.

Strategy Pattern: defines a family of algorithms,encapsulates each one,and makes them interchangeable.Strategy Pattern let the algorithm vary independently from clients that use it.

Observer Pattern: defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.

Decorator Pattern: attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

Factory Method Pattern: defines an interface for creating an object, but lest subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclasses.

Abstract Factory Pattern: provides an interface for creating families of related or dependent objects without specifying their concrete classes.

Singleton Pattern: ensures a class has only one instance, and provides a global point of access to it.

Command Pattern: encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.

Adapter Pattern: converts the interface of a class into another interface the clients expects. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

Facade Pattern: provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher level interface that makes the subsystem easier to use.

Template Method Pattern: defines the skeleton of an algorithm in a method, deferring some steps to subclass. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.

Iterator Pattern: provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Composite Pattern: allows you to compose objects into tree structures to represents part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

State Pattern: allows an object to alter its behavior when its internal state changes. The object will appear to changes its class.

Proxy Pattern: provides a surrogate or placeholder for another object to control access to it.

展开全文
有用 0 无用 0

您对该书评有什么想说的?

发 表

推荐文章

猜你喜欢

附近的人在看

推荐阅读

拓展阅读