Showing posts with label toc2. Show all posts
Showing posts with label toc2. Show all posts

Thursday, 19 May 2011

Structural Patterns

This design pattern is all about Class and Object composition. Structural class-creation patterns use inheritance to compose interfaces. Structural object-patterns define ways to compose objects to obtain new functionality.
Following are the patterns under this category:
Adapter pattern / Wrapper pattern
FlyWeight Pattern
Bridge  Pattern
Composite pattern
Decorator pattern
Proxy Pattern

Behavioral design pattern

This design pattern is all about algorithms and assigning object responsibilities. This design pattern also helps design communications between different classes and objects and their interconnections. While behavorial-class patterns use inheritance to distribute behavior between classes, behavorial-object patterns use object composition to perform the same task.
Covering some patterns under it :

Memento Pattern
Mediator Pattern
Observer Pattern
Null Object Pattern
Visitor Pattern
Interpreter Pattern
Iterator Pattern
Strategy Pattern
Command Pattern
Template Method Pattern
Chain of Responsibility Pattern

Design Principles

The principles of design include following:
Open Close principle
Dependency interversion principle
Interface segregation principle
Single responsibility principle
Liskov's Substitution principle
Principle of least knowledge

These all principles help us manage dependencies and coupling among the software modules in a better way. These principles expose the dependency management aspects of OOD as opposed to the conceptualization and modeling aspects. This is not to say that OO is a poor tool for conceptualization of the problem space, or that it is not a good venue for creating models. Certainly many people get value out of these aspects of OO. The principles, however, focus very tightly on dependency management.

Dependency Management is an issue that most of us have faced. Whenever we bring up on our screens a nasty batch of tangled legacy code, we are experiencing the results of poor dependency management. Poor dependency managment leads to code that is hard to change, fragile, and non-reusable. On the other hand, when dependencies are well managed, the code remains flexible, robust, and reusable. So dependency management, and therefore these principles, are at the foudation of the -ilities that software developers desire.

The first five principles are principles of class design. They are:

SRP The Single Responsibility Principle A class should have one, and only one, reason to change.
OCP The Open Closed Principle You should be able to extend a classes behavior, without modifying it.
LSP The Liskov Substitution Principle Derived classes must be substitutable for their base classes.
DIP The Dependency Inversion Principle Depend on abstractions, not on concretions.
ISP The Interface Segregation Principle Make fine grained interfaces that are client specific.

The above 5 principles are called SOLID, derived from their first name.

Creational Patterns in java

This Design pattern is all about class instantiation. This pattern can be further divided into class-creation patterns and object-creational patterns. While class-creation patterns use inheritance effectively in the instantiation process, object-creation patterns use delegation effectively to get the job done. Following are the patterns under this category:
Object Pool Pattern
Prototype Pattern
Factory Method Pattern
Builder Pattern
Factory Pattern( See also - Factory pattern example in java )
Abstract Factory Pattern
Singleton Pattern