{"id":6466,"date":"2023-02-17T05:02:13","date_gmt":"2023-02-17T05:02:13","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=6466"},"modified":"2023-03-10T07:21:31","modified_gmt":"2023-03-10T07:21:31","slug":"software-design-principles","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/software-design-principles\/","title":{"rendered":"Software Design Principles"},"content":{"rendered":"<p>In our daily programming, we see three types of software design principles i.e <strong>DRY, KISS<\/strong>, and <strong>YAGNI<\/strong>.<\/p>\n<ol>\n<li>DRY PRINCIPLE &#8211; Don\u2019t repeat yourself<\/li>\n<li>KISS &#8211; Keep it simple stupid<\/li>\n<li>YAGNI &#8211; You aren&#8217;t gonna need it<\/li>\n<li>Curly&#8217;s Law &#8211; Do One Thing<\/li>\n<\/ol>\n<h2>DRY PRINCIPLE :<\/h2>\n<p>The aim of this principle is to reduce the repetition of information. This principle is stated as &#8220;Every piece of knowledge must have a single, unambiguous, representation within a system \u201c.<\/p>\n<p>To accomplish this, divide your system into pieces. Don&#8217;t write long methods; instead, divide logic into smaller reusable pieces as much as possible and try to reuse existing pieces in your method.<\/p>\n<h3>KISS &#8211; KEEP IT SIMPLE STUPID :<\/h3>\n<p>Each method should only solve one small problem, rather than many. If your method contains a large number of conditions, divide it into smaller methods. It will not only be easier to read and maintain, but it will also allow you to find bugs much faster.<\/p>\n<p><em>Here below, Two different methods doing the same implementation,<\/em><br \/>\n<code>public String weekday1(int day) {<br \/>\nswitch (day) {<br \/>\ncase 1:<br \/>\nreturn \"Monday\";<br \/>\ncase 2:<br \/>\nreturn \"Tuesday\";<br \/>\ncase 3:<br \/>\nreturn \"Wednesday\";<br \/>\ncase 4:<br \/>\nreturn \"Thursday\";<br \/>\ncase 5:<br \/>\nreturn \"Friday\";<br \/>\ncase 6:<br \/>\nreturn \"Saturday\";<br \/>\ncase 7:<br \/>\nreturn \"Sunday\";<br \/>\ndefault:<br \/>\nthrow new InvalidOperationException(\"day must be in range 1 to 7\");<br \/>\n}<br \/>\n}<br \/>\npublic String weekday2(int day) {<br \/>\nif ((day &lt; 1) || (day &gt; 7)) throw new InvalidOperationException(\"day must be in range 1 to 7\");<br \/>\nstring[] days = {<br \/>\n\"Monday\",<br \/>\n\"Tuesday\",<br \/>\n\"Wednesday\",<br \/>\n\"Thursday\",<br \/>\n\"Friday\",<br \/>\n\"Saturday\",<br \/>\n\"Sunday\"<br \/>\n};<br \/>\nreturn days[day - 1];<br \/>\n} <\/code><\/p>\n<h3>YAGNI &#8211; You aren&#8217;t gonna need it<\/h3>\n<p>Don&#8217;t add any functionality until it&#8217;s absolutely necessary; in other words, only write the code you need right now. If you don&#8217;t think you&#8217;ll need it, leave it out. Don&#8217;t think about what might be needed in the future as you write your code logic.<\/p>\n<p><strong>There are two primary reasons to use YAGNI:<\/strong><br \/>\nYou save time because you avoid writing code that you later discover is unnecessary.<br \/>\nYour code is better because you don&#8217;t pollute it with &#8216;guesses&#8217; that turn out to be mostly incorrect but persist.<\/p>\n<p><strong>Curly&#8217;s Law &#8211; Do One Thing<\/strong><br \/>\nA class, function, or variable should only mean one thing. It should not mean one thing in one context and mean something completely different in another. It should not mean two things at the same time. It should only mean one thing and mean it all the time.<\/p>\n<p><small><em>People having good knowledge of Financial accounting can get an accounting certification 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 <a href=\"https:\/\/www.studysection.com\/financial-accounting-advanced\">Financial Accounting<\/a> 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>In our daily programming, we see three types of software design principles i.e DRY, KISS, and YAGNI. DRY PRINCIPLE &#8211;<\/p>\n","protected":false},"author":1,"featured_media":6467,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[676,48],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Software Design Principles - StudySection Blog<\/title>\n<meta name=\"description\" content=\"In our daily programming, we see three types of software design principles i.e DRY, KISS, and YAGNI. DRY PRINCIPLE - Don\u2019t repeat yourself\" \/>\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\/software-design-principles\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Software Design Principles - StudySection Blog\" \/>\n<meta property=\"og:description\" content=\"In our daily programming, we see three types of software design principles i.e DRY, KISS, and YAGNI. DRY PRINCIPLE - Don\u2019t repeat yourself\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/software-design-principles\/\" \/>\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=\"2023-02-17T05:02:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-10T07:21:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/02\/Software-Design1.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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/software-design-principles\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/software-design-principles\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"Software Design Principles\",\"datePublished\":\"2023-02-17T05:02:13+00:00\",\"dateModified\":\"2023-03-10T07:21:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/software-design-principles\/\"},\"wordCount\":376,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"keywords\":[\"Principles\",\"Software\"],\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/software-design-principles\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/software-design-principles\/\",\"url\":\"https:\/\/studysection.com\/blog\/software-design-principles\/\",\"name\":\"Software Design Principles - StudySection Blog\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2023-02-17T05:02:13+00:00\",\"dateModified\":\"2023-03-10T07:21:31+00:00\",\"description\":\"In our daily programming, we see three types of software design principles i.e DRY, KISS, and YAGNI. DRY PRINCIPLE - Don\u2019t repeat yourself\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/software-design-principles\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/software-design-principles\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/software-design-principles\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Software Design Principles\"}]},{\"@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":"Software Design Principles - StudySection Blog","description":"In our daily programming, we see three types of software design principles i.e DRY, KISS, and YAGNI. DRY PRINCIPLE - Don\u2019t repeat yourself","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\/software-design-principles\/","og_locale":"en_US","og_type":"article","og_title":"Software Design Principles - StudySection Blog","og_description":"In our daily programming, we see three types of software design principles i.e DRY, KISS, and YAGNI. DRY PRINCIPLE - Don\u2019t repeat yourself","og_url":"https:\/\/studysection.com\/blog\/software-design-principles\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2023-02-17T05:02:13+00:00","article_modified_time":"2023-03-10T07:21:31+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2023\/02\/Software-Design1.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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/software-design-principles\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/software-design-principles\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"Software Design Principles","datePublished":"2023-02-17T05:02:13+00:00","dateModified":"2023-03-10T07:21:31+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/software-design-principles\/"},"wordCount":376,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"keywords":["Principles","Software"],"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/software-design-principles\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/software-design-principles\/","url":"https:\/\/studysection.com\/blog\/software-design-principles\/","name":"Software Design Principles - StudySection Blog","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2023-02-17T05:02:13+00:00","dateModified":"2023-03-10T07:21:31+00:00","description":"In our daily programming, we see three types of software design principles i.e DRY, KISS, and YAGNI. DRY PRINCIPLE - Don\u2019t repeat yourself","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/software-design-principles\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/software-design-principles\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/software-design-principles\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Software Design Principles"}]},{"@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":235,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6466"}],"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=6466"}],"version-history":[{"count":2,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6466\/revisions"}],"predecessor-version":[{"id":6525,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/6466\/revisions\/6525"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/6467"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=6466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=6466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=6466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}