Structural Design Patterns in C#
In this article, I am going to give a brief introduction to Structural Design Pattern in C#. Please read our previous article where we discussed the Creational Design Patterns in C# with examples. As part of this article, we are going to discuss the following three things.
- What is Structural Design Pattern?
- When to use the Structural Design Pattern?
- Examples of Structural Design Pattern
What is Structural Design Pattern in C#?
According to Wikipedia, in software engineering, Structural Design Patterns are design patterns that ease the design by identifying a simple way to realize the relationship among entities.
This design pattern is all about class and object composition. Structural class creation patterns use inheritance to compose interfaces. The structural object patterns define ways to compose objects to obtain new functionality.
The structural patterns describe how objects and classes can be combined to form larger structures.
When to use Structural Design Patterns in C#?
In real-time applications, sometimes we need to change the structure of a class or the relationship among the classes but we don’t want this change to be affected by the project. For example, if we have two classes let say user and product. And the product class is used inside the user class making one to many relationships between the User and Product. Tomorrow, the structure or the relationships between these two classes change. The customer now wants to keep away the product class from the User class, as they want to use the User and Product class independently. This is actually a structural change and we don’t want this structural change to affect our project. This is where the Structural Design Pattern helps us.
Examples of Structural Design Patterns in C#:
- Adapter Design Pattern
- Facade Design Pattern
- Decorator Design Pattern
- Bridge Design Pattern
- Composite Design Pattern
- Proxy Design Pattern
- Flyweight Design Pattern
In the next article, I am going to discuss the Adapter Design Pattern in C# with some examples. Here, in this article, I try to give a brief introduction to Structural Design Pattern. I hope you understood the need and use of the Structural Design Pattern in C#.