Monday, December 31, 2012

Design Patterns

Design Patterns
Preface
It's a book of design patterns that describes simple and elegant solutions to specific problems in object-oriented software design. You'll have insights that can make your own designs more flexible, modular, reusable, and understandable

Introduction
Your design should be specific to the problem at hand but also general enough to address future problems and requirements.
In general, a pattern has four essential elements:
1. The pattern name
2. The problem
3. The solution
4. The consequences
The design patterns in this book are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context.
MVC decouples views and models by establishing a subscribe/notify protocol between them.
MVC uses other design patterns, such as Factory Method to specify the default controller class for a view and Decorator to add scrolling to a view. But the main relationships in MVC are given by the Observer, Composite, and Strategy design patterns.
How do we describe design patterns?
Pattern Name and Classification
Intent
Also Known As
Motivation
Applicability
Structure
Participants
Collaborations
Consequences
Implementation
Sample Code
Known Uses
Related Patterns
Creational patterns concern the process of object creation. Structural patterns deal with the composition of classes or objects. Behavioral patterns characterize the ways in which classes or objects interact and distribute responsibility.
Prototype is often an alternative to Abstract Factory.
Some patterns result in similar designs even though the patterns have different intents. For example, the structure diagrams of Composite and Decorator are similar.
There are also run-time inefficiencies, but the human inefficiencies are more important in the long run. Delegation is an extreme example of object composition. It shows that you can always replace inheritance with object composition as a mechanism for code reuse.

Creational Patterns
Abstract Factory is similar to Builder in that it too may construct complex objects. The primary difference is that the Builder pattern focuses on constructing a complex object step by step. Abstract Factory's emphasis is on families of product objects (either simple or complex).

No comments:

Post a Comment