Structural design patterns that use composition to merge objects and classes into larger structures. A good toolbox of structural patterns allows you to solve many thorny problems you are likely to encounter. They show you how to glue different pieces of a system together in a flexible and extensible fashion. Structural patterns help you guarantee that when one of the parts changes, the entire structure does not need to change.
They also show you how to recast pieces that do not fit (but that you need to use) into pieces that do fit.
In this module, you will learn:
- How programmers use structural patterns
- The characteristics of some commonly used structural patterns
- When and when not to use the Flyweight pattern
- How the Flyweight pattern can help with your course project
Spring 5 Design Pattern Book
Types of structural design patterns
There are following types of structural design patterns.
Structural Patterns deal with the composition of classes and objects. Inheritance is employed for interface composition and methods for addition of new functionalities are introduced by object composition. A better understanding of the entity relationship is established. Abilities of independent interfaces are combined in structural patterns.
Adapter
To link two interfaces that are not compatible and utilize their functionalities, Adapter pattern is used. It is used to provide a new interface covering for any existing class.
Bridge
In Bridge Pattern, there is a structural alteration in the main and interface implementer classes without having any effect on each other. These two classes are made independent of each other and are only connected by using the bridge which is an interface.
Composite
Composite Pattern is used group together objects as one object. The objects are composed in a tree structure form with the representation of individual tree nodes and the hierarchy as well. The objects belonging to the same groups are modified using this pattern.
Decorator
Decorator pattern restricts the alteration of object structure while a new functionality is added to it. The initial class remains unaltered while a decorator class wraps around it and provides extra capabilities.
Façade
Façade provides clients with access to the system but conceals the working of the system and its complexities. The pattern creates one class consisting of user functions and delegates provide calling facilities to the classes belonging to the systems.
Flyweight
Flyweight pattern is used to reduce memory usage and improve performance by cutting on object creation. The pattern looks for similar objects that already exist to reuse it rather than creating new ones that are similar.
Private Class Data
Some of the class attributes may be available without requirement and thus may be prone to be corrupted. To prevent that the attributes may be allowed to be manipulated only once during operation after which it becomes private and thus data is protected.
Proxy
It is used to create objects that may represent functions of other classes or objects and the interface is used to access these functionalities.
Happy Learning with us!!!