{"id":9809,"date":"2022-04-17T13:13:00","date_gmt":"2022-04-17T07:43:00","guid":{"rendered":"https:\/\/blog.guvi.in\/?p=9809"},"modified":"2026-03-09T15:21:44","modified_gmt":"2026-03-09T09:51:44","slug":"software-design-principles-solid","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/software-design-principles-solid\/","title":{"rendered":"Why do we need to apply -SOLID- software design principles?"},"content":{"rendered":"\n<p>What are software design principles? And why it&#8217;s a right-hand thumb rule to apply certain design principles in software engineering? For those unfamiliar with the term, Software engineering is a systematic &amp; procedural approach to software development. <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-style-default\">\n<p>Being in the IT industry for 7 Years, I was lucky to work with multiple companies from early age- startups to Fortune 500. Most of them were very different in their work procedures &amp; work ethics. Yet, Surprisingly similar in one area: lowering the expenses at the detremint of proper system architecture. <\/p>\n<cite>-A System Architect <\/cite><\/blockquote>\n\n\n\n<p>Before we begin with our System Design Principles, let&#8217;s fuss over the definition of &#8220;Technical Debt.&#8221; Technical Debt is the result we get when we prioritize the speedest deployment over code. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Technical Debt??<\/h2>\n\n\n\n<ul>\n<li>No matter how skilled your team is, technical debt will accumulate over time. <\/li>\n\n\n\n<li>If it goes unchecked, technical debt will entirely kill your project. <\/li>\n\n\n\n<li>To ensure that your project remains working, use SOLID principles during your development. <\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-medium\"><img decoding=\"async\" width=\"300\" height=\"264\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-2022-03-31-at-4.05.34-PM-300x264.png\" alt=\"Technical Debt - software design principles\" class=\"wp-image-9815\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-2022-03-31-at-4.05.34-PM-300x264.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-2022-03-31-at-4.05.34-PM-1163x1024.png 1163w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-2022-03-31-at-4.05.34-PM-768x676.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-2022-03-31-at-4.05.34-PM.png 1372w\" sizes=\"(max-width: 300px) 100vw, 300px\" title=\"\"><figcaption class=\"wp-element-caption\"><meta charset=\"utf-8\">Credit: VINCENTDNL<\/figcaption><\/figure><\/div>\n\n\n<p>If you are familiar with OOPS, then you must have heard about SOLID principles. These five software development serves as a foundation for building software products that are easier to scale &amp; maintain. <\/p>\n\n\n\n<p>However, there are serious consequences of not using SOLID principles such as <strong>Rigidity, Immobility, Coupling &amp; viscosity. <\/strong><\/p>\n\n\n\n<ul>\n<li><strong>RIGIDITY: <\/strong>Software implementation that is hard to change. <\/li>\n\n\n\n<li><strong>Immobility: <\/strong>Deployment which is difficult to reuse. <\/li>\n\n\n\n<li><strong>Viscosity: <\/strong>Difficult to add on new features in a systematic manner. <\/li>\n\n\n\n<li><strong>Coupling: <\/strong>Issues related to interdependency. <\/li>\n\n\n\n<li><strong>Fragility: <\/strong>It&#8217;s easy to break the implemented code. <\/li>\n<\/ul>\n\n\n\n<p>Further in this article, we&#8217;ll discuss the SOLID software design principles In detail. Read till the end, and you will learn several tips that can save you time &amp; trouble while writing code. <\/p>\n\n\n\n<p>Interested in switching to Full-stack development career? Ensure you&#8217;re solid on full-stack development essentials like front-end frameworks, back-end technologies, and database management. Join HCL GUVI\u2019s<strong> <a href=\"https:\/\/www.guvi.in\/zen-class\/full-stack-development-course\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=software-design-principles-solid\" target=\"_blank\" rel=\"noreferrer noopener\">Full Stack Development Course<\/a><\/strong> with Placement Assistance. You will be able to master the <a href=\"https:\/\/www.guvi.in\/blog\/guide-for-mern-stack\/\" target=\"_blank\" rel=\"noreferrer noopener\">MERN stack<\/a> (MongoDB, Express.js, React, <a href=\"https:\/\/www.guvi.in\/blog\/guide-for-nodejs-as-backend\/\" target=\"_blank\" rel=\"noreferrer noopener\">Node.js<\/a>) and build real-life projects.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">SOLID-An integral part of Software Design Principles <\/h2>\n\n\n\n<p>Solid is an acronym for 5 software design principles that assists us to keep technical debt under control.<\/p>\n\n\n\n<p>The main goal of SOLID is to make you &amp; your tech team more productive which can only happen if the whole code is maintainable through decoupling and decomposition. Let&#8217;s deconstruct SOLID principles into their letters. <\/p>\n\n\n\n<p><strong><em><a href=\"http:\/\/guvi.spellzee.in\/full-stack-development-syllabus-2021-the-complete-guide\/?utm_source=GUVI-Website&amp;utm_medium=BLOG&amp;utm_campaign=Software-design-principles+&amp;utm_content=BLOG_SOLID\" target=\"_blank\" rel=\"noopener\"><\/a><strong><em><a href=\"https:\/\/www.guvi.in\/blog\/full-stack-developer-syllabus\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/blog\/full-stack-developer-syllabus\/\" rel=\"noreferrer noopener\"> ROADMAP TO FULL STACK DEVELOPMENT + SYLLABUS  (UPDATED) <\/a><\/em><\/strong><\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">S&#8211;Single Responsibility Principle (SRP) <\/h2>\n\n\n\n<p class=\"has-text-align-center has-white-color has-black-background-color has-text-color has-background\"><em>A class, function, or module should have a single responsibility. They all should have only one reason to change.<\/em><\/p>\n\n\n\n<p>If a class, module, or function has many responsibilities, it increases the probability of bugs. Making a crucial change to one of its responsibilities could affect the other ones without the developer&#8217;s knowledge. To comprehend it in easy words &#8220;Responsibility&#8221; can be defined as a reason to change, and each entity should have one, and only one reason to change. <\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong>One reason to change  = &gt; one responsibility!<\/strong><\/p>\n\n\n\n<p>The main objective of this principle is<strong> decoupling. <\/strong>If classes will have a separate behavior, and in case a bug arrives, it won&#8217;t hamper other unrelated behaviors. Thus creating an organized hierarchy in software design. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What If SRP is absent? <\/h3>\n\n\n\n<ul>\n<li>Code is hard to read &amp; comprehend. <\/li>\n\n\n\n<li>High rate of coupling. <\/li>\n\n\n\n<li>We unintentionally create a God Class or Monster Method. ( A class\/method that controls way too many objects in the code and has grown beyond all logic to comprehend) <\/li>\n\n\n\n<li>Multiple If\/switch statements &#8211; a clear indication that the method has more than one reason to change. <\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">O&#8211;Open closed principle (OCP)<\/h2>\n\n\n\n<p class=\"has-text-align-center has-white-color has-black-background-color has-text-color has-background\"><em>Class, modules,<\/em> or functions should be open for extensibility but closed<em> for modification. Although, BUG fixing is okay.<\/em><\/p>\n\n\n\n<p>Modifications are an integral part of software design &amp; its evolution. But if you have already upgraded to a stable build, modifications can trigger instability. Hence for a right-hand thumb rule avoid modifications, rather evolution should progress based on extension. <\/p>\n\n\n\n<p>The principle is eminent in Production! For instance-open source libraries. The premise is that if a developer has created and published some class modification in the class can break the implementation of those, who have started using this specific class. <\/p>\n\n\n\n<p>OCP was originally described in the context of inheritance, where you should always prefer composition over inheritance as it is easier\/malleable to modify later. OCP minimizes the risk of regression bugs &amp; enforces decoupling by isolating changes in specific components. Nevertheless, It&#8217;s not the hard end rule? <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3813\">Should we use OCP every time? No. <\/h3>\n\n\n\n<ul>\n<li>Start small -&gt; Make changes inline<\/li>\n\n\n\n<li>More changes -&gt; Consider inheritance<\/li>\n\n\n\n<li>Many changes\/dynamic decisions -&gt; consider interface and design patterns like Strategy<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">L&#8211;Liskov Substitution Principles (LSP) <\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-style-default\">\n<p><em>Subsets should be subsituatble for their base type. <\/em><\/p>\n<cite>Barbara Liskov, 1987<\/cite><\/blockquote>\n\n\n\n<p>If A is a subtype of B then all the objects of type B in a program may be replaced with objects of type A without altering any of the desirable properties of that program. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1142\" height=\"1024\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_yKk2XKJaCLNlDxQMx1r55Q-1142x1024.png\" alt=\"Liskov_Substitution_Principles\" class=\"wp-image-9818\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_yKk2XKJaCLNlDxQMx1r55Q-1142x1024.png 1142w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_yKk2XKJaCLNlDxQMx1r55Q-300x269.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_yKk2XKJaCLNlDxQMx1r55Q-768x688.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_yKk2XKJaCLNlDxQMx1r55Q.png 1400w\" sizes=\"(max-width: 1142px) 100vw, 1142px\" title=\"\"><\/figure>\n\n\n\n<p>The principle explains how <strong>polymorphism <\/strong>should work, and not how it actually works, but how it should work. Needless to say, achieving clean substitution of the entities is not easy as it sounds. There are 6 rules to ensure  LSP. <\/p>\n\n\n\n<ol>\n<li>Pre-Condition -&gt; Preceding condition of the subtype should not be more restrictive than the supertype<\/li>\n\n\n\n<li>Invariance -&gt; In some cases, the same type should be strictly used throughout<\/li>\n\n\n\n<li>Post-condition Rule -&gt; Trailing condition of the subtype should not be less restrictive than the supertype<\/li>\n\n\n\n<li>Contra-variance of Methods Arguments&nbsp;(inputs) -&gt; Method arguments of subtype should be more generic than the subtype<\/li>\n\n\n\n<li>Covariance of Return Types&nbsp;(outputs) -&gt; Return types of the supertype should be more generic than the subtype <\/li>\n\n\n\n<li>No exceptions are allowed  -&gt; No new exception should be thrown in the subtype which is not there in the supertype<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">I&#8211;Interface Segregation Principle (ISP)<\/h2>\n\n\n\n<p class=\"has-text-align-center has-white-color has-black-background-color has-text-color has-background\"><em>An ideology that no client should be forced to depend upo<\/em>n the interfaces that they do not use. <\/p>\n\n\n\n<p>Many methods are written in a single large interface, and the class implementing that interface has to implement redundant methods. When a class is instructed to execute an action that is not useful or wasteful, it may trigger unexpected bugs. instead of this, we should split the interface into multiple smaller interfaces. So that we can keep the methods in the interface as granular as possible. Avoid redundancy. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"601\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_2hmyR9L43Vm64MYxj4Y89w-1200x601.png\" alt=\"Interface-Segregation-software-design-principels-SOLID\" class=\"wp-image-9819\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_2hmyR9L43Vm64MYxj4Y89w-1200x601.png 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_2hmyR9L43Vm64MYxj4Y89w-300x150.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_2hmyR9L43Vm64MYxj4Y89w-768x385.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_2hmyR9L43Vm64MYxj4Y89w.png 1400w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<p>Please note that &#8220;interface&#8221; in the above principle name does not strictly adhere to the interface, it could be an abstract class. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The benefits of applying ISP<\/h3>\n\n\n\n<ul>\n<li>Code becomes more succinct and focused. <\/li>\n\n\n\n<li>It reinforces the use of LSP &amp; SRP. <\/li>\n\n\n\n<li>It leans the interface, minimizes redundancy on unsued members, and reduces code coupling. <\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">D&#8211;Dependency Inversion Principle <\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-columns is-layout-flex wp-container-3 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<p class=\"has-white-color has-black-background-color has-text-color has-background has-medium-font-size\"><em>High-level modules should not depend on low-level modules. In fact, Both should be dependent on abstraction. <\/em><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:50%\">\n<p class=\"has-white-color has-black-background-color has-text-color has-background has-medium-font-size\"><em>Abstraction should not rely on details, details should rely on abstraction.     <\/em>                                                  <\/p>\n<\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<p>Sometimes modules with great complex structures come under scrutiny when we modify or update modules at a much lower level. This is a horrifying experience for any software developer especially when software needs frequent revamp. SOLID&#8217;s last principle dependency inversion principle solves the specific issue using a key rule that High-level modules &amp; low-level modules should never be codependent. Entities must depend on abstractions, not on concretions. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"628\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Dependency-Inversion-1200x628.png\" alt=\"Dependency_Inversion_Principle \" class=\"wp-image-9820\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Dependency-Inversion-1200x628.png 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Dependency-Inversion-300x157.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Dependency-Inversion-768x402.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Dependency-Inversion-1536x804.png 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Dependency-Inversion-2048x1072.png 2048w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<p>This principle says a Class should not be fused with the tool it uses to execute an action. Rather, it should be fused to the interface that will allow the tool to connect to the Class. if you are working on Spring Framework, you might be familiar with this principle. <\/p>\n\n\n\n<p>It also says that both the Class and the interface should not know how the tool works. However, the tool needs to meet the specification of the interface. Thus reducing the dependency of high-level classes on a low-level classes by introducing an interface.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping up<\/h2>\n\n\n\n<p>So we have summarized five integral pillars of software design principles. These SOLID principles will help you make your code easy to adjust, extend and test with little to no problems.<\/p>\n\n\n\n<p>For more such engaging &amp; thoughtful content on <a href=\"https:\/\/www.guvi.in\/blog\/is-software-development-hard\/\" target=\"_blank\" rel=\"noreferrer noopener\">Software development<\/a>, enroll in HCL GUVI&#8217;s <a href=\"https:\/\/www.guvi.in\/zen-class\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=software-design-principles-solid\" target=\"_blank\" rel=\"noreferrer noopener\">Career Programs<\/a> offering a springboard for knowledge &amp; deep dive into in-demand streams: <em>Full Stack Development, Data Science, Automation Testing, Data Engineering<\/em>, UI UX Design &amp; more.<\/p>\n\n\n\n<p>It&#8217;s Industry&#8217;s leading live online class platform, that offers placement support &amp; IIT-M recognized <a href=\"https:\/\/www.guvi.in\/blog\/highest-paying-it-certifications-in-india\/\" target=\"_blank\" rel=\"noreferrer noopener\">certifications<\/a>. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.guvi.in\/zen-class\/full-stack-development-course\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1200\" height=\"628\" src=\"http:\/\/blog.guvi.in\/wp-content\/uploads\/2022\/06\/Discovery-FSD-3-1200_628-1200x628.png\" alt=\"Full Stack development course banner\" class=\"wp-image-9758\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Discovery-FSD-3-1200_628-1200x628.png 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Discovery-FSD-3-1200_628-300x157.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Discovery-FSD-3-1200_628-768x402.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Discovery-FSD-3-1200_628-1536x804.png 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/Discovery-FSD-3-1200_628-2048x1072.png 2048w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>What are software design principles? And why it&#8217;s a right-hand thumb rule to apply certain design principles in software engineering? For those unfamiliar with the term, Software engineering is a systematic &amp; procedural approach to software development. Being in the IT industry for 7 Years, I was lucky to work with multiple companies from early [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":9814,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[294],"tags":[],"views":"6346","authorinfo":{"name":"Tushar Vinocha","url":"https:\/\/www.guvi.in\/blog\/author\/tushar\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_wrxj0oBKpA_GXb8LPhXOeg-300x111.png","jetpack_featured_media_url":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/06\/1_wrxj0oBKpA_GXb8LPhXOeg.png","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/9809"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=9809"}],"version-history":[{"count":18,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/9809\/revisions"}],"predecessor-version":[{"id":103294,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/9809\/revisions\/103294"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/9814"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=9809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=9809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=9809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}