.Net

SOLID Principles – Interface Segregation Principle [ISP]

SOLID stands for Single Responsibility Principle [SRP], Open Closed Principle [OCP], Liskov Substitution Principle [LSP], Interface Segregation Principle [ISP] and Dependency Inversion Principle [DIP]. In this article I will explain Interface Segregation Principle [ISP]. This pattern states that once an interface becomes too fat, it needs to be split into smaller interfaces so that client of the interface will only know about the methods that pertain to them. In other words, client should not be forced to depend upon interfaces that they do not use. In the code example defined below, I have declared an interface IDoor which is used…

SOLID Principles – Liskov Substitution Principle [LSP]

SOLID stands for Single Responsibility Principle [SRP], Open Closed Principle [OCP], Liskov Substitution Principle [LSP], Interface Segregation Principle [ISP] and Dependency Inversion Principle [DIP]. In this article I will explain Liskov Substitution Principle [LSP]. This pattern states that functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it. In other words you should always be able to use a base class or interface instead of the actual implementation and still get the expected result. If you can’t, you’re breaking LSP. Lets understand it through example. In below code example…

SOLID Principles – Open Closed Principle [OCP]

SOLID stands for Single Responsibility Principle [SRP], Open Closed Principle [OCP], Liskov Substitution Principle [LSP], Interface Segregation Principle [ISP] and Dependency Inversion Principle [DIP]. In this article I will explain Open Closed Principle [OCP]. This pattern states that software component such as classes, functions etc should be open for extension, but closed for modification. This can be achieved by using inheritance. Software modules that satisfy the open-closed principle have two huge benefits. First, they are “open for extension”. (The behavior of the modules can be altered to satisfy the changing requirements.) Second, these modules are “closed for modification”. (The modules,…

SOLID Principles – Single Responsibility Principle [SRP]

SOLID stands for Single Responsibility Principle [SRP], Open Closed Principle [OCP], Liskov Substitution Principle [LSP], Interface Segregation Principle [ISP] and Dependency Inversion Principle [DIP]. In this article, I will explain Single Responsibility Principle [SRP]. This pattern states that an object should have one and only one responsibility and that responsibility should be completely encapsulated by the class. In other words, a class should have only one reason to change. The point of the Single Responsibility Principle isn’t just to write smaller classes and methods, but to ensure each class implements a cohesive set of related functions. An easy way to…

4 of 4
1234