{"id":1298,"date":"2025-08-12T13:36:15","date_gmt":"2025-08-12T06:36:15","guid":{"rendered":"https:\/\/kienthucmo.com\/kiss-dry-yagni-3-golden-principles-in-software-development\/"},"modified":"2025-12-09T23:07:46","modified_gmt":"2025-12-09T16:07:46","slug":"kiss-dry-yagni-3-golden-principles-in-software-development","status":"publish","type":"post","link":"https:\/\/kienthucmo.com\/en\/kiss-dry-yagni-3-golden-principles-in-software-development\/","title":{"rendered":"KISS, DRY, YAGNI &#8211; 3 Golden Principles in Software Development"},"content":{"rendered":"\n<p>In the world of software, where every line of code can be the &#8220;seed&#8221; for a robust system or a &#8220;time bomb&#8221; of errors, we \u2014 the developers \u2014 need more than just the ability to write working code. We need to write code that is readable, maintainable, and won&#8217;t become a burden in the future.<\/p>\n\n\n\n<p>The three principles <strong>KISS<\/strong>, <strong>DRY<\/strong>, and <strong>YAGNI<\/strong> are a &#8220;guiding trio&#8221; that have existed and proven their value over decades. They are not just empty slogans, but the distilled essence of hard-earned experience from countless successful software projects&#8230; and failures as well.<\/p>\n\n\n\n<p>In this article, we will delve into the meaning, mindset behind, and practical application of these three principles. Consider this not just as knowledge, but as the survival philosophy of a programmer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Overview<\/h2>\n\n\n\n<p>KISS, DRY, and YAGNI are commonly referred to as <strong>&#8220;software design principles&#8221;<\/strong> or more specifically as <strong>&#8220;programming principles&#8221;<\/strong> (programming principles \/ coding principles).<\/p>\n\n\n\n<p>They belong to the <strong>&#8220;best practices&#8221;<\/strong> group \u2013 methods and principles widely recognized to help make code more maintainable, scalable, and error-resistant.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"800\" height=\"533\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/thiet-ke-phan-mem.jpg\" alt=\"Software Design\" class=\"wp-image-657\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/thiet-ke-phan-mem.jpg 800w, https:\/\/kienthucmo.com\/wp-content\/uploads\/thiet-ke-phan-mem-300x200.jpg 300w, https:\/\/kienthucmo.com\/wp-content\/uploads\/thiet-ke-phan-mem-768x512.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>In addition to these three principles, developers often refer to other principles such as:\n<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SOLID<\/strong> \u2013 5 object-oriented design principles.<\/li>\n\n\n\n<li><strong>GRASP<\/strong> \u2013 Principles of responsibility assignment in OOP.<\/li>\n\n\n\n<li><strong>SoC<\/strong> (Separation of Concerns) \u2013 Separate functionalities for easier management.<\/li>\n\n\n\n<li><strong>SNE<\/strong> (Simple, Not Easy) \u2013 similar to KISS but focuses on &#8220;simplicity without compromising quality.&#8221;<\/li>\n\n\n\n<li><strong>Occam\u2019s Razor<\/strong> \u2013 Choose the simplest solution possible that still meets the requirements.<\/li>\n\n\n\n<li><strong>Fail Fast<\/strong> \u2013 Detect errors as early as possible to reduce repair costs.<\/li>\n<\/ul>\n\n\n\n<p>In this article, we will focus primarily on KISS, DRY, and YAGNI.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. KISS \u2014 Keep It Simple, Stupid<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"736\" height=\"736\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/kiss-avatar.jpg\" alt=\"\" class=\"wp-image-658\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/kiss-avatar.jpg 736w, https:\/\/kienthucmo.com\/wp-content\/uploads\/kiss-avatar-300x300.jpg 300w, https:\/\/kienthucmo.com\/wp-content\/uploads\/kiss-avatar-150x150.jpg 150w\" sizes=\"(max-width: 736px) 100vw, 736px\" \/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">2.1 Definition &amp; Philosophy<\/h3>\n\n\n\n<p>KISS is a reminder to: <strong>Keep everything as simple as possible<\/strong>. In system design and coding, \u201csimple\u201d does not mean removing features, but rather <strong>avoiding unnecessary complexity<\/strong>.<\/p>\n\n\n\n<p>Complex systems often arise from the accumulation of small but uncontrolled decisions. A function that was originally just 10 lines can, after several \u201cpatches,\u201d turn into 200 lines with many branches, forcing the reader to spend hours trying to understand it.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2.2 Why is KISS important?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Speed of understanding and maintenance<\/strong>: Simple code helps new developers joining the project quickly grasp it.<\/li>\n\n\n\n<li><strong>Reduced risk of errors<\/strong>: Every redundant piece of logic is an opportunity for a bug to appear.<\/li>\n\n\n\n<li><strong>Optimized scalability<\/strong>: A simple platform makes it easier to add features compared to a tangled one.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2.3 Principles of application<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Always ask: <em>\u201cIs there a shorter and clearer way?\u201d<\/em><\/li>\n\n\n\n<li>Avoid \u201cpremature optimization\u201d (<em>premature optimization<\/em>).<\/li>\n\n\n\n<li>Use familiar structures and libraries instead of \u201cinventing\u201d things that no one understands.\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2.4 Example<\/h3>\n\n\n\n<p><strong>Problem: Calculate the total order value (including discount and tax)<\/strong><br>You have a list of products in the cart, each product has:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>price<\/code>: price<\/li>\n\n\n\n<li><code>quantity<\/code>: quantity<\/li>\n\n\n\n<li>May have <code>discount<\/code> (optional)<\/li>\n\n\n\n<li>VAT is 10%<br>Goal: Calculate the total amount the customer has to pay.<\/li>\n<\/ul>\n\n\n\n<p><strong>\u274c Complex approach, violating KISS<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>def calculate_total(cart):\n    total = 0\n    for i in range(len(cart)):\n        product = cart&#91;i&#93;\n        price = product&#91;\"price\"&#93;\n        quantity = product&#91;\"quantity\"&#93;\n        discount = 0\n        if \"discount\" in product:\n            discount = product&#91;\"discount\"&#93;\n        subtotal = price * quantity\n        if discount > 0:\n            subtotal = subtotal - (subtotal * discount)\n        tax = subtotal * 0.1\n        subtotal = subtotal + tax\n        total = total + subtotal\n    return total\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">calculate_total<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">cart<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    total <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">for<\/span><span style=\"color: #D8DEE9FF\"> i <\/span><span style=\"color: #81A1C1\">in<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">range<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #88C0D0\">len<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">cart<\/span><span style=\"color: #ECEFF4\">)):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        product <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> cart<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #D8DEE9FF\">i<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        price <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> product<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">price<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        quantity <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> product<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">quantity<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        discount <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">discount<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">in<\/span><span style=\"color: #D8DEE9FF\"> product<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            discount <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> product<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">discount<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        subtotal <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> price <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> quantity<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> discount <\/span><span style=\"color: #81A1C1\">&gt;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            subtotal <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> subtotal <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">subtotal <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> discount<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        tax <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> subtotal <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0.1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        subtotal <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> subtotal <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> tax<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        total <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> total <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> subtotal<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> total<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Problem:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Too many unnecessary temporary variables.<\/li>\n\n\n\n<li>Too many sequential steps, making it hard to see the \u201cbig picture.\u201d<\/li>\n\n\n\n<li>The loop using <code><em>range(len(cart))<\/em><\/code> is unnecessary.<\/li>\n\n\n\n<li>Discount and tax logic is scattered, making it hard to reuse.<\/li>\n<\/ul>\n\n\n\n<p><strong>\u2705 A more KISS-friendly approach<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>def calculate_total(cart):\n    def item_total(p):\n        subtotal = p&#91;\"price\"&#93; * p&#91;\"quantity\"&#93;\n        subtotal *= (1 - p.get(\"discount\", 0))\n        return subtotal * 1.1  # add 10% VAT\n    \n    return sum(item_total(product) for product in cart)\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">calculate_total<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">cart<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">item_total<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">p<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        subtotal <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> p<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">price<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> p<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">quantity<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        subtotal <\/span><span style=\"color: #81A1C1\">*=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9FF\"> p<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #88C0D0\">get<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">discount<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><span style=\"color: #ECEFF4\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> subtotal <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">1.1<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># add 10% VAT<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">sum<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #88C0D0\">item_total<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">product<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">for<\/span><span style=\"color: #D8DEE9FF\"> product <\/span><span style=\"color: #81A1C1\">in<\/span><span style=\"color: #D8DEE9FF\"> cart<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Why is it simpler?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Clear intention<\/strong>: At a glance, it\u2019s clear \u2014 \u201ccalculate each product\u2019s total and then sum them up.\u201d<\/li>\n\n\n\n<li><strong>Fewer temporary variables<\/strong>: No need to store each intermediate value if it\u2019s only used once.<\/li>\n\n\n\n<li><strong>Small function extraction<\/strong>: <code>item_total<\/code> helps encapsulate the logic for calculating each product\u2019s price.<\/li>\n\n\n\n<li><strong>Easy maintenance<\/strong>: If the tax later changes from 10% \u2192 8%, you only need to update it in one place.<\/li>\n<\/ul>\n\n\n\n<p><strong>Lesson from this example<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>KISS<\/strong> is not just about \u201cwriting fewer lines\u201d but about <strong>keeping the ideas in the code clear and easy to read<\/strong>.<\/li>\n\n\n\n<li>A newcomer to the project reading a KISS-style function will immediately understand its <strong>purpose and flow<\/strong>, without having to \u201ctranslate\u201d each variable one by one.<\/li>\n\n\n\n<li>KISS code usually has fewer bugs because there are fewer points of confusion.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3. DRY \u2014 Don\u2019t Repeat Yourself<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1024\" height=\"430\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/dry-principle.png\" alt=\"\" class=\"wp-image-659\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/dry-principle.png 1024w, https:\/\/kienthucmo.com\/wp-content\/uploads\/dry-principle-300x126.png 300w, https:\/\/kienthucmo.com\/wp-content\/uploads\/dry-principle-768x323.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">3.1 Definition &amp; Philosophy<\/h3>\n\n\n\n<p>DRY advocates: <strong>Don\u2019t Repeat Yourself<\/strong>. If a piece of logic appears in multiple places, you are doubling the maintenance workload and doubling the risk of errors.<\/p>\n\n\n\n<p>The philosophy of DRY lies in this: Each idea, each piece of knowledge in the system should exist in only one place.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.2 Why is DRY important?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Easy maintenance<\/strong>: When changes are needed, you only have to update it in one place.<\/li>\n\n\n\n<li><strong>Fewer errors<\/strong>: No worries about fixing it in one file but forgetting in another.<\/li>\n\n\n\n<li><strong>Reusability<\/strong>: Common logic is consolidated into a function, module, or class, helping keep the project consistent.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3.3 Principles of application<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>When you find yourself copy-pasting code from one file to another, stop and think about how to extract it into a function or module.\n<\/li>\n\n\n\n<li>Use <strong>inheritance<\/strong> or <strong>composition<\/strong> in OOP when appropriate.<\/li>\n\n\n\n<li>Use <strong>constants<\/strong> or a <strong>config file<\/strong> instead of hard-coding values multiple times.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3.4 Problem: Employee management and payroll calculation<\/h3>\n\n\n\n<p>You need to write a small system to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Store employee information.<\/li>\n\n\n\n<li>Calculate net salary based on base salary, bonuses, and taxes.<\/li>\n<\/ul>\n\n\n\n<p><strong>\u274c Approach violating DRY (repeating the same logic in multiple places)<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>def calculate_salary(emp):\n    gross_salary = emp&#91;\"base_salary\"&#93; + emp&#91;\"bonus\"&#93;\n    tax = gross_salary * 0.1\n    net_salary = gross_salary - tax\n    return net_salary\n\ndef print_salary(emp):\n    gross_salary = emp&#91;\"base_salary\"&#93; + emp&#91;\"bonus\"&#93;\n    tax = gross_salary * 0.1\n    net_salary = gross_salary - tax\n    print(f\"{emp&#91;'name'&#93;} receives {net_salary} VND\")\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">calculate_salary<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">emp<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    gross_salary <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> emp<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">base_salary<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> emp<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">bonus<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    tax <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> gross_salary <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0.1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    net_salary <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> gross_salary <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9FF\"> tax<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> net_salary<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">print_salary<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">emp<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    gross_salary <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> emp<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">base_salary<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> emp<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">bonus<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    tax <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> gross_salary <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0.1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    net_salary <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> gross_salary <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9FF\"> tax<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #D8DEE9FF\">emp<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">name<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> receives <\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #D8DEE9FF\">net_salary<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> VND&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Problem:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The salary calculation logic (<code>gross_salary<\/code>, <code>tax<\/code>, <code>net_salary<\/code>) is repeated in both functions.<\/li>\n\n\n\n<li>If the tax needs to change from 10% \u2192 8%, you have to update multiple places, which is easy to forget.<\/li>\n\n\n\n<li>Increases the risk of bugs if updates are missed.<\/li>\n<\/ul>\n\n\n\n<p><strong>\u2705 DRY approach (consolidate common logic in one place)<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>def net_salary(emp):\n    \"\"\"Calculate net salary (applying DRY)\"\"\"\n    gross_salary = emp&#91;\"base_salary\"&#93; + emp&#91;\"bonus\"&#93;\n    tax = gross_salary * 0.1\n    return gross_salary - tax\n\ndef calculate_salary(emp):\n    return net_salary(emp)\n\ndef print_salary(emp):\n    print(f\"{emp&#91;'name'&#93;} receives {net_salary(emp)} VND\")\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">net_salary<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">emp<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #ECEFF4\">&quot;&quot;&quot;<\/span><span style=\"color: #A3BE8C\">Calculate net salary (applying DRY)<\/span><span style=\"color: #ECEFF4\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    gross_salary <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> emp<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">base_salary<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">+<\/span><span style=\"color: #D8DEE9FF\"> emp<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #A3BE8C\">bonus<\/span><span style=\"color: #ECEFF4\">&quot;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    tax <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> gross_salary <\/span><span style=\"color: #81A1C1\">*<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0.1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> gross_salary <\/span><span style=\"color: #81A1C1\">-<\/span><span style=\"color: #D8DEE9FF\"> tax<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">calculate_salary<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">emp<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">net_salary<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">emp<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">print_salary<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">emp<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #81A1C1\">f<\/span><span style=\"color: #A3BE8C\">&quot;<\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #D8DEE9FF\">emp<\/span><span style=\"color: #ECEFF4\">&#91;<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">name<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">&#93;<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> receives <\/span><span style=\"color: #EBCB8B\">{<\/span><span style=\"color: #88C0D0\">net_salary<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">emp<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #EBCB8B\">}<\/span><span style=\"color: #A3BE8C\"> VND&quot;<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Why is it better?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The salary calculation logic exists in only one function (net_salary).<\/li>\n\n\n\n<li>If the tax changes, you only need to update one place.<\/li>\n\n\n\n<li>Other functions simply <strong>call the common function<\/strong>, without copy-pasting.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Lesson from this example<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>DRY<\/strong> not only makes the code cleaner but also protects you from \u201cmissing updates\u201d bugs.<\/li>\n\n\n\n<li>The DRY principle is especially important in large projects, where a piece of logic can appear in dozens of different files.<\/li>\n\n\n\n<li>DRY = \u201cWrite once, use many times\u201d \u2192 saves time and reduces risk.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">4. YAGNI \u2014 You Aren\u2019t Gonna Need It<br><\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/yagni.jpg\" alt=\"Yagni\" class=\"wp-image-660\" srcset=\"https:\/\/kienthucmo.com\/wp-content\/uploads\/yagni.jpg 600w, https:\/\/kienthucmo.com\/wp-content\/uploads\/yagni-300x300.jpg 300w, https:\/\/kienthucmo.com\/wp-content\/uploads\/yagni-150x150.jpg 150w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">4.1 Definition &amp; Philosophy<\/h3>\n\n\n\n<p>YAGNI is a warning: <strong>Don\u2019t build things you don\u2019t need yet<\/strong>. Many developers tend to \u201canticipate\u201d features thinking \u201cthey will be needed later,\u201d but in reality, many of these \u201canticipatory features\u201d are never used.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.2 Why is YAGNI important?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Save time<\/strong>: Focus on doing things that currently bring value.<\/li>\n\n\n\n<li><strong>Reduce risk<\/strong>: Every line of code is a potential place for bugs; if it\u2019s not necessary yet, it\u2019s better not to write it.<\/li>\n\n\n\n<li><strong>Avoid overcomplicating the system<\/strong>: Redundant features make it harder for others to understand the code.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4.3 Principles of Application<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Only implement features when there is a clear request from the product team or the customer.<\/li>\n\n\n\n<li>If future expansion is needed, design the code to be <em>easily extendable<\/em> rather than <em>pre-writing<\/em> everything.<\/li>\n\n\n\n<li>Focus on the <strong>MVP (Minimum Viable Product)<\/strong> first.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4.4 Examples<\/h3>\n\n\n\n<p><strong>Context<\/strong><br>Suppose you are assigned the task of writing a function to calculate the sum of integers in a <code>list<\/code>.<br>You <strong>predict<\/strong> that in the future it might need to support decimals, complex numbers, or handle nested lists\u2026 so you immediately write an \u201cultra-versatile\u201d version right from the start.<\/p>\n\n\n\n<p>\u274c An approach that violates YAGNI<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\ndef sum_list(lst, allow_float=False, allow_complex=False, recursive=False):\n    total = 0\n    for item in lst:\n        if isinstance(item, int):\n            total += item\n        elif allow_float and isinstance(item, float):\n            total += item\n        elif allow_complex and isinstance(item, complex):\n            total += item.real  # assume only the real part is summed\n        elif recursive and isinstance(item, list):\n            total += sum_list(item, allow_float, allow_complex, recursive)\n    return total\n\n# Currently only need to sum integers, but written too complicated\nprint(sum_list(&#91;1, 2, 3&#93;))  # 6\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">sum_list<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">lst<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">allow_float<\/span><span style=\"color: #81A1C1\">=False<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">allow_complex<\/span><span style=\"color: #81A1C1\">=False<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">recursive<\/span><span style=\"color: #81A1C1\">=False<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    total <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">for<\/span><span style=\"color: #D8DEE9FF\"> item <\/span><span style=\"color: #81A1C1\">in<\/span><span style=\"color: #D8DEE9FF\"> lst<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">isinstance<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">item<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">int<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            total <\/span><span style=\"color: #81A1C1\">+=<\/span><span style=\"color: #D8DEE9FF\"> item<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">elif<\/span><span style=\"color: #D8DEE9FF\"> allow_float <\/span><span style=\"color: #81A1C1\">and<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">isinstance<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">item<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">float<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            total <\/span><span style=\"color: #81A1C1\">+=<\/span><span style=\"color: #D8DEE9FF\"> item<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">elif<\/span><span style=\"color: #D8DEE9FF\"> allow_complex <\/span><span style=\"color: #81A1C1\">and<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">isinstance<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">item<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">complex<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            total <\/span><span style=\"color: #81A1C1\">+=<\/span><span style=\"color: #D8DEE9FF\"> item<\/span><span style=\"color: #ECEFF4\">.<\/span><span style=\"color: #D8DEE9FF\">real  <\/span><span style=\"color: #616E88\"># assume only the real part is summed<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">elif<\/span><span style=\"color: #D8DEE9FF\"> recursive <\/span><span style=\"color: #81A1C1\">and<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">isinstance<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">item<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">list<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            total <\/span><span style=\"color: #81A1C1\">+=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">sum_list<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">item<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> allow_float<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> allow_complex<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> recursive<\/span><span style=\"color: #ECEFF4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> total<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># Currently only need to sum integers, but written too complicated<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #88C0D0\">sum_list<\/span><span style=\"color: #ECEFF4\">(&#91;<\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">2<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">3<\/span><span style=\"color: #ECEFF4\">&#93;))<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># 6<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Problem<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You added <strong>many unnecessary features<\/strong> (float, complex, recursive).<\/li>\n\n\n\n<li>The code becomes harder to read and maintain.<\/li>\n\n\n\n<li>There\u2019s a chance the extensions may never be used, wasting development and testing time.\n<\/li>\n<\/ul>\n\n\n\n<p><strong>\u2705 An approach that follows YAGNI<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>def sum_list(lst):\n    total = 0\n    for item in lst:\n        if isinstance(item, int):\n            total += item\n    return total\n\nprint(sum_list(&#91;1, 2, 3&#93;))  # 6\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #81A1C1\">def<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">sum_list<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">lst<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    total <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">for<\/span><span style=\"color: #D8DEE9FF\"> item <\/span><span style=\"color: #81A1C1\">in<\/span><span style=\"color: #D8DEE9FF\"> lst<\/span><span style=\"color: #ECEFF4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">        <\/span><span style=\"color: #81A1C1\">if<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">isinstance<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9FF\">item<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">int<\/span><span style=\"color: #ECEFF4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">            total <\/span><span style=\"color: #81A1C1\">+=<\/span><span style=\"color: #D8DEE9FF\"> item<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> total<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">print<\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #88C0D0\">sum_list<\/span><span style=\"color: #ECEFF4\">(&#91;<\/span><span style=\"color: #B48EAD\">1<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">2<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #B48EAD\">3<\/span><span style=\"color: #ECEFF4\">&#93;))<\/span><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #616E88\"># 6<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><strong>Explanation<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You only write what is necessary for the current requirement.<\/li>\n\n\n\n<li>If one day you truly need to add decimals or nested lists, then you extend it.<\/li>\n\n\n\n<li>Helps keep the code clean, easy to understand, and saves development time.<\/li>\n<\/ul>\n\n\n\n<p><strong>Lesson from YAGNI<\/strong>:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Don\u2019t \u201cpredict\u201d the future when writing code. Over-anticipating needs can make software more complex and time-consuming without necessarily being used. Focus on addressing the current requirements and extend when needed.\n<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">5. The Relationship between KISS, DRY, and YAGNI<\/h2>\n\n\n\n<p>These three principles do not exist in isolation; they complement each other:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>KISS<\/strong> keeps the code simple, making DRY and YAGNI easier to apply.<\/li>\n\n\n\n<li><strong>DRY<\/strong> keeps the system tidy, which in turn helps maintain KISS.<\/li>\n\n\n\n<li><strong>YAGNI<\/strong> keeps the codebase lean, making KISS and DRY achievable.<\/li>\n<\/ul>\n\n\n\n<p>If programming is compared to <strong>building a house<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>KISS<\/strong> = a clear, uncluttered blueprint.<\/li>\n\n\n\n<li><strong>DRY<\/strong> = reusing materials and techniques instead of creating everything from scratch.<\/li>\n\n\n\n<li><strong>YAGNI<\/strong> = not building a swimming pool when no one wants to swim yet.<br><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">6. Common Mistakes When Applying<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>KISS but overly simplified<\/strong>\n<ul class=\"wp-block-list\">\n<li>Wrong: Removing important features just to make the code shorter.<\/li>\n\n\n\n<li>Right: Keep the necessary features, but avoid adding unnecessary complexity.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>DRY but applied excessively<\/strong>\n<ul class=\"wp-block-list\">\n<li>Wrong: Forcing everything into a single function, making the code hard to read.<\/li>\n\n\n\n<li>Right: Group only the <em>truly common<\/em> parts, maintaining balance.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>YAGNI but ignoring potential future extensions<\/strong>\n<ul class=\"wp-block-list\">\n<li>Wrong: Ignoring the possibility of future extensions, leading to a complete rewrite later.<\/li>\n\n\n\n<li>Right: Design for extensibility but avoid writing unnecessary code.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">7. Conclusion<\/h2>\n\n\n\n<p>The three principles <strong>KISS<\/strong>, <strong>DRY<\/strong>, and <strong>YAGNI<\/strong> form the foundation of professional programming mindset.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>KISS<\/strong> reminds you to keep everything clear and avoid unnecessary complexity.<\/li>\n\n\n\n<li><strong>DRY<\/strong> ensures you don\u2019t repeat yourself, reducing risk and improving maintainability.<\/li>\n\n\n\n<li><strong>YAGNI<\/strong> helps you focus on current value, avoiding waste on things that might never be used.<\/li>\n<\/ul>\n\n\n\n<p>Before committing code, ask yourself:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>KISS<\/strong> \u2014 Is there a simpler way to do this?<\/li>\n\n\n\n<li><strong>DRY<\/strong> \u2014 Am I repeating myself anywhere?<\/li>\n\n\n\n<li><strong>YAGNI<\/strong> \u2014 Am I doing something unnecessary?<\/li>\n<\/ul>\n\n\n\n<p>Programming is not just about \u201cmaking the computer run,\u201d but about writing code that humans can understand and computers can execute efficiently. These three principles are the bridge between art and engineering in programming.<\/p>\n\n\n\n<p><strong>Read more:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/kienthucmo.com\/en\/what-is-solid-principles-how-it-works-and-practical-applications\/\" data-type=\"link\" data-id=\"https:\/\/kienthucmo.com\/en\/what-is-solid-principles-how-it-works-and-practical-applications\/\">What is SOLID? Principles and how to apply them in practice<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/kienthucmo.com\/en\/clean-code-the-art-of-writing-clean-and-sustainable-code-in-software-development\/\" data-type=\"link\" data-id=\"https:\/\/kienthucmo.com\/clean-code-nghe-thuat-viet-ma-sach-va-ben-vung-trong-phat-trien-phan-mem\/\">Clean Code: The Art of Writing Clean and Sustainable Code in Software Development<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">8. References<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>[1] B. W. Kernighan and P. J. Plauger,&nbsp;<em>The Elements of Programming Style<\/em>. New York, NY: McGraw-Hill, 1978.<\/li>\n\n\n\n<li>[2] A. Hunt and D. Thomas,&nbsp;<em>The Pragmatic Programmer: From Journeyman to Master<\/em>. Reading, MA: Addison-Wesley, 1999.<\/li>\n\n\n\n<li>[3] K. Beck,&nbsp;<em>Extreme Programming Explained: Embrace Change<\/em>. Reading, MA: Addison-Wesley, 1999.<\/li>\n\n\n\n<li>[4] ThoughtWorks, \u201cThe DRY Principle,\u201d&nbsp;<em>ThoughtWorks Insights<\/em>. [Online]. Available:&nbsp;<a href=\"https:\/\/www.thoughtworks.com\/insights\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.thoughtworks.com\/insights<\/a>.<\/li>\n\n\n\n<li>[5] M. Fowler, \u201cYAGNI,\u201d&nbsp;<em>martinfowler.com<\/em>. [Online]. Available:&nbsp;<a href=\"https:\/\/martinfowler.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/martinfowler.com<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>KISS, DRY, and YAGNI are commonly referred to as &#8220;software design principles&#8221; or more specifically as &#8220;programming principles&#8221; (programming principles \/ coding principles).<\/p>\n","protected":false},"author":1,"featured_media":2612,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"googlesitekit_rrm_CAowieHDDA:productID":"","footnotes":""},"categories":[50,49],"tags":[51,52],"class_list":["post-1298","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-information-technology","category-software-engineering","tag-clean-code","tag-software-design-principles"],"_links":{"self":[{"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/posts\/1298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/comments?post=1298"}],"version-history":[{"count":7,"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/posts\/1298\/revisions"}],"predecessor-version":[{"id":2619,"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/posts\/1298\/revisions\/2619"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/media\/2612"}],"wp:attachment":[{"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/media?parent=1298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/categories?post=1298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kienthucmo.com\/en\/wp-json\/wp\/v2\/tags?post=1298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}