Design Pattern

What Is the Mediator Design Pattern and When to Use It in C#?

The Mediator design pattern is a behavioral pattern that allows objects to communicate with each other without knowing the identities of their peers. Instead, objects communicate through a mediator object, which acts as an intermediary between them. In C#, the Mediator pattern can be implemented by creating a mediator interface that defines the methods that the objects will use to communicate, and a concrete mediator class that implements the interface. The objects that need to communicate with each other will also need to implement the same i…

Solid Principles in C# - Explore the Open Closed Principle

From the five solid principles, the Open Closed Principle has been the hardest for me to understand and apply in my C# and ASP.NET MVC projects. Some time ago, however, I came across some code that I had written years ago that made me think this is clearly violating the Open Closed Principle. I was planning to reuse this code in the project I was currently working on, but I realized that I would have to rewrite it to adhere to OCP in order to achieve my goal of writing clean code that fits with my design and flexibility goals. The case – pro…

Understanding the Open/Closed Principle with C# Examples

Photo Credit: unsplash/crisdinoto In this post, we are going to learn about the Open/Closed Principle which  is one of the five SOLID design principles described by Robert C. Martin .  What is the Open/Closed Principle? First, let’s summarize the core definition of what the Open/Closed Principle is.  The Open-Closed Principle (OCP) states that software entities (classes, modules, methods, etc.) should be open for extension, but closed for modification. In other words, with this principle, we will …

List of .NET Dependency Injection Containers (IOC)

When designing a software application, a major concern is that the design must be loosely coupled because loose coupling offers greater reusability, maintainability, and testability. Dependency Injection (DI) reduces the coupling between classes and moves the binding of abstraction and concrete implementation out of the dependent class. Dependency Injection enables developers to better manage future code changes and complexity in our software, thus helping us to make our code maintainable. Dependency …

Load More
That is All