Posts

SOLID Principles With .NET - Liskov Substitution Principle

Image
 Liskov Substitution Principle           is a fundamental SOLID principle that states " You should be able to use any derived class instead of a parent class and have it to behave in the same manner without modification". It ensures that a derived class does not affect the behaviour of the base class . Before going into implementation of LSP , please do go through the previous article on OCP . We are continuing with the same example . This article is divided into three parts :  - Banking Service without LSP  - Banking Service Example with LSP  - Conclusion And now business want to provide the Additional Compound Interest to Salary Accounts , so in our base abstract class we are now adding another method called CalculateCompundInterest . And our abstract class looks like this  and now the derived classes looks something like below and everything looks fine till there .  Now check the below code which  violate the LSP ...

SOLID Principles With .NET - Single Responsibility Principle

Image
 Single Responsibility Principle                          The acronym SRP states that "A class should take one responsibility and there should be one reason to change that class". In this article I want to share my knowledge on how we can make sure to follow this in our career as a developer . Every software module should have only one reason to change .The single responsibility principle gives you a good way of identifying classes at the design phase of an application.A good separation of responsibilities is done only when we have the full picture of how the application should work .  Now let's go into our example . And to go through SOLID principles , I have taken a real case scenario of a banking system  as an example for clear understanding and to give everyone a wider view about how one should act while he starts to code .  And we have three different sections   ...

SOLID Principles With .NET - Open Closed Principle

Image
The Open Closed Principle           is the SOLID principle which states that the software entities (classes or methods) should be open for extension but closed for modification. Open for extension but closed for modification ? Oh what does it really mean ?  In real time every business requirements changes so frequently, so while developing an application we should strive to write a code that doesn't require modification every time  business changes it requirement. The biggest benefit for an application to be adhered to OCP is, it potentially streamlines code maintenance and reduces the risk of breaking the existing implementation. Here , I will show you how we can implement a requirement with and without OCP rules.  This article is divided into the following sections :  Banking Service - Without  OCP   Example - Without  OCP  implemented  Conclusion     So let's start  Banking Service C...

SOLID Principles

SOLID PRINCIPLES  SOLID is an acronym for 5 important design principles when doing OOP (Object Oriented Programming) Solid Principles are the design principles that enables us to manage most of the software design problems. These principles provide us the way to move from tightly coupled code and little encapsulation to the desired results of loosely coupled and encapsulated real needs of business properly.   Every SOLID principle can be misused and overused . So be sure that as developer make sure to use them when there is need for clean code base on priority .  As said , SOLID is acronym and each of the letters in it stands for :  S -  Single Responsibility Principle (SRP) O - Open Closed Principle (OCP) L -  Liskov Substitution Principle (LSP) I  -  Interface Segregation Principle(ISP) D - Dependency Inversion Principle (DIP) Following this article , next throughout these articles each principle is explained with an explain with and withou...