SOLID Principles with Examples in C#

Implementing the Inversion of Control Pattern in C#

SOLID Principles in C# – An Overview

SOLID principles with real world examples



Initial Stands for
Single responsibility principle
class should have only a single responsibility.
Open/closed principle
“software entities … should be open for extension, but closed for modification”.
Liskov substitution principle
“objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program”. See also design by contract.
Interface segregation principle
“many client-specific interfaces are better than one general-purpose interface.”[5]
Dependency inversion principle
one should “Depend upon Abstractions. Do not depend upon concretions.”[5]
Dependency injection is one method of following this principle.


What’s the difference between the Dependency Injection and Service Locator patterns?
“The difference may seem slight, but even with the ServiceLocator, the class is still responsible for creating its dependencies. It just uses the service locator to do it. With DI, the class is given it’s dependencies. It neither knows, nor cares where they come from. One important result of this is that the DI example is much easier to unit test — because you can pass it mock implementations of its dependent objects. You could combine the two — and inject the service locator (or a factory), if you wanted.”


The Principles of Good Programming

3 Key Software Principles You Must Understand–net-25161



Liskov Substitution Principle

Can you explain Liskov Substitution Principle with a good C# example?

Simplifying the Liskov Substitution Principle of SOLID in C#

Liskov Substitution Principle in C#






Moscow Prioritisation

MoSCoW Principle: Must, Should, Could, Would
“MoSCoW is a technique used in management, business analysis, and software development to reach a common understanding with stakeholders on the importance they place on the delivery of each requirement – also known as MoSCoW prioritization or MoSCoW analysis.
According to A Guide to the Business Analysis Body of Knowledge, version 2.0,[1] section, the MoSCoW categories are as follows:”

Moscow Prioritisation
“Must Have, Should Have, Could Have, Won’t Have this time”