Structural Design Patterns are design patterns that make design easier by establishing a simple way to represent the link between elements. In simple terms, the Structural Design Pattern is used to manage the structure of classes & interfaces, as well as the relationships between classes.
In real-time applications, structural design patterns help to preserve flexibility by allowing changes to class structures or relationships to be made without affecting the project. For example, structural design patterns allow you to change the relationship between classes such as User and Product without affecting the project.
The following is a list of structural design patterns:
The adapter pattern serves as a bridge between two incompatible interfaces. This design uses a single class, adapter, to handle communication between two independent or incompatible interfaces.
A card reader serves as an interface between a memory card and a laptop. You connect the memory card to a card reader and the card reader to the laptop, allowing the laptop to read the memory card.
Examples of adapter patterns include:
The UML class diagram above includes the following classes, interfaces, and objects:
The adapter design pattern is applicable in the following scenarios:
There are two types of Adapter design patterns: