Wednesday, November 25, 2009

Design Patterns

A note on Design patterns

Many times we can see ourselves looking for design patterns to fit the design of a requirement.
Of course if the requirement is simple enough to apply any existing design pattern we should do so. This will save us valuable time.

In my opinion it is better not to worry about which pattern to apply.But concentrate on the
three basic Object oriented principles.

1) Encapsulate what varies
2) Prefer composition over inheritance
3) Program to an interface not to an implementation.

If we approach the design with these principles in mind , we don't have to search for patterns. Pattern will emerge itself. Once we apply these principles, we can definitely look whether any of the existing patterns can solve the issue better than the way we thought of. This way our thinking process will improve tremendously and at times we may end up creating a solution which may be better than any available design patterns.