Chapter 1 Welcome to Design Patterns: an introduction
OO Basics:- Abstraction
- Encapsulation
- Polymorphism
- Inheritance
OO Principles:
- Encapsulate what varies.
- Favor composition over inheritence.
- Program to interfaces, not implementations.
OO Patterns:
- Strategy - defined a family of algorithms, encapsulates each once, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
Chapter 2 Keeping your Objects in the know: the Observer Pattern
OO Principles:
- Strive for loosely coupled designs between objects that interact.
OO Patterns:
- Observer - defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Chapter 3 Decorating Objects: the Decorator Pattern
OO Principles:
- Classes should be open for extension but closed for modification.
OO Patterns:
- Decorator - Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
Chapter 4 Baking with OO Goodness: the factory Pattern
OO Principles:
- Depend on abstractions. Do not depend on concrete classes.
OO Patterns:
- Abstract Factory - Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
- Factory Method - Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to the subclasses.
Chapter 5 One of a Kind Objects: the Singleton Pattern
OO Patterns:
- Singleton - Ensure a class only has one instance and provide a global point of access to it.
Chapter 6 Encapsulating Invocation: the Command Pattern
OO Patterns:
- Command - Encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.
Chapter 7 Being Adaptive: the Adapter and Facade Patterns
OO Principles:
- Only talk to your fiends
OO Patterns:
- Adapter - Converts the interface of a class into another interface clients expect. Lets classes work together that couldn't otherwise because of incompatible interfaces.
- Facade - Provides a unified interface to a set of interfaces in a subsystem. Facade defined a higher-level interface that makes the subsystem easier to use.
Chapter 8 Encapsulating Alogrithms: the Template Method Pattern
OO Principles:
- Don't call us, we'll call you.
OO Patterns:
- Template Method - Defined the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.
Chapter 9 Well-Managed Collections: the Iterator and Composite Patterns
OO Patterns:
- Iterator - Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
- Composite - Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
Chapter 10 The State of Things: the State Pattern
OO Pattern:
- State - Allows an object to alter its behavior when its internal state changes. The object will appear to change it class.
Chapter 11 Controlling Object Access: the Proxy Pattern
OO Pattern:
- Proxy - Provide a surrogate or placeholder for another object to control access to it.
Chapter 12 Patterns of Patterns: Compound Patterns
OO Pattern:
- Compound Patterns - A Compound Pattern combines two or more patterns into a solution that solves a recurring or general problem.
Chapter 13 Patterns in the Real World: Better Living with Patterns
Chapter 14 Appendix: Leftover Patterns
OO Patterns:
- Bridge - Use the Bridge Pattern to vary not only your implementations, but also your abstractions.
- Builder - Use the Builder Pattern to encapsulate the construction of a product and allow it to be constructed in steps.
- Chain of Responsibility - Use the Chain of Responsibility Pattern when you want to give more than one object a chance to handle a request.
- Flyweight - Use the Flyweight Pattern when one instance of a class can be used to provide many "virtual instances."
- Interpreter - Use the Interpreter Pattern to build an interpreter for a language.
- Mediator - Use the Mediator Pattern to centralize complex communications and control between related objects.
- Memento - Use the Memento Pattern when you need to be able to return an object to one of its previous states; for instance, if your use requests an "undo."
- Prototype - Use the Prototype Pattern when creating an instance of a given class is either expensive or complicated.
- Visitor - Use the Visitor Pattern when you want to add capabilities to a composite of objects and encapsulation is not important.
留言
張貼留言