{"id":4936,"date":"2021-09-07T04:28:36","date_gmt":"2021-09-07T04:28:36","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=4936"},"modified":"2021-09-07T05:06:38","modified_gmt":"2021-09-07T05:06:38","slug":"solid-principles-in-c-language","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/","title":{"rendered":"SOLID principles in C# Language"},"content":{"rendered":"<p><strong>Definition:<\/strong> SOLID principles are the design principles that enable us to manage most of the software design problems. SOLID principles provide us with ways to maneuver from tightly coupled code and tiny encapsulation to the specified results of loosely coupled and encapsulated real needs of a business properly. SOLID is an acronym of the following.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles1.png\" alt=\"SOLID principles1\" \/><\/p>\n<h2>S: Single Responsibility Principle (SRP)<\/h2>\n<p>The single-responsibility principle (SRP) states that every class, module, or function in your program should only do one job. In other words, each should have full responsibility for one functionality of the program. The class should contain only variables and methods relevant to its functionality.<br \/>\nClasses can work together to finish larger complex tasks, but each class must complete a function from start to end before it passes the output to a different class.<br \/>\nSRP makes it easy to follow another well-respected principle of OOP, encapsulation. It is easy to keep data secret from the user when all data and methods for a feature are within the single-responsibility class.<br \/>\nIf you add a getter and setter method to a single-responsibility class, then it meets all criteria of an encapsulated class.<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles2.png\" alt=\"SOLID principles2\" \/><\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles3.png\" alt=\"SOLID principles3\"\/><\/br><br \/>\n<strong>Advantage:<\/strong> The advantage of programs that follow SRP is that you simply can change the behavior of a function by editing the only class liable for it. Also, if one functionality breaks, you recognize where the bug is going to be within the code and may trust that only that class will break.<\/p>\n<h3>O: Open-closed principle<\/h3>\n<p>The <strong>open-closed principle (OCP)<\/strong> involves entities that will be widely adopted but also remain unchanged. This leads us to make duplicate entities with specialized behavior through polymorphism.<br \/>\nThrough polymorphism, we may extend our base entity to suit the requirements of the derived entity while leaving the base intact.<br \/>\nOur parent entity will function as an abstract base class which will be reused with added specializations through <a href=\"https:\/\/studysection.com\/blog\/inheritance-and-access-modifiers\/\">inheritance<\/a>. However, the first entity is locked to permit the program to be both open and closed.<br \/>\n<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles4.png\" alt=\"SOLID principles4\" \/><br \/>\n<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles5.png\" alt=\"SOLID principles5\"\/><br \/>\n<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles6.png\" alt=\"principles6\"\/><br \/>\n<\/br><br \/>\n<strong>Advantage:<\/strong>  The advantage of OCP is that it minimizes program risk when you need to add new uses for an entity. Instead of reworking the parent class to fit a work-in-progress feature, you create a derived class break away from the classes currently present throughout the program. We can then work on this unique derived class, confident that any changes we make thereto won&#8217;t affect the parent or the other derived class.<br \/>\nWe can then work on this unique derived class, confident that any changes we make thereto won&#8217;t affect the parent or the other derived class.<\/p>\n<h3>L: Liskov substitution principle<\/h3>\n<p>The principle says that any class must be directly replaceable by any of its subclasses without error. In other words, each subclass must maintain all behavior from the parent class as well as the new behaviors unique to the subclass. The child class must be able to process all the same requests and complete all the existing tasks as its parent class.<br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles7.png\" alt=\"principles7\"\/><br \/>\n<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles8.png\" alt=\"principles8\" \/><br \/>\n<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles9.png\" alt=\"principles9\"\/><br \/>\n<\/br><br \/>\n<strong>Advantage:<\/strong>  The advantage of LSP is that it quickens the development of the latest subclasses as all subclasses of an equivalent type share a uniform use.<br \/>\nYou can trust that each newly created subclasses will work with the prevailing code. If you opt that you simply need a replacement subclass, you&#8217;ll create it without reworking the prevailing code.<\/p>\n<h3>I: Interface segregation principle<\/h3>\n<p>The interface segregation principle (ISP) requires that classes only be ready to perform behaviors that are useful to attain their end functionality. In other words, classes don&#8217;t include behaviors that are not in use.<br \/>\nThis relates to our first SOLID principle in that together these two principles strip a class of all variables, methods, or behaviors that do not directly contribute to their role. Methods must contribute to the main goal in their entirety.<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles10.png\" alt=\"principles10\"\/><br \/>\n<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles11.png\" alt=\"principles11\" \/><br \/>\n<\/br><\/p>\n<h3>D: Dependency inversion principle<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles12.png\" alt=\"principles12\"\/><br \/>\n<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles13.png\" alt=\"principles13\" \/><br \/>\n<\/br><br \/>\n<strong>Advantage:<\/strong> The advantage of DIP is that decoupled programs require less work to change. Webs of dependencies across your program mean that one change can affect many separate parts. The second part may be thought of as \u201cthe abstraction isn&#8217;t affected if the definitions are changed\u201d. The abstraction is mainly the user-facing part of the program.<\/p>\n<p><small><em>People having good knowledge of Financial accounting can get an <a href=\"https:\/\/www.studysection.com\/financial-accounting-advanced\">Accounting Certification Exam<\/a> from StudySection to increase their chances of getting a job in this field. You can get a foundation level certification if you are new to Financial accounting or you can go for advanced level certification if you have expert level skills in Financial accounting.<\/em><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Definition: SOLID principles are the design principles that enable us to manage most of the software design problems. SOLID principles<\/p>\n","protected":false},"author":1,"featured_media":4937,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[142,676],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SOLID principles in C# Language - StudySection Blog<\/title>\n<meta name=\"description\" content=\"SOLID principles provide maneuver from tightly coupled code and tiny encapsulation to loosely coupled and encapsulated business needs.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SOLID principles in C# Language - StudySection Blog\" \/>\n<meta property=\"og:description\" content=\"SOLID principles provide maneuver from tightly coupled code and tiny encapsulation to loosely coupled and encapsulated business needs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Posts on famous people, innovations and educational topics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/studysection\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-07T04:28:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-07T05:06:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin-studysection-blog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@studysection\" \/>\n<meta name=\"twitter:site\" content=\"@studysection\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-studysection-blog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"SOLID principles in C# Language\",\"datePublished\":\"2021-09-07T04:28:36+00:00\",\"dateModified\":\"2021-09-07T05:06:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/\"},\"wordCount\":750,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"keywords\":[\"C\",\"Principles\"],\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/\",\"url\":\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/\",\"name\":\"SOLID principles in C# Language - StudySection Blog\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2021-09-07T04:28:36+00:00\",\"dateModified\":\"2021-09-07T05:06:38+00:00\",\"description\":\"SOLID principles provide maneuver from tightly coupled code and tiny encapsulation to loosely coupled and encapsulated business needs.\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SOLID principles in C# Language\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/studysection.com\/blog\/#website\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"name\":\"Blog Posts on famous people, innovations and educational topics\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/studysection.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/studysection.com\/blog\/#organization\",\"name\":\"StudySection\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"contentUrl\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"width\":920,\"height\":440,\"caption\":\"StudySection\"},\"image\":{\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/studysection\",\"https:\/\/twitter.com\/studysection\",\"https:\/\/www.instagram.com\/study.section\/\",\"https:\/\/www.linkedin.com\/company\/studysection\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\",\"name\":\"admin-studysection-blog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"caption\":\"admin-studysection-blog\"},\"url\":\"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SOLID principles in C# Language - StudySection Blog","description":"SOLID principles provide maneuver from tightly coupled code and tiny encapsulation to loosely coupled and encapsulated business needs.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/","og_locale":"en_US","og_type":"article","og_title":"SOLID principles in C# Language - StudySection Blog","og_description":"SOLID principles provide maneuver from tightly coupled code and tiny encapsulation to loosely coupled and encapsulated business needs.","og_url":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2021-09-07T04:28:36+00:00","article_modified_time":"2021-09-07T05:06:38+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/09\/principles.png","type":"image\/png"}],"author":"admin-studysection-blog","twitter_card":"summary_large_image","twitter_creator":"@studysection","twitter_site":"@studysection","twitter_misc":{"Written by":"admin-studysection-blog","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"SOLID principles in C# Language","datePublished":"2021-09-07T04:28:36+00:00","dateModified":"2021-09-07T05:06:38+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/"},"wordCount":750,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"keywords":["C","Principles"],"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/","url":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/","name":"SOLID principles in C# Language - StudySection Blog","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2021-09-07T04:28:36+00:00","dateModified":"2021-09-07T05:06:38+00:00","description":"SOLID principles provide maneuver from tightly coupled code and tiny encapsulation to loosely coupled and encapsulated business needs.","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/solid-principles-in-c-language\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"SOLID principles in C# Language"}]},{"@type":"WebSite","@id":"https:\/\/studysection.com\/blog\/#website","url":"https:\/\/studysection.com\/blog\/","name":"Blog Posts on famous people, innovations and educational topics","description":"","publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/studysection.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/studysection.com\/blog\/#organization","name":"StudySection","url":"https:\/\/studysection.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","contentUrl":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","width":920,"height":440,"caption":"StudySection"},"image":{"@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/studysection","https:\/\/twitter.com\/studysection","https:\/\/www.instagram.com\/study.section\/","https:\/\/www.linkedin.com\/company\/studysection"]},{"@type":"Person","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402","name":"admin-studysection-blog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","caption":"admin-studysection-blog"},"url":"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/"}]}},"views":697,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/4936"}],"collection":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/comments?post=4936"}],"version-history":[{"count":6,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/4936\/revisions"}],"predecessor-version":[{"id":4956,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/4936\/revisions\/4956"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/4937"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=4936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=4936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=4936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}