Structural Patterns  «Prev 

Common Structural Patterns

Structural patterns primarily:
  1. Deal with objects delegating responsibilities to other objects. This results in a layered architecture of components with a low degree of coupling.
  2. Facilitate inter-object communication when one object is not accessible to the other by normal means or when an object is not usable because of its incompatible interface.
  3. Provide ways to structure an aggregate object so that it is created in full and to reclaim system resources in a timely manner.
Structural Patterns: Designing objects to satisfy particular project constraints. These work with the way objects are connected with other objects to ensure that changes in the system do not require changes to those connections.

Adapter pattern is a simple pattern that provides a wrapper for a class or object that uses a different interface, much like an electrical adapter can convert three-prong to two-prong plugs.

Bridge Pattern decouples the interface from the implementation without using inheritance. A parallel class hierarchy is used.

Composite Pattern describes a tree-like structure in which individual parts have the same interface as the whole pattern. Any leaf or sub-tree of the tree has the same interface as the entire tree. There is no fixed limit on the number of nodes in the three.

Decorator Pattern adds responsibilities to individual objects by wrapping them in a class that exposes their original interface, but includes some new methods and functionality as well.

Facade Pattern combines a group of diverse classes with complicated interrelations into a single, simple unified interface that handles the needs of most client classes. This makes it simpler for client programmers to use.
Facade Pattern Code

Proxy Pattern is similar to the Adapter pattern in that a surrogate objects stands in between the client classes and the actual object. However, the Proxy presents the same interface as the original object rather than a new interface.