Saturday, November 13, 2010

.....Structural Pattern

Structural Patterns describe how objects and classes can be combined to form larger structures. The difference between class patterns and object patterns is that class patterns describe abstraction with the help of inheritance and how it can be used to provide more useful program interface. Object patterns, on other hand, describe how objects can be associated and composed to form larger, more complex structures.

There are seven structural patterns.

1) Adapter :- Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

2) Bridge Patter :- The Bridge pattern is used to separate the interface of class from its implementation, so that either can be varied separately.We can do it by using abstract class instead of interface.

3)Composite Pattern :- The composite pattern describes that a group of objects are to be treated in the same way as a single instance of an object.
i.e The Composite pattern allows you to create a tree like structure for simple and complex objects so they appear the same to the client. An XmlDocument,TreeView are example of composite pattern.

4) Decorator Pattern :- A Decorator design pattern is a design pattern that allows new/additional behavior to be added to an existing object dynamically.

5) Facade :- Facade - The front(face) of a building,In Facade pattern a single class represent the entire system and hide the complexity of the system.

6) Flyweight Pattern :- When we need to share information between many objects than we use Flyweight pattern. If an information is shared between many objects than we can remove it from each object and referenced. This eliminates the redundancy and we can save memory. So instead of storing the same information n times for n object, it is only stored once. This object that contains all of the intrinsic(basic) information is called a flyweight object.

7) Proxy :- The Proxy pattern is used when you need to represent a complex object by a simpler one. If creating an object is expensive in time or computer resources, Proxy allows you to postpone this creation until you need the actual object. A Proxy usually has the same methods as the object it represents, and once the object is loaded, it passes on the method calls from the Proxy to the actual object.

No comments: