{"id":25523389,"date":"2022-05-08T15:14:16","date_gmt":"2022-05-08T09:44:16","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25523389"},"modified":"2022-11-23T20:04:00","modified_gmt":"2022-11-23T14:34:00","slug":"solid-design-principle-java-an-overview","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/","title":{"rendered":"SOLID Design Principle Java? An Overview"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e4d424d8704\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e4d424d8704\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#_SOLID_Design_Principles_in_Java_Application_Development\" >\u00a0SOLID Design Principles in Java Application Development<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#What_Are_SOLID_Design_Principles\" >What Are SOLID Design Principles?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#SOLID_Design_Principles\" >SOLID Design Principles<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#Final_Thoughts\" >Final Thoughts<\/a><\/li><\/ul><\/nav><\/div>\n<div class=\"b_module_expansion\">\n<div class=\"b_expansion_wrapper b_collapse b_onpage_expansion\" role=\"button\">\n<div class=\"b_expansion_text b_1linetrunc\" aria-label=\"What is the solid design principle in programming?\"><\/div>\n<\/div>\n<\/div>\n<div id=\"wire1\" class=\"b_expandable_inline_container\" data-rinterval=\"-1\" data-errormessage=\"We can't find any more info about this page right now\">\n<div class=\"df_alsocon b_primtxt\" data-tag=\"RelatedQnA.ItemDetails\">\n<div class=\"rwrl rwrl_small rwrl_padref\">SOLID refers to five design principles in object-oriented programming, designed to reduce code rot and improve the value, function, and maintainability of software. The SOLID principles help the user to develop less coupled code. If code is tightly coupled, a group of classes are dependent on one another. This should be avoided for better maintainability and readability.<\/div>\n<div>\n<h3><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25494072 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square.png\" alt=\"\" width=\"345\" height=\"345\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square.png 345w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-300x300.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-150x150.png 150w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-24x24.png 24w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-48x48.png 48w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-96x96.png 96w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-75x75.png 75w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/a><\/h3>\n<\/div>\n<div><\/div>\n<div>\n<h2><span class=\"ez-toc-section\" id=\"_SOLID_Design_Principles_in_Java_Application_Development\"><\/span><strong><span class=\"field field--name-title field--type-string field--label-hidden\">\u00a0SOLID Design Principles in Java Application Development<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<\/div>\n<\/div>\n<div>\n<p>SOLID refers to five design principles in object-oriented programming, designed to reduce code rot and improve the value, function, and maintainability of software. The SOLID principles help the user develop less coupled code. If code is tightly coupled, a group of classes are dependent on one another.<\/p>\n<p>Here, we give an overview of each SOLID principle along with an example of each.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"What_Are_SOLID_Design_Principles\"><\/span><strong>What Are SOLID Design Principles?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>SOLID principles are object-oriented design concepts that, in conjunction with an extensive test suite, help you avoid code rot.<\/p>\n<p>SOLID design is an acronym for the following five principles:<\/p>\n<ul>\n<li>Single Responsibility Principle<\/li>\n<li>Open-Closed Principle<\/li>\n<li>Liskov Substitution Principle<\/li>\n<li>Interface Segregation Principle<\/li>\n<li>Dependency Inversion Principle<\/li>\n<\/ul>\n<p>These principles provide a valuable standard for guiding developers away from such \u201ccode rot,&#8221; and instead help them move towards building applications that provide lasting value for customers and sanity for future developers working on your project.<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Grab the opportunity to learn Java with Entri! Click Here<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"SOLID_Design_Principles\"><\/span><strong>SOLID Design Principles<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><a id=\"srp\"><\/a><strong>1. Single Responsibility Principle (SRP)<\/strong><\/h3>\n<p>The Single Responsibility Principle (SRP) says that there should not be more than one reason for a class to change. This means that every class in your code should have only one job to do.<\/p>\n<p>Everything in the class should be related to that single purpose. It does\u00a0<strong>not<\/strong>\u00a0mean that your classes should only contain one method or property.<\/p>\n<p>There can be a lot of members as long as they relate to the single responsibility. It may be that when the one reason to change occurs, multiple members of the class may need modification. It may also be that multiple classes will require updates.<\/p>\n<p>For example:<\/p>\n<pre><code class=\" hljs cs\">class Employee {\r\n<span class=\"hljs-keyword\">public<\/span> Pay <span class=\"hljs-title\">calculatePay<\/span>() {...}\r\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">save<\/span>() {...}\r\n<span class=\"hljs-keyword\">public<\/span> String <span class=\"hljs-title\">describeEmployee<\/span>() {...}\r\n}\r\n<\/code><\/pre>\n<p>Here we have to pay calculation logic with database logic and reporting logic all mixed up within one class. If you have multiple responsibilities combined into one class, it might be difficult to change one part without breaking others.<\/p>\n<p>The easiest way to fix this is to split the class into three different classes, with each having only one responsibility: database access, calculating pay, and reporting, all separated.<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<h3><strong><a id=\"ocp\"><\/a>2. Open-Closed Principle (OCP)<\/strong><\/h3>\n<p>The Open-Closed Principle (OCP) states that classes should be open for extension but closed for modification. \u201cOpen to extension\u201d means that you should design your classes so that new functionality can be added as new requirements are generated. \u201cClosed for modification\u201d means that once you have developed a class you should never modify it, except to correct bugs.<\/p>\n<p>These two parts of the principle appear to be contradictory. However, if you correctly structure\u00a0classes and their dependencies, you can add functionality without editing existing source code.<\/p>\n<p>Applying OCP to your projects reduces the need to change source code once it has been written, tested, and debugged. This reduces the risk of introducing new bugs to existing code, leading to more robust software.<\/p>\n<h4><strong>Open-Closed Principle Example<\/strong><\/h4>\n<p>Another side effect of the use of interfaces for dependencies is reduced coupling (i.e. when changing code in class A forces related changes in class B), and increased flexibility.<\/p>\n<pre><code class=\" hljs cs\"><span class=\"hljs-keyword\">void<\/span> checkOut(Receipt receipt) {\r\n  Money total = Money.zero;\r\n  <span class=\"hljs-keyword\">for<\/span> (item : items) {\r\n    total += item.getPrice();\r\n    receipt.addItem(item);\r\n  }\r\n  Payment p = acceptCash(total);\r\n  receipt.addPayment(p);\r\n}<\/code><\/pre>\n<p>So how do we add credit card support? You could add an \u201cif\u201d statement like this, but then that would be violation of OCP.<\/p>\n<pre><code class=\" hljs bash\">Payment p;\r\n<span class=\"hljs-keyword\">if<\/span> (credit)\r\n  p = acceptCredit(total);\r\n<span class=\"hljs-keyword\">else<\/span>\r\n  p = acceptCash(total);\r\nreceipt.addPayment(p);<\/code><\/pre>\n<p>Here is a better solution:<\/p>\n<pre><code class=\" hljs cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">interface<\/span> PaymentMethod {<span class=\"hljs-keyword\">void<\/span> acceptPayment(Money total);}\r\n\r\n<span class=\"hljs-keyword\">void<\/span> checkOut(Receipt receipt, PaymentMethod pm) {\r\n  Money total = Money.zero;\r\n  <span class=\"hljs-keyword\">for<\/span> (item : items) {\r\n    total += item.getPrice();\r\n    receipt.addItem(item);\r\n  }\r\n  Payment p = pm.acceptPayment(total);\r\n  receipt.addPayment(p);\r\n}<\/code><\/pre>\n<p>Keep in mind \u2013 OCP helps only if the changes that are going to come are predictable, so you should apply it only if a similar change has already happened. So, first do the simplest thing and then see what changes are requested so you can more accurately predict the future changes.<\/p>\n<h3><strong><a id=\"lsp\"><\/a>3. Liskov Substitution Principles (LSP)<\/strong><\/h3>\n<p>The Liskov Substitution Principle (LSP) applies to inheritance hierarchies, specifying that you should design your classes so that client dependencies can be substituted with subclasses without the client knowing about the change.<\/p>\n<p>All subclasses must, therefore, operate in the same manner as their base classes. The specific functionality of the subclass may be different but must match to the expected behavior of the base class. The subclass must not only implement the methods and properties of the base class, but also conform to its implied behavior.<\/p>\n<p>In general, if a subtype of the supertype does something that the client of the supertype does not expect, then this is in violation of LSP. Imagine a derived class throwing an exception that the superclass does not throw, or if a derived class has some unexpected side effects. Basically, derived classes should never do less than their base class.<\/p>\n<p>A typical example that violates LSP is a Square class that derives from a Rectangle class. The Square class always assumes that the width is equal with the height. If a Square object is used in a context where a Rectangle is expected, unexpected behavior may occur because the dimensions of a Square cannot (or rather should not) be modified independently.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><strong>Learn to code from industry experts! Enroll here<\/strong><\/a><\/p>\n<h4><strong>Liskov Substitution Principle Example<\/strong><\/h4>\n<p>This problem cannot be easily fixed: if we can modify the setter methods in the Square class so that they preserve the Square invariant (i.e., keep the dimensions equal), then these methods will weaken (violate) the post-conditions for the Rectangle setters, which state that dimensions can be modified independently.<\/p>\n<pre><code class=\" hljs cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> Rectangle {\r\n  <span class=\"hljs-keyword\">private<\/span> <span class=\"hljs-keyword\">double<\/span> height;\r\n  <span class=\"hljs-keyword\">private<\/span> <span class=\"hljs-keyword\">double<\/span> width;\r\n\r\n  <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">double<\/span> <span class=\"hljs-title\">area<\/span>();\r\n\r\n  <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">setHeight<\/span>(<span class=\"hljs-keyword\">double<\/span> height);\r\n  <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">setWidth<\/span>(<span class=\"hljs-keyword\">double<\/span> width);\r\n}<\/code><\/pre>\n<p>What you see above violates LSP.<\/p>\n<pre><code class=\" hljs java\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Square<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title\">Rectangle<\/span> {<\/span>  \r\n  <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">setHeight<\/span>(<span class=\"hljs-keyword\">double<\/span> height) {\r\n    <span class=\"hljs-keyword\">super<\/span>.setHeight(height);\r\n    <span class=\"hljs-keyword\">super<\/span>.setWidth(height);\r\n  }\r\n\r\n  <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">setWidth<\/span>(<span class=\"hljs-keyword\">double<\/span> width) {\r\n    setHeight(width);\r\n  }\r\n}<\/code><\/pre>\n<p>Violations of LSP cause undefined behavior, which can lead to weeks of wasted time trying to find out where the bug is.<\/p>\n<h3><strong><a id=\"isp\"><\/a>4. Interface Segregation Principle (ISP)<\/strong><\/h3>\n<p>The Interface Segregation Principle (ISP) states that clients should not be forced to depend upon interface members they do not use. When we have non-cohesive interfaces, the ISP guides us to create multiple, smaller and cohesive interfaces.<\/p>\n<p>When you apply ISP, classes and their dependencies communicate using tightly-focused interfaces, minimizing dependencies on unused members and reducing coupling accordingly. Smaller interfaces are easier to implement, improving flexibility and the possibility of reuse. As fewer classes share these interfaces, the number of changes that are required in response to an interface modification is lowered, which increases robustness.<\/p>\n<h4><strong>Interface Segregation Principle Example<\/strong><\/h4>\n<p>Picture an ATM, which has a screen where we wish to display different messages.\u00a0If you want to add a message on the ATM that appears only for withdrawal functionality,\u00a0how would you solve it?<\/p>\n<p>Perhaps you would add a method to the Messenger interface and be done with it. But this causes you to recompile all the users of this interface and almost all the system needs to be changed, which is in direct violation of OCP.<\/p>\n<p>What happened here was that changing the withdrawal functionality caused changes to other totally unrelated functionalities as well, which is something we now know we don&#8217;t want. How did this happen?<\/p>\n<p>Actually, there is backwards dependency at play, where each functionality that uses this Messengers interface depends on methods it does not need but are needed by other functionalities. Here is what we want to avoid:<\/p>\n<pre><code class=\" hljs cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">interface<\/span> Messenger {\r\n  askForCard();\r\n  tellInvalidCard();\r\n  askForPin();\r\n  tellInvalidPin();\r\n  tellCardWasSiezed();\r\n  askForAccount();\r\n  tellNotEnoughMoneyInAccount();\r\n  tellAmountDeposited();\r\n  tellBalance();\r\n}<\/code><\/pre>\n<p>Instead, split the Messenger interface up so that different ATM functionality depend on separate Messengers.<\/p>\n<pre><code class=\" hljs php\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">LoginMessenger<\/span> {<\/span>\r\n  askForCard();\r\n  tellInvalidCard();\r\n  askForPin();\r\n  tellInvalidPin();\t\r\n}\r\n\r\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-class\"><span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">WithdrawalMessenger<\/span> {<\/span>\r\n  tellNotEnoughMoneyInAccount();\r\n  askForFeeConfirmation();\r\n}\r\n\r\npublc <span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">EnglishMessenger<\/span> <span class=\"hljs-keyword\">implements<\/span> <span class=\"hljs-title\">LoginMessenger<\/span>, <span class=\"hljs-title\">WithdrawalMessenger<\/span> {<\/span>\r\n  ...\t\r\n}<\/code><\/pre>\n<h3><a id=\"dip\"><\/a><strong>5. Dependency Inversion Principle (DIP)<\/strong><\/h3>\n<p>The Dependency Inversion Principle (DIP) states that high-level modules should not depend upon low-level modules , they should depend on abstractions.<\/p>\n<p>Also, abstractions should not depend upon details, details should depend upon abstractions. The idea is that we isolate our class behind a boundary formed by the abstractions it depends on. If all the details behind those abstractions change, then our class is still safe. This helps keep coupling low and makes our design easier to change. DIP also allows us to test things in isolation.<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Grab the opportunity to learn Java with Entri! Click Here<\/a><\/strong><\/p>\n<h4><strong>Dependency Inversion Principle Example<\/strong><\/h4>\n<p>Example: A program depends on Reader and Writer interfaces that are abstractions, and Keyboard and Printer are details that depend on those abstractions by implementing those interfaces. Here CharCopier is oblivious to the low-level details of Reader and Writer implementations and thus you can pass in any Device that implements the Reader and Writer interface and CharCopier would still work correctly.<\/p>\n<pre><code class=\" hljs cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">interface<\/span> Reader { <span class=\"hljs-keyword\">char<\/span> getchar(); }\r\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">interface<\/span> Writer { <span class=\"hljs-keyword\">void<\/span> putchar(<span class=\"hljs-keyword\">char<\/span> c)}\r\n\r\nclass CharCopier {\r\n\r\n  <span class=\"hljs-keyword\">void<\/span> copy(Reader reader, Writer writer) {\r\n    <span class=\"hljs-keyword\">int<\/span> c;\r\n    <span class=\"hljs-keyword\">while<\/span> ((c = reader.getchar()) != EOF) {\r\n      writer.putchar();\r\n    }\r\n  }\r\n}\r\n\r\n<span class=\"hljs-keyword\">public<\/span> Keyboard implements Reader {...}\r\n<span class=\"hljs-keyword\">public<\/span> Printer implements Writer {\u2026}<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Final_Thoughts\"><\/span><strong>Final Thoughts<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25494072 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square.png\" alt=\"\" width=\"345\" height=\"345\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square.png 345w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-300x300.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-150x150.png 150w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-24x24.png 24w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-48x48.png 48w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-96x96.png 96w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2021\/10\/Web-Development-Square-75x75.png 75w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/a><\/h3>\n<p>SOLID principles are valuable tools in your toolbox, ones you should keep them in back of your mind when designing your next feature or application.<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>SOLID refers to five design principles in object-oriented programming, designed to reduce code rot and improve the value, function, and maintainability of software. The SOLID principles help the user to develop less coupled code. If code is tightly coupled, a group of classes are dependent on one another. This should be avoided for better maintainability [&hellip;]<\/p>\n","protected":false},"author":111,"featured_media":25523529,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1882],"tags":[],"class_list":["post-25523389","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-java-programming"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SOLID Design Principle Java? An Overview - Entri Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SOLID Design Principle Java? An Overview - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"SOLID refers to five design principles in object-oriented programming, designed to reduce code rot and improve the value, function, and maintainability of software. The SOLID principles help the user to develop less coupled code. If code is tightly coupled, a group of classes are dependent on one another. This should be avoided for better maintainability [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-08T09:44:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-23T14:34:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Feeba Mahin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Feeba Mahin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/\"},\"author\":{\"name\":\"Feeba Mahin\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36\"},\"headline\":\"SOLID Design Principle Java? An Overview\",\"datePublished\":\"2022-05-08T09:44:16+00:00\",\"dateModified\":\"2022-11-23T14:34:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/\"},\"wordCount\":1409,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png\",\"articleSection\":[\"Articles\",\"Java Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/\",\"url\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/\",\"name\":\"SOLID Design Principle Java? An Overview - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png\",\"datePublished\":\"2022-05-08T09:44:16+00:00\",\"dateModified\":\"2022-11-23T14:34:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png\",\"width\":820,\"height\":615,\"caption\":\"SOLID Design Principle Java An Overview (1)\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Entri Skilling\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Programming\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"SOLID Design Principle Java? An Overview\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36\",\"name\":\"Feeba Mahin\",\"url\":\"https:\/\/entri.app\/blog\/author\/feeba123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SOLID Design Principle Java? An Overview - Entri Blog","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:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/","og_locale":"en_US","og_type":"article","og_title":"SOLID Design Principle Java? An Overview - Entri Blog","og_description":"SOLID refers to five design principles in object-oriented programming, designed to reduce code rot and improve the value, function, and maintainability of software. The SOLID principles help the user to develop less coupled code. If code is tightly coupled, a group of classes are dependent on one another. This should be avoided for better maintainability [&hellip;]","og_url":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2022-05-08T09:44:16+00:00","article_modified_time":"2022-11-23T14:34:00+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png","type":"image\/png"}],"author":"Feeba Mahin","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Feeba Mahin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/"},"author":{"name":"Feeba Mahin","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36"},"headline":"SOLID Design Principle Java? An Overview","datePublished":"2022-05-08T09:44:16+00:00","dateModified":"2022-11-23T14:34:00+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/"},"wordCount":1409,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png","articleSection":["Articles","Java Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/","url":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/","name":"SOLID Design Principle Java? An Overview - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png","datePublished":"2022-05-08T09:44:16+00:00","dateModified":"2022-11-23T14:34:00+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/SOLID-Design-Principle-Java-An-Overview-1.png","width":820,"height":615,"caption":"SOLID Design Principle Java An Overview (1)"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Entri Skilling","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/"},{"@type":"ListItem","position":3,"name":"Java Programming","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/"},{"@type":"ListItem","position":4,"name":"SOLID Design Principle Java? An Overview"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36","name":"Feeba Mahin","url":"https:\/\/entri.app\/blog\/author\/feeba123\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25523389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25523389"}],"version-history":[{"count":9,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25523389\/revisions"}],"predecessor-version":[{"id":25548141,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25523389\/revisions\/25548141"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25523529"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25523389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25523389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25523389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}