Can you explain in simple and short sentence SOLID?
It’s an acronym of five object oriented design principles which when applied together make our system an easy maintenance system.
It simply helps us to avoid the bad design.
Five principles are
- S – SRP – Single Responsibility Principle
Every software module should have only one reason to change
- O – OCP – Open closed principle
Software modules should be closed for modifications but open for extension
- L – LSP – Liskov substitution principle
Subclasses should be substitutable for base classes.
- I – ISP– Interface Segregation principle
Clients should not be forced to implement interfaces they don’t use. OR Many client specific interfaces are better than one general purpose interface
- D – DIP– Dependency Inversion principle
High level modules should not depend upon low level modules. Rather, both should depend upon abstractions
IS SOLID a Design Pattern
No, Design patterns are reusable solutions for commonly occurring problems in software programming whereas SOLID is a set of principles, we can call it guidelines which let us create system where every part will be loosely attached to every other part.
SRP – What is mean by “module” and “Reason to change” in explanation?
Module - May be class, function, namespace
Reason to change – Responsibility.
Every Modules should contain only one responsibility. Here the word responsibility depends on the context where we are talking like, when we say module as class responsibility indicates “database responsibility”, “reporting responsibility” etc., when we say module as function it indicates “Generating xml from list”, “using generated xml for inserting multiple records into sql”.
OCP – Can you name some techniques using which we can expose new functionality to client without touching existing code?
There are various ways achieving it. Some are,
- Using Extension methods in .net 3.5
- By creating derived classes
For live trainings on various technical trainings like MVC, WCF, Design patterns, ALM with VSTS, WPF etc visit www.Sukesh-Marla.com or contact SukeshMarla@Gmail.com
- MVC interview questions with answers http://www.codeproject.com/Articles/556995/MVC-interview-questions-with-answers
- Entity framework interview questions with answers http://www.codeproject.com/Articles/676309/ADO-NET-Entity-Framework-Interview-Questions
- 500 .NET and C# interview questions and answers video collection site www.questpond.com
- Awesome .NET interview question book by bpb publications http://www.flipkart.com/net-interview-questions-6th/p/itmdyuqzdqx8cvqx
- 40 important HTML 5 interview questions with answer list http://www.codeproject.com/Articles/702051/40-important-HTML-5-Interview-questions-with-answers
- JQUERY and JSON interview question list http://beyondrelational.com/modules/2/blogs/1016/posts/19729/jquery-and-json-interview-questions-with-answer.aspx