SOLID in C#: The Dependency Inversion Principle

What Is This Principle? The Dependency Inversion Principle is comprised of two rules: High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions. This principle is primarily concerned with reducing dependencies amongst the code modules. We can think of it as needing the low-level objects to define contracts that the high-level objects can use, without the high-level objects needing to care about the specific implementation the... Read more >

SOLID in C# - The Interface Segregation Principle

What Is This Principle? The Interface Segregation Principle states that no client code object should be forced to depend on methods it does not use. Basically, each code object should only implement what it needs, and not be required to implement anything else. Benefits The ISP is all about reducing code objects down to their smallest possible implementation, and removing dependencies the object doesn't need to function properly. The result of implementing this principle, generally speaking, is to have a... Read more >

SOLID in C#: The Liskov Substitution Principle

What Is This Principle? The Liskov Substitution Principle(LSP), named for and originally defined by Barbara Liskov, states that we should be able to treat a child class as though it were the parent class. Essentially this means that all derived classes should retain the functionality of their parent class and cannot replace any functionality the parent provides. The LSP is very similar in principle to the Open/Closed Principle. Benefits This principle aims to keep functionality intact. It's main... Read more >

SOLID in C#: The Open/Closed Principle

What Is This Principle? The Open/Closed Principle, as originally formulated by Bertrand Meyer, states that a given software entity should be open for extension, but closed for modification. Essentially, any given class (or module, or function, etc) should allow for its functionality to be extended, but not allow for modification to its own source code. Benefits This principle aims to reduce the introduction of bugs and other errors into your code by requiring classes to not change their own... Read more >

SOLID in C#: The Single Responsibility Principle

What Is This Principle? The Single Responsibility Principle (SRP) states that any class must have one, and only one, reason to change. If a class has more than one reason to change, it should be refactored. Benefits The primary benefit the Single-Responsibility Principle gives you is high-cohesion, low-coupling code. Cohesion refers to the degree with which elements of code belong together. This means that the level of cohesion between elements is higher if they are related, and lower if they... Read more >