Behavioral Design Pattern in C#
In this article, I am going to give a brief introduction to Behavioral Design Pattern in C#. Please read our previous article where we discussed the Structural Design Patterns in C# with examples. As part of this article, we are going to discuss the following three things.
- What is Behavioral Design Pattern?
- When to use the Behavioral Design Pattern?
- Examples of Behavioral Design Pattern
What is Behavioral Design Pattern in C#?
According to Wikipedia, in Software Engineering, behavioral design patterns are design patterns that identify common communication patterns among objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication.
The Behavioral Design Patterns deal with the communication or interaction between Classes and objects. The interaction between the objects should be in such a way that they are talking to each other and still are loosely coupled. The loose coupling is the key to n-tier architecture.
So, a behavioral pattern explains how objects interact. It describes how different objects and classes send messages to each other to make things happen and how the steps of a task are divided among different objects.
When to use Behavioral Design Patterns in C#?
In real-time applications, sometimes we want to change the behavior of a class and again we don’t want it to affect other classes of the project. For example, we have an Invoice class that currently applying taxes as 18%. Tomorrow if we want to add another extra tax. That means we are changing the behavior of a class. To solve such types of Behavioral issues Behavioral Design Pattern comes into the picture.
Examples of Behavioral Design Pattern in C#:
The following design patterns belong to the Behavioral Design Pattern category.
- Iterator Design Pattern
- Observer Design Pattern
- Chain of Responsibility Design Pattern
- Interpreter Design Pattern
- Command Design Pattern
- Memento Design Pattern
- Mediator Design Pattern
- State Design Pattern
- Template Method Design Pattern
- Strategy Design Pattern
- Visitor Design Pattern
In the next article, I am going to discuss the Iterator Design Pattern in C# with some examples. Here, in this article, I try to give a brief introduction to Behavioral Design Pattern. I hope you understood the need and use of the Behavioral Design Pattern in C#.