Wednesday, 30 December 2020

SOLID Design principles in C#

If you have experience more than 8 years and you are going for interview then interviewer will certainly ask about SOLID. 

You read about SOLID but still you are not able to answer the questions as from SOLID concepts or you are confused by interviewer? Yes there are lot of things which confuses you and even many. 

 Let's discuss each principles one by one. Let's loot at the basic definition of the SOLID 


 1. S - S in SOLID stands for Single Responsibility Principle and we also call it SRP. So what is Responsibility ? In general english Responsibility means a duty to deal with something . Similarly in the programming, every class have its own responsibility, if we mix the responsibility of one class with another then your program might work correctly but you are messing with the code, you are loosing the code maintainability and many things. We will discuss more about this in separate discussion, but for now you can understand is as A class should be created only for doing one JOB for example if you have created class for Printing then your class should be only used for print functionality, you should not add methods which does something else like inserting data to database or calling some web api method. 

 2. O - O in SOLID stands for Open Close Principle and is single line we can say a class should be open for extension and closed for modification. Your class should be extendable without any modification. We also call it OCP. We will discuss more about this principle in other post with examples, its benefits, limitations and many more things.