<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Programming with Shahan</title>
    <description>The latest articles on DEV Community by Programming with Shahan (@codewithshahan).</description>
    <link>https://dev.to/codewithshahan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F643041%2F4bf2d91a-2cc2-4670-88b3-9183a0435fdd.png</url>
      <title>DEV Community: Programming with Shahan</title>
      <link>https://dev.to/codewithshahan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codewithshahan"/>
    <language>en</language>
    <item>
      <title>How to learn to code in 2026 (dev job market is insane!)</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Wed, 22 Apr 2026 10:06:35 +0000</pubDate>
      <link>https://dev.to/codewithshahan/how-to-learn-to-code-in-2026-before-the-hiring-surge-starts-54ho</link>
      <guid>https://dev.to/codewithshahan/how-to-learn-to-code-in-2026-before-the-hiring-surge-starts-54ho</guid>
      <description>&lt;p&gt;Learning to code in 2026 is not what it used to be.&lt;/p&gt;

&lt;p&gt;And if you still think it is&lt;/p&gt;

&lt;p&gt;You are already behind.&lt;/p&gt;

&lt;p&gt;And the way you become a developer?&lt;/p&gt;

&lt;p&gt;It's &lt;em&gt;completely&lt;/em&gt; different. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuaqvdkb1hsxt8uwy2aom.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuaqvdkb1hsxt8uwy2aom.png" alt="Image of developer asking AI agent: " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;You may ask: "should I even learn to code in 2026?"&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes.&lt;/p&gt;

&lt;p&gt;100% yes.&lt;/p&gt;

&lt;p&gt;Because some people think AI replaced programmers.&lt;/p&gt;

&lt;p&gt;It didn’t.&lt;/p&gt;

&lt;p&gt;It removed bad programmers.&lt;/p&gt;

&lt;p&gt;And increased demand for REAL BUILDERS.&lt;/p&gt;

&lt;p&gt;This is still one of the highest-leverage skills.&lt;/p&gt;

&lt;p&gt;Plus the software engineer (SWE) job market is picking up in 2026. &lt;/p&gt;

&lt;p&gt;SignalFire &lt;a href="https://www.signalfire.com/blog/report-engineering-talent-retention" rel="noopener noreferrer"&gt;reported&lt;/a&gt; that firms like Meta, Netflix, Uber, and Google are hiring engineers FASTER than people are leaving:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faxbmfvbhkmjptfh99c3v.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faxbmfvbhkmjptfh99c3v.webp" alt="firms like Meta, Netflix, Uber, and Google are hiring engineers faster than people are leaving" width="800" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The US Bureau of Labor Statistics still expects &lt;a href="https://www.bls.gov/ooh/computer-and-information-technology/software-developers.htm#tab-6" rel="noopener noreferrer"&gt;software developer jobs to grow by about 15%&lt;/a&gt;, which is way faster than most other careers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fply6c2a2f0ctmv8dbyjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fply6c2a2f0ctmv8dbyjm.png" alt="US Bureau of Labor Statistics still expects software developer jobs to grow by about 15%" width="576" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Moreover, &lt;a href="https://www.itransition.com/software-development/statistics" rel="noopener noreferrer"&gt;72% of organizations outsource software development&lt;/a&gt; to achieve better access to talent [32%], meet increasing customer demands more efficiently [35%], optimize spending [34%], and improve quality or performance [33%]:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbkiq6ed5e9mrypbt002.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbkiq6ed5e9mrypbt002.png" alt="72% of organizations outsource software development image graph" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Meanwhile, Python is the most sought-after programming language, with 45.7% of recruiters seeking candidates with Python skills, followed by JavaScript [41.5%], Java [39.5%], TypeScript [27.9%], and C# [24.4%].&lt;/p&gt;

&lt;p&gt;according to &lt;a href="https://www.devjobsscanner.com/python-jobs" rel="noopener noreferrer"&gt;devjobsscanner&lt;/a&gt; Python is the most in-demand language as of January 2026 with 43,300+ posted job openings:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcptasmsx23fjta0luofn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcptasmsx23fjta0luofn.png" alt="Image statistic: Python is the most in-demand language as of January 2026" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AND&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.gartner.com/en/newsroom/press-releases/2024-10-03-gartner-says-generative-ai-will-require-80-percent-of-engineering-workforce-to-upskill-through-2027" rel="noopener noreferrer"&gt;Gartner predicts&lt;/a&gt; that by 2027, 80% of the engineering workforce will need to upskill to keep pace with generative AI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5oqos795x14j7x91sca5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5oqos795x14j7x91sca5.png" alt="by 2027, 80% of the engineering workforce will need to upskill to keep pace with generative AI." width="800" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so if you can code in 2026 you certainly can &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📲 build complex application&lt;/li&gt;
&lt;li&gt;😴 automate your entire projects &lt;/li&gt;
&lt;li&gt;💼 land your dream job&lt;/li&gt;
&lt;li&gt;🦮 and instruct AI instead of being replaced by it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The good news is: learning to code today is much easier than ever before.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y7up6g2rvc9kotvj9h6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y7up6g2rvc9kotvj9h6.png" alt="developer using secret ai prompt to learn code faster" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in this article, I will show you:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. 🍱 what coding looks like now in 2026&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;2. 🏫 what you MUST learn for the future&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;3. ⚡ AND how to speed up your learning massively&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's jump in.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;💊TABLE OF CONTENTS:&lt;/strong&gt;&lt;br&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FIRST: Why "Vibe coding" to "Agentic Engineering" shift happened?&lt;/li&gt;
&lt;li&gt;
🍼 STEP 1: Coding Fundamentals (non-negotiable)

&lt;ul&gt;
&lt;li&gt;Language choice&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;🍌 STEP 2: Software Architecture&lt;/li&gt;
&lt;li&gt;🧪 STEP 3: Testing &lt;/li&gt;
&lt;li&gt;🛫 STEP 4: Deployment &lt;/li&gt;
&lt;li&gt;🛩️🎮 STEP 5: Version Control&lt;/li&gt;
&lt;li&gt;🔐 STEP 6: Security &amp;amp; Privacy &lt;/li&gt;
&lt;li&gt;🚢 STEP 7: Microservices &amp;amp; Containers &lt;/li&gt;
&lt;li&gt;
💪 NOW you are ready for AI coding

&lt;ul&gt;
&lt;li&gt;⚡ The new coding shift: Agentic Engineering&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
🧠 How to learn code faster 

&lt;ul&gt;
&lt;li&gt;🤔 1. Use AI to THINK, not just code&lt;/li&gt;
&lt;li&gt;🔍 2. Reverse engineer code&lt;/li&gt;
&lt;li&gt;🏗️ 3. Projects = everything&lt;/li&gt;
&lt;li&gt;🧠 4. Ask AI for multiple solutions&lt;/li&gt;
&lt;li&gt;📄 5. Documentation shortcut&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;📚 Recommendation&lt;/li&gt;
&lt;li&gt;🧭 Final thoughts&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  FIRST: Why "Vibe coding" to "Agentic Engineering" shift happened?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgbz3p9rkf8ul7xuz9cf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgbz3p9rkf8ul7xuz9cf.png" alt="Image of developer coding agentic engineering" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In 2025, Andrej Karpathy introduced something called&lt;/p&gt;

&lt;p&gt;👉 “Vibe coding”&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1886192184808149383-950" src="https://platform.twitter.com/embed/Tweet.html?id=1886192184808149383"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1886192184808149383-950');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1886192184808149383&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;It meant&lt;/p&gt;

&lt;p&gt;🤖 you talk to AI&lt;br&gt;
🍎 you let it generate code&lt;br&gt;
🥱 you don’t care about details&lt;/p&gt;

&lt;p&gt;It worked for small projects. &lt;/p&gt;

&lt;p&gt;It was fun.&lt;/p&gt;

&lt;p&gt;But it was never serious engineering.&lt;/p&gt;

&lt;p&gt;Then things changed in 2026.&lt;/p&gt;

&lt;p&gt;By 2026, a new workflow became normal:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Agentic Engineering&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1egvkjhdlsmxdujbp1ly.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1egvkjhdlsmxdujbp1ly.png" alt="Image of agentic engineerin shift amon devevelopers" width="800" height="902"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This hits &lt;em&gt;different&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Now you don’t just “talk to AI”&lt;/p&gt;

&lt;p&gt;You:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🤹 manage AI coding agents&lt;/li&gt;
&lt;li&gt;🏗️ structure systems&lt;/li&gt;
&lt;li&gt;🦮 guide architecture&lt;/li&gt;
&lt;li&gt;🪸 correct mistakes&lt;/li&gt;
&lt;li&gt;🛫 control outputs like a system designer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You are no longer a coder.&lt;/p&gt;

&lt;p&gt;You are now a &lt;strong&gt;Chief of Commander&lt;/strong&gt; of machine. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5tnhs8wagp7md8ztbtoh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5tnhs8wagp7md8ztbtoh.png" alt="developer doing agentic engeering to fix customer feedback" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But here’s the trap:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can’t command what you don’t understand.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So fundamentals still rule everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  🍼 STEP 1: Coding Fundamentals (non-negotiable)
&lt;/h2&gt;

&lt;p&gt;Before AI, &lt;a href="https://dev.to/codewithshahan/skills-to-become-a-backend-developer-in-6-months-roadmap-4li3"&gt;coding fundamentals&lt;/a&gt; &lt;em&gt;was&lt;/em&gt; everything.&lt;/p&gt;

&lt;p&gt;Now?&lt;/p&gt;

&lt;p&gt;Still everything.&lt;/p&gt;

&lt;p&gt;You must learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[variables]&lt;/li&gt;
&lt;li&gt;[data types]&lt;/li&gt;
&lt;li&gt;conditions (if/else)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loops&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;[functions]&lt;/li&gt;
&lt;li&gt;object-oriented programming&lt;/li&gt;
&lt;li&gt;APIs&lt;/li&gt;
&lt;li&gt;privacy &amp;amp; security&lt;/li&gt;
&lt;li&gt;clean code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because if you cannot &lt;a href="https://dev.to/codewithshahan/clean-code-zero-to-one-4ihk"&gt;read, scale or maintain code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You CAN'T control AI-generated code. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ok5zdmsaep4jwgv3qen.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ok5zdmsaep4jwgv3qen.png" alt="ai agent leaking production database because dev doesn't know how to write code securely" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You become dependent. &lt;/p&gt;

&lt;p&gt;Your software becomes useless. &lt;/p&gt;

&lt;h3&gt;
  
  
  Language choice
&lt;/h3&gt;

&lt;p&gt;You should pick only one tech field first and go deep.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff913mw2hvrv3oz7jifq6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff913mw2hvrv3oz7jifq6.png" alt="what programming language to learn in 2026? a developer confuse what coding language to learn" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To begin with:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;learn Python for AI, automation, data systems&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;OR&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;learn JavaScript for web/mobile apps, frontend/backend&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pick ONE. Don’t jump.&lt;/p&gt;

&lt;h2&gt;
  
  
  🍌 STEP 2: Software Architecture
&lt;/h2&gt;

&lt;p&gt;This is where beginners quit.&lt;/p&gt;

&lt;p&gt;And professionals are built.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feve56ysqgbahztqu8x2r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feve56ysqgbahztqu8x2r.png" alt="Image of software dev learning sotware architecture and google is scanning if this app legit" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You must understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;how software is structured&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;how systems are designed (clean code)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;how tech stacks are chosen&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;how APIs connect systems&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;how data flows&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;where data is stored (databases)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now think: you want to build an app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3i7beryky1xiyz94m1b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3i7beryky1xiyz94m1b.png" alt="a confused AI agent sitting down arguing why developer don't know clean code architecture" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You must answer these questions:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Where does data go?&lt;br&gt;
How does it scale?&lt;br&gt;
How do users interact with it?&lt;br&gt;
How fast is it under load?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These are NOT coding questions.&lt;/p&gt;

&lt;p&gt;These are &lt;strong&gt;engineering decisions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And AI cannot reliably decide them for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧪 STEP 3: Testing
&lt;/h2&gt;

&lt;p&gt;AI can write code.&lt;/p&gt;

&lt;p&gt;But AI also makes mistakes silently.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcohux2ne440joklxqcgl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcohux2ne440joklxqcgl.png" alt="ai coding agents breaking project in production image illustration" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s dangerous.&lt;/p&gt;

&lt;p&gt;So you must learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🍽️ how to write test cases&lt;/li&gt;
&lt;li&gt;🍳 how to verify logic&lt;/li&gt;
&lt;li&gt;🪠 how to validate features&lt;/li&gt;
&lt;li&gt;🫗 how to catch failures early&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Concretely, without testing you are guessing.&lt;/p&gt;

&lt;p&gt;With testing:&lt;/p&gt;

&lt;p&gt;You are controlling your output.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛫 STEP 4: Deployment
&lt;/h2&gt;

&lt;p&gt;Code that ONLY runs locally is useless.&lt;/p&gt;

&lt;p&gt;learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🪂 how to host applications&lt;/li&gt;
&lt;li&gt;🗼 how servers work&lt;/li&gt;
&lt;li&gt;🪟 how environments are structured&lt;/li&gt;
&lt;li&gt;🪈 how deployment pipelines function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Job recruiters often ask about it. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs6sok9ox9dc1vnefnf9x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs6sok9ox9dc1vnefnf9x.png" alt="image of concept art of dev deploying facebook app and explain to Google recruiter" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You must ship to create history. &lt;/p&gt;

&lt;p&gt;You must understand and explain WHY things does/doesn't work.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛩️🎮 STEP 5: Version Control
&lt;/h2&gt;

&lt;p&gt;Version control (e,g. Git) is not optional. Its the baseline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fekwonjtui3td7eyhc6gq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fekwonjtui3td7eyhc6gq.png" alt="a developer is frustrated after losing his 2.5months of work and git assuring use me or lose another work" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
You need it even if AI is knocking on your door.&lt;/p&gt;

&lt;p&gt;Learn what version control does and master the most useful commands. &lt;/p&gt;

&lt;p&gt;You will thank me later. &lt;/p&gt;

&lt;p&gt;Now in AI-driven coding&lt;/p&gt;

&lt;p&gt;This becomes even more important.&lt;/p&gt;

&lt;p&gt;Because AI can break your project while you blink.&lt;/p&gt;

&lt;p&gt;Git or version control system will help you tackle it.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔐 STEP 6: Security &amp;amp; Privacy
&lt;/h2&gt;

&lt;p&gt;This is where AI fails the most. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frr9z3g90wiwu4x8zk643.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frr9z3g90wiwu4x8zk643.png" alt="Image of claude code meme stealing password from dev" width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI acts as a child to "security and privacy" &lt;/p&gt;

&lt;p&gt;And that's where beginners get destroyed without knowing.&lt;/p&gt;

&lt;p&gt;So learn&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;🥷 authentication&lt;/li&gt;
&lt;li&gt;👨‍🦯‍➡️ authorization&lt;/li&gt;
&lt;li&gt;🛟 data safety&lt;/li&gt;
&lt;li&gt;🗝️ secure APIs&lt;/li&gt;
&lt;li&gt;🔏 secret management&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;AI does NOT care about security unless you force it to.&lt;/p&gt;

&lt;p&gt;And real engineers know this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Paranoia is not fear. it is protection."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Which means build a proactive security-first mindset where you assume threats exist and systems will fail.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚢 STEP 7: Microservices &amp;amp; Containers
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fka0mpfzarvcvjf61y35g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fka0mpfzarvcvjf61y35g.png" alt="Image of developer using docker where AI fails" width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is advanced.&lt;/p&gt;

&lt;p&gt;But important.&lt;/p&gt;

&lt;p&gt;You should learn:&lt;/p&gt;

&lt;p&gt;-0  how applications are packaged&lt;br&gt;
-01 how dependencies are bundled&lt;br&gt;
-02 how systems run in isolation&lt;br&gt;
-04 how environments stay consistent&lt;/p&gt;

&lt;p&gt;Why does this matter now?&lt;/p&gt;

&lt;p&gt;Because AI agents can break your projects, break environments and create unpredictable setups&lt;/p&gt;

&lt;p&gt;Containers (e.g., Docker) protect you from drowning.&lt;/p&gt;




&lt;h2&gt;
  
  
  💪 NOW you are ready for AI coding
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1pi9vvd6p4pr6b7914mq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1pi9vvd6p4pr6b7914mq.png" alt="developer ready for using AI coding and buid projects much faster" width="800" height="905"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Only after all this…&lt;/p&gt;

&lt;p&gt;You use AI properly.&lt;/p&gt;

&lt;p&gt;But as a tool.&lt;/p&gt;

&lt;p&gt;Now you can&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📢 direct AI agents&lt;/li&gt;
&lt;li&gt;🍔 build systems faster&lt;/li&gt;
&lt;li&gt;🤜 correct mistakes&lt;/li&gt;
&lt;li&gt;🏠 design architecture&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ⚡ The new coding shift: Agentic Engineering
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1egvkjhdlsmxdujbp1ly.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1egvkjhdlsmxdujbp1ly.png" alt="Image of agentic engineerin shift amon devevelopers" width="800" height="902"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now coding looks like this:&lt;/p&gt;

&lt;p&gt;You open your machine.&lt;/p&gt;

&lt;p&gt;Multiple AI agents working:&lt;/p&gt;

&lt;p&gt;One builds backend. One writes tests. One handles docs&lt;/p&gt;

&lt;p&gt;You assign tasks, correct mistakes, guide structure, AND enforce logic.&lt;/p&gt;

&lt;p&gt;This is not coding anymore. &lt;/p&gt;

&lt;p&gt;This is agentic engineering. &lt;/p&gt;

&lt;p&gt;Make sure to learn it early. &lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 How to learn code faster
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6zpewla8ydspjgtl811.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6zpewla8ydspjgtl811.png" alt="how to learn code faster meme" width="800" height="902"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most people fail here because they consume too much content.&lt;/p&gt;

&lt;p&gt;or learn but never build&lt;/p&gt;

&lt;p&gt;Before, it took 2–5 years to become solid developer&lt;/p&gt;

&lt;p&gt;Now ~6 months if you are focused. &lt;/p&gt;

&lt;p&gt;Because tools will multiply your output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So here is the solid strategy to learn code faster:&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  🤔 1. Use AI to THINK, not just code
&lt;/h3&gt;

&lt;p&gt;Don’t ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“write code”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"explain this"&lt;br&gt;
"break it down"&lt;br&gt;
"give analogies"&lt;br&gt;
"show mistakes"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  🔍 2. Reverse engineer code
&lt;/h3&gt;

&lt;p&gt;Take real projects.&lt;/p&gt;

&lt;p&gt;Then: break them, modify them and ask AI to explain them&lt;/p&gt;

&lt;p&gt;That is actual serious learning.&lt;/p&gt;

&lt;h3&gt;
  
  
  🏗️ 3. Projects = everything
&lt;/h3&gt;

&lt;p&gt;No projects = no skill.&lt;/p&gt;

&lt;p&gt;You must:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;☑️ build APIs&lt;/li&gt;
&lt;li&gt;☑️ build apps&lt;/li&gt;
&lt;li&gt;☑️ build features&lt;/li&gt;
&lt;li&gt;☑️ break and fix things&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s how neural memory forms. &lt;/p&gt;

&lt;p&gt;Reading or watching tutorials is another word for procrastination. &lt;/p&gt;

&lt;h3&gt;
  
  
  🧠 4. Ask AI for multiple solutions
&lt;/h3&gt;

&lt;p&gt;NEVER accept one answer.&lt;/p&gt;

&lt;p&gt;Ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“give me 3 approaches”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;this way you'll learn: tradeoffs. efficiency. structure&lt;/p&gt;

&lt;h3&gt;
  
  
  📄 5. Documentation shortcut
&lt;/h3&gt;

&lt;p&gt;Nobody likes reading documentation.&lt;/p&gt;

&lt;p&gt;Don’t struggle through docs.&lt;/p&gt;

&lt;p&gt;Use AI to translate them.&lt;/p&gt;

&lt;p&gt;But still understand them.&lt;/p&gt;

&lt;h2&gt;
  
  
  📚 Recommendation
&lt;/h2&gt;

&lt;p&gt;If you want a clean, structured path:&lt;/p&gt;

&lt;p&gt;📘 My &lt;strong&gt;&lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt;&lt;/strong&gt; book is for you:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fic3yhzc59cy84ftdt9ew.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fic3yhzc59cy84ftdt9ew.png" alt="developer reading clean code zero to one book written by Shahan Chowdhury" width="800" height="953"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After reading this book you'll think like a system designer. Write clean architecture. Scale and maintain your application and avoid beginner's mistakes.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧭 Final thoughts
&lt;/h2&gt;

&lt;p&gt;Coding in 2026 is easy. &lt;/p&gt;

&lt;p&gt;BUT its not "too easy" as 63% of non-developers so called "vibe coders" think. They all face the reality when seriously get involved in buidling softwares. &lt;/p&gt;

&lt;p&gt;either you learn fundamentals&lt;/p&gt;

&lt;p&gt;Or you skip fundamentals and get replaced. &lt;/p&gt;

&lt;p&gt;There is no middle. &lt;/p&gt;

&lt;p&gt;Now open your code editor and build something cool from scratch! 🥂&lt;/p&gt;

&lt;p&gt;You can follow me on &lt;a href="https://www.linkedin.com/in/codewithshahan" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;. Thanks.&lt;/p&gt;

</description>
      <category>coding</category>
      <category>programming</category>
      <category>ai</category>
      <category>career</category>
    </item>
    <item>
      <title>learn these 12 git commands and forget</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Fri, 17 Apr 2026 22:31:10 +0000</pubDate>
      <link>https://dev.to/codewithshahan/mastering-git-github-12-most-useful-git-commands-3l70</link>
      <guid>https://dev.to/codewithshahan/mastering-git-github-12-most-useful-git-commands-3l70</guid>
      <description>&lt;h2&gt;
  
  
  🌱 Introduction
&lt;/h2&gt;

&lt;p&gt;Most devs think they can vibe code with a few Git commands.&lt;br&gt;
They run &lt;code&gt;git add .&lt;/code&gt;, "push commit" … and start acting like they built Linux.&lt;/p&gt;

&lt;p&gt;I’ve seen the opposite.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj17y2egh5b0w75tp7cs5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj17y2egh5b0w75tp7cs5.png" alt="Image description: 12 advanced Git commands 2026 by Shahan" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;they trust AI agents and then the project turns into something nobody wants to touch.&lt;/p&gt;

&lt;p&gt;I’ve done that too, early on.&lt;/p&gt;

&lt;p&gt;The difference is that you eventually get tired of fixing avoidable problems. That’s when Git stops being a checklist of commands and starts becoming a way of working.&lt;/p&gt;

&lt;p&gt;These 12 git commands I actually rely on when things get messy or when I want to keep things clean from the start.&lt;/p&gt;

&lt;p&gt;now lets get started.&lt;/p&gt;


&lt;h2&gt;
  
  
  🎂 1) Rebasing
&lt;/h2&gt;

&lt;p&gt;AI code reviewers and merge queues DO NOT babysit premature branches. &lt;/p&gt;

&lt;p&gt;They &lt;u&gt;expect&lt;/u&gt; discipline.&lt;/p&gt;

&lt;p&gt;most so called git expert stack commits like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;fix&lt;br&gt;
fix again&lt;br&gt;
testing&lt;br&gt;
oops&lt;br&gt;
final-final-v3&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then they open a PR (pull request) and &lt;a href="https://dev.to/codewithshahan/how-to-write-clean-code-tips-for-developers-with-examples-25ic"&gt;hope it works&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Unfortunately it doesn’t. &lt;/p&gt;
&lt;h3&gt;
  
  
  🍄‍🟫 What rebase actually is
&lt;/h3&gt;

&lt;p&gt;Look at the image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh1d6t1a4s1gci3l4vljf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh1d6t1a4s1gci3l4vljf.png" alt="Image description of " width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bottom = old commits&lt;br&gt;
Top = latest main&lt;br&gt;
Dog = your feature branch&lt;/p&gt;

&lt;p&gt;Right now your branch is behind.&lt;/p&gt;

&lt;p&gt;The dog is sitting somewhere in the middle.&lt;/p&gt;

&lt;p&gt;But he wants the top.&lt;/p&gt;

&lt;p&gt;So what does he do?&lt;/p&gt;

&lt;p&gt;He cLimbs.&lt;/p&gt;

&lt;p&gt;Step by step.&lt;/p&gt;

&lt;p&gt;And then he sits on top of the latest main.&lt;/p&gt;

&lt;p&gt;That’s &lt;strong&gt;rebase.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You don’t build sideways.&lt;br&gt;
You don’t stay behind.&lt;/p&gt;

&lt;p&gt;You move your work to the top.&lt;/p&gt;

&lt;p&gt;Clean. Straight. Done.&lt;/p&gt;

&lt;p&gt;🤔 You ask &lt;strong&gt;why?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look, modern teams use &lt;a href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request" rel="noopener noreferrer"&gt;AI merge queues, automated reviewers, async PR pipelines.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These systems are NOT your mother.&lt;/p&gt;

&lt;p&gt;THey don’t review your failure.&lt;/p&gt;

&lt;p&gt;AI pipelines don’t fix your alienated history.&lt;/p&gt;

&lt;p&gt;They see this:&lt;/p&gt;

&lt;p&gt;random commits&lt;br&gt;
unclear changes&lt;br&gt;
outdated branch&lt;/p&gt;

&lt;p&gt;🙅‍♂️ And they reject it.&lt;/p&gt;

&lt;p&gt;Not because you’re bad.&lt;/p&gt;

&lt;p&gt;Because your &lt;em&gt;git history&lt;/em&gt; is turmoil. 🧐🌡️&lt;/p&gt;

&lt;p&gt;WitH rebase you fix everything before PR.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Now merge is simple.&lt;/u&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  🍨 Rebase workflow
&lt;/h3&gt;

&lt;p&gt;This is what you actually do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch feature-login
git fetch origin
git rebase origin/main

git add &lt;span class="nb"&gt;.&lt;/span&gt;
git rebase &lt;span class="nt"&gt;--continue&lt;/span&gt;

git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🏗️ Code demonstrations for beginners:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;1) 🧗‍♂️ Switch to your feature branch = &lt;code&gt;git switch feature-login&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You move into your own work area.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) ⛅ Get latest updates from remote = &lt;code&gt;git fetch origin&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You look at what changed on the server using fetch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3) 🛟 Rebuild your work on top of latest main = &lt;code&gt;git rebase origin/main&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the core moment.&lt;/p&gt;

&lt;p&gt;Git takes your commits and replays them one by one on top of the newest main.&lt;/p&gt;

&lt;p&gt;So instead of:&lt;/p&gt;

&lt;p&gt;messy branch history&lt;br&gt;
outdated base&lt;/p&gt;

&lt;p&gt;You now get:&lt;/p&gt;

&lt;p&gt;clean linear history&lt;br&gt;
same work, new foundation&lt;/p&gt;

&lt;p&gt;If conflicts happen, Git stops here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4) 🚤 Fix conflicts (if any)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
git rebase &lt;span class="nt"&gt;--continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means:&lt;/p&gt;

&lt;p&gt;you fix the files&lt;br&gt;
you tell Git: “okay continue”&lt;/p&gt;

&lt;p&gt;Git keeps replaying your commits until everything is applied.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5) Push updated history = &lt;code&gt;git push --force-with-lease&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Important part:&lt;/p&gt;

&lt;p&gt;You are not just pushing code.&lt;/p&gt;

&lt;p&gt;You are rewriting history.&lt;/p&gt;

&lt;p&gt;So Git says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Only push if nobody else changed this branch while you were working.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s what &lt;code&gt;--force-with-lease&lt;/code&gt; protects you from. &lt;/p&gt;

&lt;p&gt;It checks if someone else updated the branch.&lt;/p&gt;

&lt;p&gt;If yes, it stops you.&lt;/p&gt;

&lt;p&gt;So you don’t destroy their work.&lt;/p&gt;

&lt;p&gt;again, rebase changes history.&lt;/p&gt;

&lt;p&gt;That’s why you don’t just &lt;code&gt;--force&lt;/code&gt; push blindly. &lt;/p&gt;


&lt;h2&gt;
  
  
  🪦 2) Reset, Revert, Restore
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4j21v0xnzqj5aqzn16t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4j21v0xnzqj5aqzn16t.png" alt="Image description: 2) Reset, Revert, Restore" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mistakes will happen.&lt;/p&gt;

&lt;p&gt;That’s normal.&lt;/p&gt;

&lt;p&gt;Panicking is optional.&lt;/p&gt;

&lt;p&gt;Some developers break things… then freeze.&lt;/p&gt;

&lt;p&gt;Others fix it in 10 seconds and move on.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Read &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt; and become like them.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;The difference is knowing which command to use.&lt;/p&gt;
&lt;h3&gt;
  
  
  Git gives you &lt;strong&gt;three weapons&lt;/strong&gt; to reverse damage:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git revert HEAD 
git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; HEAD~1
git restore &lt;span class="nt"&gt;--staged&lt;/span&gt; app.js
git restore app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;[ code demonstration is below ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1) 🦺 &lt;code&gt;git revert&lt;/code&gt; | safe undo&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You don’t delete anything.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git revert HEAD&lt;/code&gt; = Makes a &lt;em&gt;new&lt;/em&gt; commit that cancels the last one.&lt;/p&gt;

&lt;p&gt;History stays clean.&lt;/p&gt;

&lt;p&gt;Nothing is hidden.&lt;/p&gt;

&lt;p&gt;This is what serious teams want.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2) 🗑️ &lt;code&gt;git reset&lt;/code&gt; | delete it completely&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This one is different.&lt;/p&gt;

&lt;p&gt;It moves your branch back.&lt;/p&gt;

&lt;p&gt;The commit is gone.&lt;/p&gt;

&lt;p&gt;Like it never happened.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git reset --hard HEAD~1&lt;/code&gt; = Deletes the last commit and your changes.&lt;/p&gt;

&lt;p&gt;Fast. Clean. But dangerous.&lt;/p&gt;

&lt;p&gt;If someone already pulled that commit… you just created a big mess.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use it when you’re alone on the branch.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3) 🗃️ &lt;code&gt;git restore&lt;/code&gt; | fix files only&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This doesn’t touch history.&lt;/p&gt;

&lt;p&gt;It just fixes your working files.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git restore --staged app.js&lt;/code&gt; = Removes &lt;code&gt;app.js&lt;/code&gt; from staging (undo git add). Your edits stay untouched.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git restore app.js&lt;/code&gt; = Deletes your changes. File goes back to last commit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 Concretely:&lt;/strong&gt;&lt;br&gt;
revert → undo safely&lt;br&gt;
reset → erase history&lt;br&gt;
restore → fix files&lt;/p&gt;

&lt;p&gt;Three different jobs.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Where people mess up?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;They use reset when they should use revert.&lt;/p&gt;

&lt;p&gt;Now history is broken.&lt;/p&gt;

&lt;p&gt;Team is confused.&lt;/p&gt;

&lt;p&gt;Time is wasted.&lt;/p&gt;
&lt;h3&gt;
  
  
  🦐 2026 RRR Best Practices
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffoh3nxjx6ri88jt7iwk5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffoh3nxjx6ri88jt7iwk5.png" alt="Image description: git checkout no longer needed use git switch and git checkout" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git switch&lt;/code&gt; and &lt;code&gt;git restore&lt;/code&gt; replaced the overloaded confusing &lt;code&gt;git checkout&lt;/code&gt;. This isn’t optional anymore.&lt;/p&gt;

&lt;p&gt;Modern teams would love to see you using them.&lt;/p&gt;

&lt;p&gt;Old messy &lt;code&gt;git checkout&lt;/code&gt; command did everything: &lt;br&gt;
Switch branches. Restore files. Confuse everyone.&lt;/p&gt;

&lt;p&gt;Now it’s split into two:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git switch&lt;/code&gt;: move between branches&lt;br&gt;
&lt;code&gt;git restore&lt;/code&gt;: fix files / undo file changes&lt;/p&gt;

&lt;p&gt;ITs much cleaner and accurate. &lt;/p&gt;

&lt;p&gt;That’s why you will &lt;strong&gt;never&lt;/strong&gt; see me use &lt;code&gt;checkout&lt;/code&gt; in this article.&lt;/p&gt;

&lt;p&gt;It’s outdated. &lt;/p&gt;

&lt;p&gt;Just like a serious dev who &lt;a href="https://dev.to/codewithshahan/how-to-write-clean-code-tips-for-developers-with-examples-25ic"&gt;refuses to shallow AI hypes.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will show you EXACTLY how they work in the next section (#3).&lt;/p&gt;


&lt;h2&gt;
  
  
  🫰3) Switch &amp;amp; Restore
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9igzuuiz0akqqinm29x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9igzuuiz0akqqinm29x.png" alt="Image description: Git Switch &amp;amp; Restore (Modern Navigation)" width="800" height="336"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch main
git switch &lt;span class="nt"&gt;-c&lt;/span&gt; feature-payment

git restore README.md
git restore &lt;span class="nt"&gt;--staged&lt;/span&gt; utils.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  👉 &lt;code&gt;git switch main&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;with that, you leave your current branch and return to mission control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;br&gt;
You’re on: &lt;code&gt;bugfix/login-issue&lt;/code&gt;&lt;br&gt;
You’ve got random work-in-progress edits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;After running:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You are now on the &lt;code&gt;main&lt;/code&gt; branch. &lt;/p&gt;

&lt;p&gt;Your files instantly match the &lt;code&gt;main&lt;/code&gt; branch’s state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✍️ NOTE:&lt;/strong&gt; Uncommitted edits may follow, unless switching would create conflicts, in which case Git stops you to avoid damage. That's protection.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;either way, you’ve returned to home base. You’re back to clean ground..&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  👉 &lt;code&gt;git switch -c feature-payment&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt;&lt;br&gt;
A new branch &lt;strong&gt;is created&lt;/strong&gt;  which is &lt;code&gt;feature-payment&lt;/code&gt;&lt;br&gt;
And you immediately &lt;strong&gt;enter&lt;/strong&gt; that branch.&lt;/p&gt;

&lt;p&gt;Now your payment feature lives in isolation.&lt;/p&gt;

&lt;p&gt;No risk of breaking main.&lt;br&gt;
No overlap with other features.&lt;/p&gt;

&lt;p&gt;🪜 One branch per mission. &lt;/p&gt;


&lt;h3&gt;
  
  
  👉 &lt;code&gt;git restore --staged utils.js&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This is your emergency fix when you accidentally run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and stage files you didn’t want to include.&lt;/p&gt;

&lt;p&gt;Fix it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
git restore &lt;span class="nt"&gt;--staged&lt;/span&gt; utils.js

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;utils.js&lt;/code&gt; is &lt;em&gt;unstaged&lt;/em&gt; which is removed from the commit list.&lt;/p&gt;

&lt;p&gt;But your edits remain safely in your working directory.&lt;/p&gt;

&lt;p&gt;which means, you fix the mistake without losing a single line.&lt;/p&gt;




&lt;h2&gt;
  
  
  🐾 4) --amend Commits [Fix Without Noise]
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv15yeio3v7x7n8a7btda.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv15yeio3v7x7n8a7btda.png" alt="Image description: 4) Amend Commits [Fix Without Noise]" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You forgot a file?&lt;br&gt;
You wrote a typo?&lt;br&gt;
You missed a small edit?&lt;/p&gt;

&lt;p&gt;You &lt;code&gt;--amend&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧱 What “--amend” actually DOES?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Amend means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Take my LAST commit and update it as if the mistake NEVER existed.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It does NOT create a new commit. It &lt;em&gt;replaces&lt;/em&gt; the previous one.&lt;/p&gt;

&lt;p&gt;But most commits like this:&lt;/p&gt;

&lt;p&gt;“fix again”&lt;br&gt;
“final fix”&lt;br&gt;
“real final fix”&lt;/p&gt;

&lt;p&gt;Now history looks like garbage.&lt;/p&gt;

&lt;p&gt;No worries.. you can time travel and &lt;code&gt;--amend&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Real example (this happens all the time)
&lt;/h3&gt;

&lt;p&gt;You accidentally committed .env&lt;/p&gt;

&lt;p&gt;Sensitive keys. Big mistake.&lt;/p&gt;

&lt;p&gt;You don’t say:&lt;/p&gt;

&lt;p&gt;“oops let me fix it in next commit”&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;You clean it properly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;--cached&lt;/span&gt; .env
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;".env"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; .gitignore
git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;--no-edit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Done.&lt;/p&gt;

&lt;p&gt;That commit never had .env.&lt;/p&gt;

&lt;p&gt;⏹️ You remove the sensitive file&lt;br&gt;
and rewrite the last commit like it never existed.&lt;/p&gt;

&lt;p&gt;Let me explain.. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;git rm --cached .env&lt;/code&gt; 👉 This removes .env from Git tracking (not your computer)&lt;/p&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;echo ".env" &amp;gt;&amp;gt; .gitignore&lt;/code&gt; 👉 So you don’t repeat the same mistake&lt;/p&gt;

&lt;p&gt;Now your changes are staged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;THEN you run:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git commit --amend --no-edit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🫡 This rewrites the last commit&lt;br&gt;
👉 Same message&lt;br&gt;
🦵 But WITHOUT the .env file&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why &lt;code&gt;--no-edit&lt;/code&gt;?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because you don’t want to waste time rewriting the message.&lt;/p&gt;

&lt;p&gt;You’re saying:&lt;/p&gt;

&lt;p&gt;“Same commit message. Just fix the mistake.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🤔 What if you WANT to edit?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then DO NOT use &lt;code&gt;--no-edit.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Just do:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git commit --amend&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now Git opens the editor.&lt;/p&gt;

&lt;p&gt;You can fix the message, explain what changed and make it more professional&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now let me illustrate an everyday use case scenario:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt;
git rebase &lt;span class="nt"&gt;-i&lt;/span&gt; HEAD~5
&lt;span class="nt"&gt;--amend&lt;/span&gt; → fix your last mistake instantly
rebase &lt;span class="nt"&gt;-i&lt;/span&gt; → squash, reorder, clean commits like a surgeon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how you turn:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“fixed stuff lol”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;into [for example]:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Refactor auth flow + fix token expiry bug” &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now your history makes sense.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚠️ WARNING (read twice):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Only --amend local commits.&lt;/p&gt;

&lt;p&gt;Never &lt;code&gt;--amend&lt;/code&gt; commits already pushed to a &lt;u&gt;team branch&lt;/u&gt;.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because you rewrite history.&lt;/p&gt;

&lt;p&gt;Automated pipelines, merge queues and AI agents HATE rewritten history.&lt;/p&gt;

&lt;p&gt;🥍 Push amended commits ONLY if you're 100% sure NO ONE else has pulled them.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏫 5) Git Log / Learn From History
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0t2gfsv58c1evp10pv5.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0t2gfsv58c1evp10pv5.gif" alt="Image description 5) Git Log [Learn From History]" width="720" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git doesn’t lie.&lt;/p&gt;

&lt;p&gt;Your code can lie. Your memory can lie. Your teammates can lie.&lt;/p&gt;

&lt;p&gt;nowadays devs zombie scroll through Git logs.&lt;/p&gt;

&lt;p&gt;They don’t understand the POWER &lt;em&gt;hidden&lt;/em&gt; in "history".&lt;/p&gt;

&lt;p&gt;Good history = easy debugging&lt;br&gt;
Bad history = endless suffering&lt;/p&gt;
&lt;h3&gt;
  
  
  ⚖️ The 50/72 rule
&lt;/h3&gt;

&lt;p&gt;Follow 50/72 Rule for efficient bug tracing AND debugging.&lt;/p&gt;

&lt;p&gt;keep titles under 50 characters and wrap descriptions at 72. &lt;/p&gt;

&lt;p&gt;write messages like "Add feature" instead of "Added feature". &lt;/p&gt;

&lt;p&gt;and do not mix code refactors with new features in the same commit.&lt;/p&gt;

&lt;p&gt;Bad example:&lt;/p&gt;

&lt;p&gt;commit 1: "fixed stuff"&lt;br&gt;
commit 2: "final update&lt;br&gt;
commit 3: "changes lol.."&lt;/p&gt;

&lt;p&gt;Good example:&lt;/p&gt;

&lt;p&gt;commit 1: "fix(auth): resolve token expiry issue"&lt;/p&gt;

&lt;p&gt;Now you know what happened without opening code.&lt;/p&gt;
&lt;h3&gt;
  
  
  Basic survival commands
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;git log --oneline&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git log --oneline --graph --decorate&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git log --oneline --author="Shahan"&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git log --oneline -- path/to/file&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What they really mean:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--oneline&lt;/code&gt; = fast history scan + short, readable commits&lt;br&gt;
&lt;code&gt;--graph&lt;/code&gt; = see branch chaos visually&lt;br&gt;
&lt;code&gt;--graph --decorate&lt;/code&gt; → visualize merges &amp;amp; branches&lt;br&gt;
&lt;code&gt;--author&lt;/code&gt; = see who broke what&lt;br&gt;
&lt;code&gt;-- path/to/file&lt;/code&gt; = see only a single file’s history&lt;/p&gt;

&lt;p&gt;This is how you stop guessing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When things get serious you type&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;git log -p&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git log -S "functionName"&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git blame file.js&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git reflog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now you’re not reading history.&lt;/p&gt;

&lt;p&gt;You’re hunting problems.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-p&lt;/code&gt; shows exact code changes&lt;br&gt;
&lt;code&gt;-S&lt;/code&gt; finds when a bug was introduced&lt;br&gt;
&lt;code&gt;git blame&lt;/code&gt; shows who touched each line&lt;br&gt;
&lt;code&gt;git reflog&lt;/code&gt; brings back “lost” commits&lt;/p&gt;


&lt;h2&gt;
  
  
  6) 🪝 Git Hooks to Automate Discipline
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9x0xrkcbctd3djb9cf9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9x0xrkcbctd3djb9cf9.png" alt="Image description: 6) Git Hooks to Automate Discipline" width="800" height="336"&gt;&lt;/a&gt;&lt;br&gt;
Junior devs hope code is fine.&lt;/p&gt;

&lt;p&gt;Serious devs don’t hope anything.&lt;/p&gt;

&lt;p&gt;They build systems that refuse bad code.&lt;/p&gt;

&lt;p&gt;That’s what Git hooks are.&lt;/p&gt;

&lt;p&gt;Hooks are simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;They run automatically when you commit, push, or merge.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Without asking. Without reminders. &lt;/p&gt;

&lt;p&gt;If something is wrong they stop you.&lt;/p&gt;

&lt;p&gt;The idea is simple:&lt;/p&gt;

&lt;p&gt;You try to commit.&lt;/p&gt;

&lt;p&gt;Git says:&lt;/p&gt;

&lt;p&gt;“Wait. Let me check that first.”&lt;/p&gt;
&lt;h3&gt;
  
  
  🔧 example of git hooks pre-commit (gatekeeper)
&lt;/h3&gt;

&lt;p&gt;You create this file:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.git/hooks/pre-commit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now you add rules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Running tests..."&lt;/span&gt;

npm &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"❌ Tests failed. Commit blocked."&lt;/span&gt;
  &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then activate it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x .git/hooks/pre-commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;What just happened?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You didn’t “add a tool.”&lt;/p&gt;

&lt;p&gt;You added a guard at the door.&lt;/p&gt;

&lt;p&gt;Now:&lt;/p&gt;

&lt;p&gt;tests run automatically&lt;br&gt;
failure = commit rejected&lt;br&gt;
broken code never enters history&lt;/p&gt;

&lt;p&gt;Therefore, there's NO debate anymore. &lt;br&gt;
No “I’ll fix it later” nap issue.  &lt;/p&gt;
&lt;h3&gt;
  
  
  🪫2026 Git Hooks Reality
&lt;/h3&gt;

&lt;p&gt;Nowadays most teams don’t hand-write hooks anymore.&lt;/p&gt;

&lt;p&gt;They use tools:&lt;/p&gt;

&lt;p&gt;they use &lt;strong&gt;&lt;a href="https://typicode.github.io/husky/" rel="noopener noreferrer"&gt;Husky&lt;/a&gt;&lt;/strong&gt; to manage hooks cleanly&lt;/p&gt;

&lt;p&gt;or &lt;strong&gt;&lt;a href="https://github.com/lint-staged/lint-staged" rel="noopener noreferrer"&gt;lint-staged&lt;/a&gt;&lt;/strong&gt; to run checks only on changed files&lt;/p&gt;

&lt;p&gt;Because raw hooks don’t scale well.&lt;/p&gt;

&lt;p&gt;Tools make it consistent.&lt;/p&gt;
&lt;h3&gt;
  
  
  Important truth most tutorials skip
&lt;/h3&gt;

&lt;p&gt;Local hooks are not secure.&lt;/p&gt;

&lt;p&gt;Anyone can bypass them:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git commit --no-verify&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And everything gets ignored. &lt;br&gt;
So if you rely ONLY on local hooks you're mistaken.&lt;/p&gt;

&lt;p&gt;So hooks alone are not enough. &lt;br&gt;
Let me explain why..&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real system (what professionals use):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You combine two layers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Local hooks&lt;/strong&gt; (Fast feedback. Instant rejection.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. CI/CD pipelines&lt;/strong&gt; (GitHub Actions, etc.)&lt;/p&gt;

&lt;p&gt;SO&lt;br&gt;
⚡Local = speed&lt;br&gt;
⚖️ Server = enforcement&lt;/p&gt;

&lt;p&gt;Local catches mistakes early.&lt;br&gt;
Server enforces rules for everyone.&lt;/p&gt;

&lt;p&gt;Together,nothing broken gets through. YOU WIN. &lt;/p&gt;


&lt;h2&gt;
  
  
  🍋‍🟩🪞 7) Commit References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9o4souqlws906nvj5i34.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9o4souqlws906nvj5i34.png" alt="Image description  7) Commit References" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;beginners copy full commit hashes like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;a3f9c1d8b7e...&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Long. Ugly. Useless in daily work.&lt;/p&gt;

&lt;p&gt;You don’t need that noise.&lt;/p&gt;
&lt;h3&gt;
  
  
  🔧 Core Commands
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff HEAD~2..HEAD
git rev-parse &lt;span class="nt"&gt;--short&lt;/span&gt; HEAD
git tag &lt;span class="nt"&gt;-a&lt;/span&gt; v2.0 &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Release v2.0"&lt;/span&gt;
git push origin v2.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;-- &lt;code&gt;HEAD~2..HEAD&lt;/code&gt; = compare recent changes &lt;/p&gt;

&lt;p&gt;-- &lt;code&gt;rev-parse --short HEAD&lt;/code&gt; = quick reference (human-friendly ID)&lt;/p&gt;

&lt;p&gt;-- &lt;code&gt;tag -a&lt;/code&gt; = mark a stable checkpoint (this matters)&lt;/p&gt;

&lt;p&gt;-- &lt;code&gt;push origin v2.0&lt;/code&gt; = share that checkpoint with the world&lt;/p&gt;
&lt;h3&gt;
  
  
  🧠 Understand this properly
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;HEAD&lt;/code&gt; = where you are&lt;br&gt;
&lt;code&gt;HEAD~1&lt;/code&gt; = one step back&lt;br&gt;
&lt;code&gt;HEAD~2&lt;/code&gt; = two steps back&lt;/p&gt;

&lt;p&gt;You’re not memorizing hashes anymore.&lt;/p&gt;

&lt;p&gt;You’re jumping up/down in a timeline. its super productive.&lt;/p&gt;
&lt;h3&gt;
  
  
  🆔 Why Tags Actually Matter??
&lt;/h3&gt;

&lt;p&gt;Tags are not decoration.&lt;/p&gt;

&lt;p&gt;They are &lt;strong&gt;anchors.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git tag &lt;span class="nt"&gt;-a&lt;/span&gt; v2.0 &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Release v2.0"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’re declaring:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“This version is stable. This is deployable.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now your CI/CD pipelines + Deployment systems and AI tools&lt;/p&gt;

&lt;p&gt;All know exactly &lt;strong&gt;what to ship.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;NOTE: ⚠️ Fix this weak idea&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Full hashes are sh$t”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blind usage is actual sh$t.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Full hashes are for finding exact location, scripting and debugging critical issues,&lt;/p&gt;

&lt;p&gt;Short refs are for &lt;strong&gt;speed&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Know both.&lt;/p&gt;




&lt;h2&gt;
  
  
  8) 🧳Stash [Pause Work Without Panic]
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F94bsczid7fk7ljp1wwll.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F94bsczid7fk7ljp1wwll.png" alt="Image description 8) 🧳 Stash [Pause Work Without Panic]" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Interruptions are coming.&lt;/p&gt;

&lt;p&gt;Boss calls. Bug report drops. Production is on fire.&lt;/p&gt;

&lt;p&gt;And you’re sitting there with half-written code…&lt;/p&gt;

&lt;p&gt;Now what?&lt;/p&gt;

&lt;p&gt;Commit garbage?&lt;br&gt;
Lose your work?&lt;br&gt;
Panic?&lt;/p&gt;

&lt;p&gt;NO.. professionals don’t panic&lt;/p&gt;

&lt;p&gt;They &lt;code&gt;stash&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  What stash actually is?
&lt;/h3&gt;

&lt;p&gt;Stash is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Save everything I’m doing right now… and bring me back to a clean state.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;No commit. No history pollution.&lt;/p&gt;

&lt;p&gt;Just pause.&lt;/p&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;Let say you’re working on a feature.&lt;/p&gt;

&lt;p&gt;Suddenly you recieved a message from colleage:&lt;/p&gt;

&lt;p&gt;“URGENT: Fix login bug NOW.”&lt;/p&gt;

&lt;p&gt;You don’t argue.&lt;/p&gt;

&lt;p&gt;You run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash push &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"WIP: profile fix"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything disappears.&lt;/p&gt;

&lt;p&gt;Not deleted.&lt;/p&gt;

&lt;p&gt;Just stored safely.&lt;/p&gt;

&lt;p&gt;Your workspace becomes clean again.&lt;/p&gt;

&lt;p&gt;Now switch safely&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch main
git pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you fix the urgent issue without your half-work getting in the way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;See what you saved&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git stash list&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It’s like a small vault of paused work.&lt;/p&gt;

&lt;p&gt;Nothing lost. Just parked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Bring it back&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you’re ready:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git stash apply&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Your work comes back exactly as it was.&lt;/p&gt;

&lt;p&gt;Or:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git stash pop&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Same thing, but removes it from stash after restoring.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advanced move
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash branch hotfix-auth stash@&lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This does something smarter:&lt;/p&gt;

&lt;p&gt;creates a new branch&lt;br&gt;
restores your work there&lt;br&gt;
keeps main branch clean&lt;/p&gt;

&lt;p&gt;So you don’t mix emergency fixes with unfinished features.&lt;/p&gt;

&lt;p&gt;No conflict with main work. &lt;/p&gt;
&lt;h3&gt;
  
  
  ⚠️🛩️ Reality Check
&lt;/h3&gt;

&lt;p&gt;Stash is NOT permanent storage.&lt;/p&gt;

&lt;p&gt;It’s temporary.&lt;/p&gt;

&lt;p&gt;Forget it… and it becomes a graveyard.🪦&lt;/p&gt;

&lt;p&gt;So use it. Don’t hoard it.&lt;/p&gt;
&lt;h3&gt;
  
  
  When to use stash
&lt;/h3&gt;

&lt;p&gt;Use it when:&lt;/p&gt;

&lt;p&gt;you saves unfinished work safely and then switch tasks instantly&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;anytime create a branch from stash (stash branch) for experiment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In summary.. need to switch tasks mid-flow? &lt;code&gt;Stash&lt;/code&gt; temporarily saves your changes.&lt;/p&gt;


&lt;h2&gt;
  
  
  9) Bisect 🐞
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qlq41rkygwfvfd11of1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3qlq41rkygwfvfd11of1.gif" alt="Image description 9) Bisect" width="760" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Manual bug hunting? WEAK MOVE. &lt;/p&gt;

&lt;p&gt;Manual bug hunting is slow.&lt;/p&gt;

&lt;p&gt;And slow means you suffer.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Bisect&lt;/code&gt; = sniper rifle for bug hunting.&lt;/p&gt;

&lt;p&gt;Think now: something breaks in production.&lt;/p&gt;

&lt;p&gt;Login stops working.&lt;/p&gt;

&lt;p&gt;No logs. No clear reason.&lt;/p&gt;

&lt;p&gt;Only one truth:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It worked yesterday. It’s broken today.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And now you have 50+ commits in between.&lt;/p&gt;

&lt;p&gt;Amateurs go to sleep.&lt;/p&gt;

&lt;p&gt;Professionals starts hunting.&lt;/p&gt;

&lt;p&gt;So what's the solution? you divide the problem.&lt;/p&gt;

&lt;p&gt;you use &lt;code&gt;bisect&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git bisect start      &lt;span class="c"&gt;# Begin the hunt&lt;/span&gt;
git bisect bad        &lt;span class="c"&gt;# Current version is broken&lt;/span&gt;
git bisect good v2.1  &lt;span class="c"&gt;# Last known good version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How the process works
&lt;/h3&gt;

&lt;p&gt;You test the code.&lt;/p&gt;

&lt;p&gt;Then you answer only two things:&lt;/p&gt;

&lt;p&gt;works = git bisect good&lt;br&gt;
broken = git bisect bad&lt;/p&gt;

&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;Git keeps cutting the search space in half.&lt;/p&gt;

&lt;p&gt;Again. And again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this is powerful?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;50 commits becomes&lt;/p&gt;

&lt;p&gt;~6 checks.&lt;/p&gt;

&lt;p&gt;its called the power of &lt;em&gt;&lt;a href="https://git-scm.com/docs/git-bisect" rel="noopener noreferrer"&gt;binary search&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  🔥 Now Finish the Bug Hunting mission
&lt;/h3&gt;

&lt;p&gt;When the bug is found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git bisect reset
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Back to normal.&lt;/p&gt;

&lt;p&gt;Bug identified.&lt;/p&gt;

&lt;p&gt;Target eliminated. ☠️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💡Tips:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can automate the entire hunt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git bisect run npm &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Git runs your tests automatically on each step.&lt;/p&gt;

&lt;p&gt;No manual checking.&lt;/p&gt;

&lt;p&gt;No human error.&lt;/p&gt;

&lt;p&gt;You just sit back and watch it find the culprit like &lt;a href="https://try.quillbot.com/bc5dxz39okqk" rel="noopener noreferrer"&gt;quillbot&lt;/a&gt; ;).&lt;/p&gt;

&lt;p&gt;NOTE: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Bisect&lt;/code&gt; only works if:&lt;/p&gt;

&lt;p&gt;you hAve a known good version&lt;br&gt;
your tests actually work&lt;/p&gt;

&lt;p&gt;If your tests are broken, bisect becomes useless.&lt;/p&gt;


&lt;h2&gt;
  
  
  10) 🧑‍🦯‍➡️ Don’t Merge Blindly
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm7sb1pu43l9jkqmqtgl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm7sb1pu43l9jkqmqtgl.png" alt="Image description 10) Don’t Merge Blindly" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ve got a &lt;code&gt;feature-cat&lt;/code&gt; branch.&lt;/p&gt;

&lt;p&gt;It “works on your machine.”&lt;/p&gt;

&lt;p&gt;Now you’re about to merge into &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And you’re thinking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Should be fine.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That sentence along has destroyed more codebases than bugs ever did.&lt;/p&gt;
&lt;h3&gt;
  
  
  Rule #1) Check What files are changing
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff &lt;span class="nt"&gt;--name-only&lt;/span&gt; main..feature-cat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is your first reality check.&lt;/p&gt;

&lt;p&gt;It shows exactly what will be affected.&lt;/p&gt;
&lt;h3&gt;
  
  
  Rule #2) What actually changed
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff &lt;span class="nt"&gt;--color-words&lt;/span&gt; main..feature-cat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now you see the real story.&lt;/p&gt;

&lt;p&gt;Not “files changed”.&lt;/p&gt;

&lt;p&gt;But what inside those files changed.&lt;/p&gt;

&lt;p&gt;This is where bad merges get exposed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two ways to compare branches:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff main..feature-cat
git diff main...feature-cat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two-dot vs Three-dot:&lt;/p&gt;

&lt;p&gt;-- &lt;code&gt;..&lt;/code&gt;  = direct comparison (simple view)&lt;br&gt;
-- &lt;code&gt;...&lt;/code&gt; =true branch difference (REAL merge view)&lt;/p&gt;

&lt;p&gt;Most people never learn this difference.&lt;/p&gt;

&lt;p&gt;And that’s exactly why they merge wrong.&lt;/p&gt;

&lt;p&gt;Before merge, you don’t ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Will this work?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What exactly am I about to change?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To sum up, know the battlefield before the fight. &lt;/p&gt;

&lt;p&gt;Compare first, merge second. &lt;/p&gt;


&lt;h2&gt;
  
  
  🫳 11) Cherry-Pick (pick ONLY What You Need)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ukqn7hq7ub7n6cibnn5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ukqn7hq7ub7n6cibnn5.png" alt="Image description 11) Cherry-Pick (pick ONLY What You Need)" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes you only need ONE commit from another branch.&lt;/p&gt;

&lt;p&gt;You Merging entire branches for one fix?&lt;/p&gt;

&lt;p&gt;That’s how you import bugs you NEVER asked for. &lt;/p&gt;

&lt;p&gt;lets cherry-pick..&lt;/p&gt;

&lt;p&gt;Real Case scenario:&lt;/p&gt;

&lt;p&gt;Your &lt;code&gt;feature-login&lt;/code&gt; branch has 10 commits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;LoginUI.tsx&lt;/code&gt; redesign ❌&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;authStyles.css&lt;/code&gt; change UI ❌&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;useAuth.ts&lt;/code&gt; refactor ❌&lt;/li&gt;
&lt;li&gt;✅ Fix: token refresh bug (&lt;code&gt;authService.ts&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Production is breaking.&lt;/p&gt;

&lt;p&gt;Users getting logged out every 5 minutes.&lt;/p&gt;

&lt;p&gt;You don’t need UI changes.&lt;br&gt;
You don't need refactor.&lt;/p&gt;

&lt;p&gt;BUT you need that ONE fix: token refresh bug in &lt;code&gt;authService.ts&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  💆 Step 1: Find the exact commit
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log &lt;span class="nt"&gt;--oneline&lt;/span&gt; feature-login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;a1b2c3d fix: refresh token expiry bug &lt;span class="k"&gt;in &lt;/span&gt;authService
f4e5d6c refactor: auth hooks
9a8b7c6 style: login UI update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You take the one that matters: 👉 &lt;code&gt;a1b2c3d&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  🩺 Step 2: Surgical extraction
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout main
git pull
git cherry-pick a1b2c3d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now only this change is applied:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;authService.ts → FIXED
Everything else → untouched
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No UI risk. No side effects.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔨 Step 3: Clean it like a pro
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git cherry-pick &lt;span class="nt"&gt;-e&lt;/span&gt; a1b2c3d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update message:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;fix(auth): resolve token refresh logout issue (hotfix)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now your history makes sense to your team + your CI/CD pipeline&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🙎‍♂️What just happened after that 3 steps workflow??&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;-- Bug reported in production&lt;br&gt;
-- You located the fix commit&lt;br&gt;
-- You shipped ONLY the fix&lt;br&gt;
-- You avoided merging unstable work&lt;/p&gt;

&lt;p&gt;This is how senior SWE teams move fast &lt;strong&gt;without breaking things.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But hey.. this is also where juniors get destroyed&lt;/p&gt;

&lt;p&gt;Cherry-pick can bite you if you have:&lt;/p&gt;

&lt;p&gt;-- Same fix exists in two branches later&lt;br&gt;
-- Merge conflicts when syncing branches&lt;br&gt;
-- Duplicate commits + confusing history&lt;/p&gt;

&lt;p&gt;You didn’t remove the problem.&lt;/p&gt;

&lt;p&gt;You &lt;strong&gt;copied the solution.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Big difference.&lt;/p&gt;
&lt;h3&gt;
  
  
  🧠 So when cherry-pick is the RIGHT move?
&lt;/h3&gt;

&lt;p&gt;Use cherry-pick when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🚨 Production hotfix&lt;/li&gt;
&lt;li&gt;🎯 One isolated commit&lt;/li&gt;
&lt;li&gt;⛔ Full merge is risky&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Avoid when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🌆 You need long-term branch sync&lt;/li&gt;
&lt;li&gt;♾️ You’re patching randomly without plan&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🧱 12) Git Add
&lt;/h2&gt;

&lt;p&gt;If you think &lt;em&gt;git mistakes happen&lt;/em&gt; during commits.&lt;/p&gt;

&lt;p&gt;You're wrong.&lt;/p&gt;

&lt;p&gt;They happen &lt;strong&gt;before that&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;At staging.&lt;/p&gt;

&lt;p&gt;You worked on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;login.js&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;profile.js&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;utils.js&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Only &lt;code&gt;login.js&lt;/code&gt; is ready.&lt;/p&gt;

&lt;p&gt;But only amateurs do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And suddenly:&lt;/p&gt;

&lt;p&gt;/ half-finished code enters history&lt;br&gt;
/ unrelated changes get bundled&lt;br&gt;
/ reviews become useless&lt;br&gt;
/ AI gets confused&lt;br&gt;
/ debugging becomes harder later&lt;/p&gt;

&lt;p&gt;That’s how conflicts starts.&lt;/p&gt;
&lt;h3&gt;
  
  
  🧑‍⚕️Professional workflow
&lt;/h3&gt;

&lt;p&gt;You don’t &lt;code&gt;git add .&lt;/code&gt; everything.&lt;/p&gt;

&lt;p&gt;You &lt;strong&gt;choose what deserves to exist in history.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nt"&gt;-p&lt;/span&gt; login.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Stage only specific parts of a file&lt;br&gt;
👉 Build clean, intentional commits&lt;/p&gt;

&lt;h3&gt;
  
  
  🔍 Preview before committing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Shows what &lt;em&gt;would&lt;/em&gt; be staged&lt;/p&gt;

&lt;h3&gt;
  
  
  ⚠️ Advanced control (use carefully)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nt"&gt;--force&lt;/span&gt; .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Used only when you intentionally need ignored files&lt;br&gt;
👉 Dangerous if you don’t understand why&lt;/p&gt;

&lt;p&gt;Staging is not “pre-commit.”&lt;/p&gt;

&lt;p&gt;It is &lt;strong&gt;decision-making.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You are deciding:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What deserves to become history?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;✍️ NOTE:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Amateurs commit everything and fix later. Professionals stage with intention and never create havoc in the first place.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Conclusion 🏁
&lt;/h2&gt;

&lt;p&gt;Git is not complicated. &lt;/p&gt;

&lt;p&gt;Most of the commands above aren’t even complicated. &lt;/p&gt;

&lt;p&gt;They just force you to slow down at the right moments.&lt;/p&gt;

&lt;p&gt;It becomes messy when you stop paying attention.&lt;/p&gt;

&lt;p&gt;After a while, you stop thinking in commands and start thinking in states:&lt;/p&gt;

&lt;p&gt;what changed, what matters, and what should actually be saved.&lt;/p&gt;

&lt;p&gt;That’s basically it.&lt;/p&gt;

&lt;p&gt;Hope you find this article useful. let me know in the comments section what  you have learned so far. Its great to hear. Cheers 🥂&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📘 Recommendations:&lt;/strong&gt; &lt;strong&gt;&lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Git is a tool. it handles history. &lt;em&gt;Clean Code&lt;/em&gt; handles everything inside that history. Developers don’t fail because of Git. They fail because the code itself becomes way too HARD to manage. If you fix that part early, Git becomes your oblige coworker.&lt;/p&gt;

&lt;p&gt;use code: &lt;code&gt;POWER40&lt;/code&gt; 40% OFF for one week.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;👉 Clean Code Zero to One&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;for those building apps &lt;a href="https://get.brightdata.com/codewithshahan-scraping-browser" rel="noopener noreferrer"&gt;Bright Data&lt;/a&gt; takes care of your data: proxies, scraping, data pipelines, all handled. You build. It runs on your behalf.&lt;/p&gt;




</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>git</category>
      <category>programming</category>
    </item>
    <item>
      <title>10 hard truths EVERY DEV must learn in 2025</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Wed, 09 Apr 2025 17:26:43 +0000</pubDate>
      <link>https://dev.to/codewithshahan/10-hard-truths-every-dev-must-learn-in-2025-26io</link>
      <guid>https://dev.to/codewithshahan/10-hard-truths-every-dev-must-learn-in-2025-26io</guid>
      <description>&lt;p&gt;I've been in the coding game for 5 years.&lt;/p&gt;

&lt;p&gt;Written messy code.&lt;/p&gt;

&lt;p&gt;Struggled with debugging nightmares.&lt;/p&gt;

&lt;p&gt;Made dumb mistakes.&lt;/p&gt;

&lt;p&gt;Learned the hard way.&lt;/p&gt;

&lt;p&gt;Here are the cold, hard lessons I had to learn the hard way (every developer must learn)...&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Looks help but they’re not everything.
&lt;/h2&gt;

&lt;p&gt;I remember when I first started using AI code assistants. I thought once I had them, coding would be effortless.&lt;/p&gt;

&lt;p&gt;They provided suggestions, completed lines... but my projects still had issues. Because I still lacked the understanding of clean code principles. AI tools got me started, but my lack of foundational knowledge closed doors just as fast.&lt;/p&gt;

&lt;p&gt;What I learned is this: AI tools don’t just respond to what you input; they amplify your existing coding habits. A developer who codes with clarity, who structures functions with purpose, who doesn’t rely solely on AI -- that developer will outperform someone who blindly follows AI suggestions every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. If you’re always chasing, you’re not in control.
&lt;/h2&gt;

&lt;p&gt;This one stung. I used to think effort was everything. If I just kept tweaking and adding features, the code would improve. So, I’d refactor endlessly, integrate every new library, follow every trend... and I ended up with bloated, unmanageable codebases.&lt;/p&gt;

&lt;p&gt;Because when you’re doing 90% of the work without a clear direction, you’re not developing; you’re floundering. Real progress is intentional. If a feature truly adds value, it will integrate seamlessly. Stop chasing every new tool or framework that barely fits your project. Start valuing simplicity and purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Your purpose is more attractive than your tools.
&lt;/h2&gt;

&lt;p&gt;I had phases where I’d focus all my energy on mastering the latest coding tools. Everything revolved around having the newest gadgets in my developer toolkit. I’d spend hours customizing my IDE, setting up complex workflows... and I got nowhere.&lt;/p&gt;

&lt;p&gt;But when I locked in on my goals—building meaningful projects, solving real problems—when I was too busy creating to constantly tweak my setup, suddenly my work stood out.&lt;/p&gt;

&lt;p&gt;Clients and peers would say, “You’re different,” “You’re focused,” “You’ve got something going.” That’s when I realized: developers who chase purpose attract recognition without even trying. Because that energy is rare, and people feel it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. I’ve learned to stop coding so much.
&lt;/h2&gt;

&lt;p&gt;Early on, I thought I had to prove myself. I’d over-engineer. Add unnecessary complexity. Implement features no one asked for. It came off as overcompensation and it killed project momentum.&lt;/p&gt;

&lt;p&gt;I started studying minimalism in code, the beauty of simplicity. I realized users notice everything.&lt;/p&gt;

&lt;p&gt;The way an application flows. The intuitiveness of the interface. The speed of execution. A developer who can deliver powerful functionality with clean, simple code is a developer who gets attention. Simplicity is power. Let your code speak for itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Your past code matters.
&lt;/h2&gt;

&lt;p&gt;I worked on projects where I ignored my previous mistakes—spaghetti code, lack of documentation, poor structure — and I told myself, “I’ll do better next time.” I wanted to move forward without addressing the past. I couldn’t. I became trapped in a cycle of repeating errors.&lt;/p&gt;

&lt;p&gt;A developer’s past work is a preview of their future. It doesn’t mean you have to be perfect, but you do need accountability. You need to learn and grow. If all your past projects were chaotic, ask why you approached them that way. If you consistently avoided testing and documentation, ask what that means for your development process.&lt;/p&gt;

&lt;p&gt;Don’t ignore the signs just because you’re eager to move on.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Not every tool is worth your time.
&lt;/h2&gt;

&lt;p&gt;When I was younger, I treated every new framework or library as a must-learn. If it was popular, that was enough. I’d ignore its relevance to my work, its learning curve, its community support—just to have it on my resume. I paid for it every time.&lt;/p&gt;

&lt;p&gt;Now? I care more about effectiveness than trendiness.&lt;/p&gt;

&lt;p&gt;Does this tool solve a problem I have? Does it integrate well with my existing stack? Does it have long-term viability? If it’s just trendy but brings nothing substantial, I pass. My time is valuable. My focus is sacred. And not every tool deserves attention.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. The less you rely, the better things go.
&lt;/h2&gt;

&lt;p&gt;This doesn’t mean rejecting help or tools. It means independence. I used to depend heavily on AI code assistants. Let them dictate my coding style. Follow their suggestions blindly. But when I stopped relying so much—when I focused on understanding, improving, and staying grounded—things shifted.&lt;/p&gt;

&lt;p&gt;My code became cleaner. My problem-solving skills sharpened. And ironically, that’s what made me a better developer. The one who can code without assistance holds the power. Not out of arrogance but out of competence.&lt;/p&gt;

&lt;p&gt;Clean code isn’t optional... it’s your edge. AI can’t fix chaos. If your code is unreadable, your future’s unstable. I learned the hard way. You don’t have to. Grab my book "Clean Code Zero to One" on Gumroad and level up forever:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxls5d3vkg4jgu7oezfn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxls5d3vkg4jgu7oezfn.png" alt="Image of clean code zero to one book by shahan" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📘: &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;https://codewithshahan.gumroad.com/l/cleancode-zero-to-one&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Being a “yes developer” doesn’t work.
&lt;/h2&gt;

&lt;p&gt;I used to think agreeing to every feature request was the way to please clients. I’d say yes to everything, avoid pushing back, always accommodate. It made me overworked.&lt;/p&gt;

&lt;p&gt;Even worse—it made me look unprofessional.&lt;/p&gt;

&lt;p&gt;Clients don’t want a pushover. They want a professional with a backbone. Someone who sets boundaries. Someone who’s accommodating but not afraid to say no. Someone who makes informed decisions.&lt;/p&gt;

&lt;p&gt;Be a good developer but don’t be a submissive one. There’s a difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Comments are cool, but clarity is better.
&lt;/h2&gt;

&lt;p&gt;“// This function calculates the sum.” Blah, blah, blah. Every developer writes that. But the one who names the function calculateSum()... who structures code so its purpose is self-evident... who doesn’t rely on excessive comments to explain convoluted logic—that’s the developer whose code is respected.&lt;/p&gt;

&lt;p&gt;Clarity isn’t verbose. It’s in the structure, the naming, the organization. I stopped trying to explain my code with comments and started writing code that needed no explanation. That’s when my work became exemplary.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Your project should add to your life, not be your life.
&lt;/h2&gt;

&lt;p&gt;I’ve taken on projects where I lost myself. I stopped learning new skills. Stopped networking. Stopped pursuing personal growth. And every time, it ended with regret.&lt;/p&gt;

&lt;p&gt;That's all for today. Hope you learned something new. Feel free to follow me and subscribe to my weekly &lt;a href="https://Horsecoder.beehiiv.com/" rel="noopener noreferrer"&gt;horsecoder newsletter&lt;/a&gt; for the latest updates. &lt;/p&gt;




&lt;p&gt;&lt;em&gt;🏖️ This article is sponsored by &lt;a href="https://fntechsolution.com/" rel="noopener noreferrer"&gt;FN Tech Solution&lt;/a&gt;, where you can find people to do marketing for you: create apps/websites/designs, grow your business, and more.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌱🗃️ More Learning Resources:&lt;/strong&gt;&lt;br&gt;
📘 My Book: &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt;&lt;br&gt;
📹 YouTube: &lt;a href="https://www.youtube.com/programmingwithshahan" rel="noopener noreferrer"&gt;Programming with Shahan&lt;/a&gt;&lt;br&gt;
🩻 𝕏: &lt;a href="https://x.com/shahancd" rel="noopener noreferrer"&gt;shahancd&lt;/a&gt;&lt;br&gt;
🌐 Website: &lt;a href="http://codewithshahan.com/" rel="noopener noreferrer"&gt;codewithshahan.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>ai</category>
    </item>
    <item>
      <title>How to land your first frontend job (11 Rules!)</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Sat, 15 Mar 2025 23:55:40 +0000</pubDate>
      <link>https://dev.to/codewithshahan/11-rules-to-land-your-first-frontend-job-3h53</link>
      <guid>https://dev.to/codewithshahan/11-rules-to-land-your-first-frontend-job-3h53</guid>
      <description>&lt;p&gt;You wanna land your first front-end job in 2025? You think slapping together a few React components and calling yourself a "developer" is enough? News flash: it's not.&lt;/p&gt;

&lt;p&gt;Most of you are out here writing spaghetti code, hoping some company will bless you with a job. Wrong. Employers want weapons—clean, scalable, maintainable code machines. You follow these 11 rules, and you’ll have hiring managers fighting over you. Ignore them? Enjoy your job at McJavaScript's.&lt;/p&gt;

&lt;p&gt;Let’s get into it&lt;/p&gt;

&lt;h2&gt;
  
  
  📽️ 1. Not building projects
&lt;/h2&gt;

&lt;p&gt;If you really want to know how far you have come, create real-world projects. A simple quiz app can be entertaining to start with. &lt;/p&gt;

&lt;p&gt;Make sure to resist the temptation to copy code. Do it from scratch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// A simple quiz app with array-based questions&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;questions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;What does HTML stand for?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;HyperText Markup Language&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;What is the output of 2+2 in JS?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;4&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;startQuiz&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;questions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;q&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userAnswer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userAnswer&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;userAnswer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Your score is: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;questions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;startQuiz&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🍽️ 2. Choose Your Learning Resources Wisely
&lt;/h2&gt;

&lt;p&gt;You want to read every tutorial, watch every video, jump on every trendy platform. That’s a &lt;strong&gt;crime&lt;/strong&gt; in software development. &lt;/p&gt;

&lt;p&gt;Pick &lt;strong&gt;one or two&lt;/strong&gt; solid resources/courses. Stick to them until you grasp critical concepts 100%.&lt;/p&gt;

&lt;p&gt;You are not gonna make it unless you grasp these two principles of learning coding online: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🫗 Jumping around too much = zero progress.
&lt;/li&gt;
&lt;li&gt;🌴 A single consistent source builds a strong mental framework.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🪛 3. Start with the Basics
&lt;/h2&gt;

&lt;p&gt;Most devs want to build an entire e-commerce platform on Day One.&lt;/p&gt;

&lt;p&gt;Don’t. It’s like trying to fight a heavyweight champion before you’ve thrown your first punch.&lt;/p&gt;

&lt;p&gt;Build hundreds of small projects with pure HTML, CSS, and plain JavaScript. &lt;/p&gt;

&lt;p&gt;Then choose a front-end framework like Vue.js, Angular or React.js and stick with it. Master them, and everything else is easier.&lt;/p&gt;




&lt;h2&gt;
  
  
  🐣 4. Begin with Easy Projects
&lt;/h2&gt;

&lt;p&gt;You want to jump into a giant game or a social media clone? &lt;/p&gt;

&lt;p&gt;Resist. Start small. A to-do list, a simple calculator, or a color picker. &lt;/p&gt;

&lt;p&gt;These little wins matter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👇 Easy Project Example (Color Picker):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;colorInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;colorInput&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;colorInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;colorInput&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One input, one background change. Easy. But it cements your knowledge.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚤 5. Take Your Time to Learn
&lt;/h2&gt;

&lt;p&gt;Some of you want to “speedrun” coding. Big mistake. &lt;/p&gt;

&lt;p&gt;This is not a race. &lt;/p&gt;

&lt;p&gt;True mastery comes from &lt;strong&gt;slow, deliberate practice&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Don’t sin by rushing. That only leads to half-baked knowledge.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎐 6. Regular Practice Is Good, But Don’t Overdo It
&lt;/h2&gt;

&lt;p&gt;Coding every day is nice, but if you burn out, you’ll crash in the long run. &lt;/p&gt;

&lt;p&gt;Pace yourself. Show up consistently, but take breaks. That’s how you stay hungry without losing your mind.&lt;/p&gt;




&lt;h2&gt;
  
  
  🥞/🍋 7. Stuck on Something? Take a Break
&lt;/h2&gt;

&lt;p&gt;When your code refuses to work, you might feel the urge to fight it for hours. Sometimes, that’s necessary. &lt;/p&gt;

&lt;p&gt;But other times, walk away. Let your mind breathe. Come back fresh.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔥 Break Trick&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step away from your desk.
&lt;/li&gt;
&lt;li&gt;Drink water or take a short walk.&lt;/li&gt;
&lt;li&gt;Eat delicious food. I personally do push-ups instead.
&lt;/li&gt;
&lt;li&gt;Fight the bug with a brand new fresh mind.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⛷️ 8. Learn by Doing
&lt;/h2&gt;

&lt;p&gt;Reading docs, watching videos—good. But &lt;strong&gt;if you’re not coding&lt;/strong&gt;, you’re lying to yourself. Real skill is built by typing, failing, debugging, and repeating.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💪 Mini-Challenge&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pick a small feature from any website you love.
&lt;/li&gt;
&lt;li&gt;Recreate it from scratch in your own code.&lt;/li&gt;
&lt;li&gt;Push to github (your future self will be surprised)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📜 9. Plan Your Projects
&lt;/h2&gt;

&lt;p&gt;Moving into code without a plan is a sin. &lt;/p&gt;

&lt;p&gt;That’s how you end up with spaghetti code and random errors. Sketch a quick layout. Identify data structures. Then code.&lt;/p&gt;

&lt;p&gt;Let me give an example of planning a Note App prior to writing code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data&lt;/strong&gt;: Where to store notes (array, localStorage?).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Functions&lt;/strong&gt;: &lt;code&gt;addNote()&lt;/code&gt;, &lt;code&gt;deleteNote()&lt;/code&gt;, &lt;code&gt;displayNotes()&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UI&lt;/strong&gt;: Minimal HTML to show notes in a list. &lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🏎️ 10. Focus on Quality, Not Speed
&lt;/h2&gt;

&lt;p&gt;Speed is tempting. “Let me build this in one night!” Then you brag about it. But your code is a big mess. Always breaks, and most often, the entire project collapses. &lt;/p&gt;

&lt;p&gt;That’s the result of short-term glory. &lt;/p&gt;

&lt;p&gt;Real devs write maintainable code. They think about the future. That's why writing clean code matters more than anything in the tech industry. &lt;/p&gt;

&lt;p&gt;The reason most software companies fire these types of devs is clear:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Poor code 🆚 Clean Code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Poor code: Hard-coded, zero flexibility&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calcPrice&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Clean code: Configurable, easy to adapt&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calcPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;basePrice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;taxRate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;basePrice&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;basePrice&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;taxRate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📘 Grab my book, &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt; to master clean coding strategies and join a few who truly can write adaptable, maintainable software. &lt;/p&gt;




&lt;h2&gt;
  
  
  🧘‍♂️ 11. Be Patient with Your Learning
&lt;/h2&gt;

&lt;p&gt;You see others landing big dev jobs. You panic. Stop comparing. Your path is your own. Focus on your front-end path and complete your 6-month or 1-year commitment regardless how you feel.   &lt;/p&gt;

&lt;p&gt;This is how all devs find their first life-changing job. &lt;br&gt;
Consistency is the key. Be patient.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏁. Conclusion
&lt;/h2&gt;

&lt;p&gt;Coding is a journey, not a sprint. &lt;/p&gt;

&lt;p&gt;Don’t let mistakes or slow progress discourage you. &lt;br&gt;
Fight through the struggle. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🛬 The more you resist the temptation to quit, the closer you are to landing your dream job.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Now Go Build Something and build it right.&lt;/strong&gt; &lt;br&gt;
That’s the ONLY way you survive in this game. &lt;/p&gt;

&lt;p&gt;Happy coding and share your thoughts in the comment section. I would love to hear that.&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>javascript</category>
      <category>career</category>
      <category>webdev</category>
    </item>
    <item>
      <title>9 frontend devs mistakes</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Mon, 10 Mar 2025 18:43:06 +0000</pubDate>
      <link>https://dev.to/codewithshahan/9-frontend-mistakes-beginners-often-make-5am6</link>
      <guid>https://dev.to/codewithshahan/9-frontend-mistakes-beginners-often-make-5am6</guid>
      <description>&lt;p&gt;You’re a newbie? Good. &lt;/p&gt;

&lt;p&gt;That means you have nowhere to go BUT UP. &lt;/p&gt;

&lt;p&gt;it can feel overwhelming. That’s natural.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsq0y4isyf9l2zj0t34g5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsq0y4isyf9l2zj0t34g5.png" alt="Image of frontend devs meme trying to keep moving forward illustrated by Shahan Chowdhury" width="800" height="960"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Frontend development is all about &lt;strong&gt;[how well]&lt;/strong&gt; you understand. &lt;/p&gt;

&lt;p&gt;Not how &lt;strong&gt;[fast]&lt;/strong&gt; you learn.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🪜 You either step up and do it right, or you watch your code breaks.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;👉 Let me walk you through the biggest mistakes beginner frontend devs ever make, and &lt;u&gt;how to avoid them&lt;/u&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  1. 🤧 NOT Optimizing Images
&lt;/h2&gt;

&lt;p&gt;Some of you test locally on a blazing-fast machine. &lt;/p&gt;

&lt;p&gt;You forget real users have slower networks. &lt;/p&gt;

&lt;p&gt;Some devs are too lazy to think about their users. &lt;/p&gt;

&lt;p&gt;Let me get it straight: A 6MB image shrunk to 200px is a SIN. &lt;/p&gt;

&lt;p&gt;Optimize your images. Every. Single. Time.&lt;/p&gt;

&lt;p&gt;Some criminal devs try to reduce image file size by using CSS like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* keeps the aspect ratio */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 However, this does not reduce the ACTUAL file size.&lt;/p&gt;

&lt;p&gt;If your image is still 6MB, it will still take a LONG TIME to download CSS just displays it smaller. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;What a [BIG WASTE] of bandwidth. 🚮&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;🪧 So, CSS resizing is mostly for layout, not real optimization.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So what is the solution?&lt;/p&gt;

&lt;p&gt;Well, the first solution I would suggest is to use online image compressor tools. &lt;/p&gt;

&lt;p&gt;I found &lt;a href="https://tinypng.com/" rel="noopener noreferrer"&gt;tinypng&lt;/a&gt; is a great tool for optimizing website images without reducing their quality. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4q0x1w2ivqnxjs258wwe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4q0x1w2ivqnxjs258wwe.png" alt="Image of tiny png online image compressor" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see my photo file size reduced to -75% (4mb to 890kb); that's crazy. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚡ Compressed images = faster load times = happy users.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;⚠️ Warning:&lt;/strong&gt; DO NOT &lt;em&gt;compress&lt;/em&gt; images for &lt;strong&gt;[larger screens]&lt;/strong&gt;. Use HTML &lt;code&gt;srcset&lt;/code&gt; attribute instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;
&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Responsive Images Example&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- 
    The browser will pick the most appropriate image based on 
    the user's device width. 
    - "small.jpg" is for screens up to ~400px wide
    - "medium.jpg" is for screens up to ~800px wide
    - "large.jpg" is for anything bigger

    Each file is physically smaller in size, so smaller devices 
    don't waste bandwidth on huge images.
  --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt;
    &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"images/large.jpg"&lt;/span&gt;
    &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A beautiful scenic view"&lt;/span&gt;
    &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"
      images/small.jpg   400w,
      images/medium.jpg  800w,
      images/large.jpg   1200w
    "&lt;/span&gt;
    &lt;span class="na"&gt;sizes=&lt;/span&gt;&lt;span class="s"&gt;"
      (max-width: 400px)  400px,
      (max-width: 800px)  800px,
      1200px
    "&lt;/span&gt;
  &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🪨🔨 How to Optimize Images Using Node.js?
&lt;/h3&gt;

&lt;p&gt;My second solution would be... use a trustworthy JavaScript library.  &lt;/p&gt;

&lt;p&gt;If you have some experience with Node.js, then here is a popular Node.js library to optimize image without reducing quality: &lt;a href="https://www.npmjs.com/package/sharp" rel="noopener noreferrer"&gt;Sharp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👇 Here’s how to use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sharp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sharp&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;sharp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;large-image.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;// The original, large file&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;// Shrink dimensions&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;jpeg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;quality&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="c1"&gt;// Convert to JPEG with 80% quality&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;optimized-image.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Image optimized successfully!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error optimizing image:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2. 🥸 Using Inline Styles
&lt;/h2&gt;

&lt;p&gt;Let's say you're working on a website that has &lt;strong&gt;[10 job offers]&lt;/strong&gt; listed. You want them to be red to catch the user’s eye.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzysa3dye6rennk6bhph.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzysa3dye6rennk6bhph.gif" alt="gif hard working octopus" width="375" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👇 You took the easy path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Inline style approach --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/job-offer/123"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color: red;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Junior Developer&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/job-offer/456"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color: red;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Frontend Engineer&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/job-offer/789"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color: red;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Backend Specialist&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- ...and so on for all your job offer links --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sure, it works. But &lt;strong&gt;the moment&lt;/strong&gt; your boss says:  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Hey dude, make all those links blue instead. My wife hates red.🥱”  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You’re in TROUBLE. &lt;br&gt;
You’d have to edit &lt;strong&gt;[each]&lt;/strong&gt; inline style to &lt;code&gt;color: blue;&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;If you have 100 links scattered across multiple pages, &lt;br&gt;
that’s a MASSIVE chore. &lt;/p&gt;

&lt;p&gt;That's one of the &lt;strong&gt;[quick-fix traps]&lt;/strong&gt; most devs fall into. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ The CSS-Only Approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s do it the &lt;strong&gt;right way&lt;/strong&gt;. You define a simple class in your CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.link-job-offer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c"&gt;/* maybe other styles, too */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.link-job-offer&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;darkred&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👇 Then, in your HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Class-based approach --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/job-offer/123"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"link-job-offer"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Junior Developer&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/job-offer/456"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"link-job-offer"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Frontend Engineer&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/job-offer/789"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"link-job-offer"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Backend Specialist&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- ...repeat for all job offer links --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;👉 Change one line in &lt;code&gt;.link-job-offer&lt;/code&gt; for a global update. That’s power. &lt;/p&gt;




&lt;h2&gt;
  
  
  3. 🎭 Using Inadequate Heading Tags
&lt;/h2&gt;

&lt;p&gt;Don’t use &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; just because it’s [big and bold]. That’s an SEO sin. &lt;/p&gt;

&lt;p&gt;Headings must reflect hierarchy. If it’s purely decorative, use a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; or a CSS class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Bad --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"font-size: 50px;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Promoted&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- Good --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"promo-text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Promoted&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then style it in your CSS with &lt;code&gt;.promo-text&lt;/code&gt;. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🔥🧯 Don’t sabotage your SEO for a cheap hack.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  4. ❌📲 Ignoring Mobile Media Queries
&lt;/h2&gt;

&lt;p&gt;You tested on desktop? Great. But &lt;strong&gt;[half]&lt;/strong&gt; your users are on mobile. &lt;/p&gt;

&lt;p&gt;If you &lt;em&gt;skip&lt;/em&gt; media queries, you CHEAT half your audience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;It doesn't take much time; you just need to add the following CSS codes:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Mobile first approach */&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;95%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Resist the lazy mindset. Always check your phone or dev tools. Because if it breaks on mobile, you lose. Your users matter most. &lt;/p&gt;




&lt;h2&gt;
  
  
  5. 🪟 Not Benefitting from Flexbox or CSS Grid
&lt;/h2&gt;

&lt;p&gt;It’s 2025. Floats are archaic. Resist your old habits. Use &lt;strong&gt;flex&lt;/strong&gt; or &lt;strong&gt;grid&lt;/strong&gt;. It’s faster, cleaner, simpler.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexbox Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.navbar&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;space-between&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🙅‍♂️ No more float nightmares.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. 🗂️ Not Abstracting Elements
&lt;/h2&gt;

&lt;p&gt;If you find yourself reusing &lt;code&gt;.newsletter__title&lt;/code&gt; all over, that’s a sign of mistakes. Abstract it. Make a &lt;code&gt;.section-title&lt;/code&gt; that you can use anywhere. That’s maintainable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;
&lt;span class="c"&gt;&amp;lt;!-- ❌ Wrong Approach: Using .newsletter__title everywhere --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"newsletter"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"newsletter__title"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Subscribe to Our Newsletter&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"blog"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"newsletter__title"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Latest Blog Posts&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Wrong! --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"events"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"newsletter__title"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Upcoming Events&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Wrong! --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;



&lt;span class="c"&gt;&amp;lt;!-- ✅ Correct Approach: Abstracting with .section-title --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"newsletter"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"section-title"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Subscribe to Our Newsletter&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- and so on... --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  7. 🧹 NOT Removing Redundant Styles
&lt;/h2&gt;

&lt;p&gt;Some of you love to add &lt;code&gt;display: block&lt;/code&gt; and &lt;code&gt;float: right&lt;/code&gt; in the same rule. Or &lt;code&gt;width: 100%&lt;/code&gt; on a block element. &lt;/p&gt;

&lt;p&gt;That’s dead code. Clean it up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrong:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.foo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Right:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.foo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* automatically block */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🤏 Less is more.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. 🏯 Uppercasing Things in HTML
&lt;/h2&gt;

&lt;p&gt;Typing &lt;code&gt;&amp;lt;h2&amp;gt;JOB OFFERS&amp;lt;/h2&amp;gt;&lt;/code&gt; is the easy route. &lt;/p&gt;

&lt;p&gt;But that’s a sin against separation of concerns. Use CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"section-title"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Job Offers&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.section-title&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text-transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;uppercase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Done. Now, your text is uppercase only in presentation.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. 💎 NOT Focusing on QUALITY
&lt;/h2&gt;

&lt;p&gt;Speed is tempting. “Let me build this in one night!” Then you brag about it. But your code is a mess. Most often, the entire project collapses. &lt;/p&gt;

&lt;p&gt;That’s the sin of short-term glory. &lt;/p&gt;

&lt;p&gt;Real devs write maintainable code. They think about the future. &lt;/p&gt;

&lt;p&gt;That's why writing clean code matters most in the tech industry. Grab my book &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt; to master this skill and join a few who truly understand everything about clean code. &lt;/p&gt;

&lt;p&gt;The reason most software companies fire these types of devs is clear:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Poor code 🆚 Clean Code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Poor code: Hard-coded, zero flexibility&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calcPrice&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;tax&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Clean code: Configurable, easy to adapt&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calcPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;basePrice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;taxRate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;basePrice&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;basePrice&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;taxRate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🏁. Conclusion
&lt;/h2&gt;

&lt;p&gt;Frontend dev is a journey, not a sprint. Mistakes happen. That doesn't mean you SHOULD NOT look into them and struggle later. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🥊 Fight through the struggle NOW before it puts you in a painful punishment.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Happy coding and share your thoughts in the comment section. I would love to hear that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌱🗃️ More Learning Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📘 My Book: &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🌐 Website: &lt;a href="https://codewithshahan.com/" rel="noopener noreferrer"&gt;codewithshahan.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🩻 𝕏: &lt;a href="https://x.com/shahancd" rel="noopener noreferrer"&gt;shahancd&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>frontend</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>css</category>
    </item>
    <item>
      <title>Which JavaScript framework is best (React or Vue in 2025?)</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Thu, 20 Feb 2025 13:34:41 +0000</pubDate>
      <link>https://dev.to/codewithshahan/which-javascript-framework-is-best-react-or-vue-1iaj</link>
      <guid>https://dev.to/codewithshahan/which-javascript-framework-is-best-react-or-vue-1iaj</guid>
      <description>&lt;p&gt;&lt;strong&gt;React vs. Vue.js in 2025, Which One Should You Choose?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React remains one of the most popular JavaScript libraries for building single-page applications in 2025. Meanwhile, Vue.js continues to call itself a “progressive framework” and its popularity skyrocketing day by day. Both share more in common than, say... Angular, which is often considered a “true” framework.&lt;/p&gt;

&lt;p&gt;In this article, I will walk you through a detailed comparison between React.js and Vue.js, updated with the &lt;strong&gt;latest 2025 trends&lt;/strong&gt;, so you can decide which library or framework is best for your next project.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚖️ Framework Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbqn3nz8cpoklyt26e70.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbqn3nz8cpoklyt26e70.png" alt="Image of JS framework overview by @codewithshahan" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React&lt;/strong&gt; was created by &lt;a href="https://twitter.com/jordwalke?lang=en" rel="noopener noreferrer"&gt;Jordan Walke&lt;/a&gt;, a software engineer at Facebook (now Meta). It’s maintained by Meta and a large community of individual developers and companies. In 2025, React’s ecosystem is richer than ever, making it a top choice for &lt;strong&gt;building complex user interfaces&lt;/strong&gt; and handling data processing tasks.&lt;/p&gt;

&lt;p&gt;Furthermore, &lt;a href="https://reactnative.dev/" rel="noopener noreferrer"&gt;React Native&lt;/a&gt; remains a popular extension of React.js, allowing developers to create hybrid mobile applications using the same skill set.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vue.js&lt;/strong&gt;, on the other hand, was created by &lt;a href="https://twitter.com/youyuxi" rel="noopener noreferrer"&gt;Evan You&lt;/a&gt; after he worked on several Google projects using AngularJS. Vue focuses on simplicity and efficiency in UI design and development. By 2025, its intuitive syntax and built-in features (like transitions and official state management via &lt;a href="https://pinia.vuejs.org/" rel="noopener noreferrer"&gt;Pinia&lt;/a&gt;) have continued to attract developers seeking a &lt;strong&gt;straightforward&lt;/strong&gt; framework for building interfaces.&lt;/p&gt;




&lt;h2&gt;
  
  
  🍏 Reasons for Using Vue.js
&lt;/h2&gt;

&lt;p&gt;Vue.js has maintained its reputation for simplicity. Developers appreciate its &lt;strong&gt;clear and logical design&lt;/strong&gt;, which speeds up development workflows. Unlike some other frameworks, Vue.js retains a consistent syntax throughout UI functionality. That's why I love it personally. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Efficient Official Plugins&lt;/strong&gt;: Vue’s core team provides well-structured solutions for common tasks like routing and state management.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Corporate Ownership&lt;/strong&gt;: As of 2025, Vue remains community-driven and independent, appealing to developers wary of data exploitation by large tech companies.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Great Ecosystem&lt;/strong&gt;: Plugins like &lt;a href="https://router.vuejs.org/" rel="noopener noreferrer"&gt;Vue Router&lt;/a&gt; and &lt;a href="https://pinia.vuejs.org/" rel="noopener noreferrer"&gt;Pinia&lt;/a&gt; cover most app needs out of the box.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F93sfo44ncmwrkyijv72v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F93sfo44ncmwrkyijv72v.png" alt="Image of vue.js security by @codewithshahan" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚛️ Reasons for Using React
&lt;/h2&gt;

&lt;p&gt;React.js brings unique features that keep it at the top of many developers’ lists (even though its popularity has been declining over time).&lt;/p&gt;

&lt;p&gt;Here is why it is still popular nowadays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;JSX Syntax&lt;/strong&gt;: JSX (JavaScript XML) makes creating custom components more intuitive. You can write HTML-like code within JavaScript, streamlining component creation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SEO Support&lt;/strong&gt;: React.js applications are relatively easy to optimize for search engines, especially when combined with frameworks like Next.js.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React Native&lt;/strong&gt;: Developers can reuse their React.js knowledge to build native mobile apps for iOS and Android.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React Dev Tools&lt;/strong&gt;: In 2025, the React Developer Tools are more handy than ever, offering deep insights for debugging and organizing complex apps.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdk077iev1xamzvmdujl5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdk077iev1xamzvmdujl5.png" alt="Image of react.js search engine support" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🥇 Comparison of Popularity and Performance
&lt;/h2&gt;

&lt;p&gt;Both React.js and Vue.js remain in high demand in 2025. React has a slight edge in terms of overall popularity, backed by its &lt;strong&gt;extensive ecosystem&lt;/strong&gt; and the community around React Native. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftls7u832ycedn4bw5lkn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftls7u832ycedn4bw5lkn.png" alt="Image of react or vue popularity" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Performance&lt;/strong&gt;: Both use a virtual DOM for efficient rendering. Vue.js often shines in component creation and updates due to its super fast optimizations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage Stats&lt;/strong&gt;: According to a 2025 developer survey, over 45% of respondents have used React.js for web development, while around 20% have used Vue.js.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;a href="https://www.appsdevpro.com/blog/vue-vs-react/#:~:text=The%20Statista%20survey%20report%20reveals,for%20web%20development." rel="noopener noreferrer"&gt;The Statista survey report&lt;/a&gt; from previous years still shows React leading in global adoption, though Vue continues to grow steadily.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧊 Scalability
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;React.js&lt;/strong&gt; has the idea of “smart” and “dumb” components to manage complex architectures. Smart components handle data-heavy tasks, while dumb components focus on rendering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vue.js&lt;/strong&gt; offers official libraries like &lt;a href="https://blog.logrocket.com/complex-vue-3-state-management-pinia/" rel="noopener noreferrer"&gt;Pinia&lt;/a&gt; for state management, enabling developers to handle larger applications. By 2025, Vue 3+ has proven its ability to scale effectively in enterprise projects.&lt;/p&gt;




&lt;h2&gt;
  
  
  📲 Adjust to Mobile Devices
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffsuvbnikg0qsbrf33vdf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffsuvbnikg0qsbrf33vdf.png" alt="Image of react or vue for mobile application development" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both frameworks have a growing demand for cross-platform solutions, although Vue.js is becoming more popular day by day. Let's have a brief overview:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;React Native&lt;/strong&gt;: An established leader for building native iOS and Android apps with React.js.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Weex (Vue)&lt;/strong&gt;: A mobile UI framework by Alibaba Group, allowing Vue.js components to run on mobile. While not as widespread as React Native, Weex provides a solid Vue-based mobile solution.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚎🔩 Size and Community Support
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bundle Size&lt;/strong&gt;: Vue.js typically ships with a smaller bundle size, making it ideal for projects prioritizing fast load times.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community&lt;/strong&gt;: React benefits from Meta’s backing and a massive open-source ecosystem. Vue.js, though smaller, boasts an active and dedicated community with thorough documentation and ongoing improvements. I think it's becoming more popular than React.js as recent data suggests. &lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🏒 Use Cases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;React.js&lt;/strong&gt;: Perfect for complex web apps, large-scale projects, and teams needing to pivot between web and mobile with React Native.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vue.js&lt;/strong&gt;: Ideal for small to medium-sized apps, real-time platforms, and content delivery systems where simplicity and performance are key.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🏇 Recommendation: Clean Code Book (2025)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9kfe6mtlt9ttq55da82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9kfe6mtlt9ttq55da82.png" alt="Image of clean code zero to one book" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re serious about mastering clean code and taking your programming career to the next level, then my book for you: &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt;. I am offering 50% discount using the code "earlybird" during checkout — only for the first 50 copies! Plus, enjoy a 30-day money-back guarantee — no risk, all reward.&lt;/p&gt;




&lt;h2&gt;
  
  
  👏 Conclusion
&lt;/h2&gt;

&lt;p&gt;I would say React.js is the first choice for developing large and complex apps. Also React Native for mobile apps is a huge plus. But you have to write separate code for web and mobile apps which is a huge downside as well. Therefore, plus-minus = zero. &lt;/p&gt;

&lt;p&gt;Vue.js, meanwhile, is loved for its simplicity, fast performance, and smaller default size. It’s a more lightweight framework without sacrificing modern features. The great news is, you don't have to write separate code for web or mobile. Write once and now you can build desktop, mobile, or web apps in one go. So no downside. Only plus plus. &lt;/p&gt;

&lt;p&gt;I would choose Vue.js for its simplicity and super fast performance.&lt;/p&gt;

&lt;p&gt;Thank you for your time. For more regular posts visit: &lt;a href="http://codewithshahan.com" rel="noopener noreferrer"&gt;codewithshahan.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you enjoyed this, check out my &lt;a href="https://twitter.com/shahancd" rel="noopener noreferrer"&gt;𝕏 (Twitter)&lt;/a&gt; account for more frontend development insights.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Related Articles:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://dev.to/codewithshahan/clean-code-zero-to-one-4ihk"&gt;Clean Code Zero to One&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/codewithshahan/lets-practice-clean-reusable-components-in-react-5flj"&gt;Writing Clean, Reusable React Components (Best Practices)&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>vue</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Code Optimization for Game Development</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Sun, 16 Feb 2025 05:46:59 +0000</pubDate>
      <link>https://dev.to/codewithshahan/code-optimization-strategies-for-game-development-2n0e</link>
      <guid>https://dev.to/codewithshahan/code-optimization-strategies-for-game-development-2n0e</guid>
      <description>&lt;p&gt;Game development is a battlefield. Either you optimize, or you lose.&lt;/p&gt;

&lt;p&gt;I don’t care if you’re an experienced developer with 10 years of experience or 1 year of experience. If you want to make games that WORK, games people respect—you need to understand &lt;strong&gt;optimization&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Players demand smooth gameplay, high-quality visuals, and a flawless experience across every device. If your game stutters, crashes, or loads slower than a snail? You’re done. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqqz1mqa652edg126c1c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqqz1mqa652edg126c1c.png" alt="Image of slow game development meme" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Optimization isn’t magic. It’s the foundation of smooth gameplay, fast loading, and stable performance. Without it, your game will lag, crash, and be forgotten faster than you can say “game over.”  &lt;/p&gt;

&lt;p&gt;But don’t worry. In this article, I will share four effective strategies to help you with that. &lt;/p&gt;

&lt;h2&gt;
  
  
  Effective Strategies for Performance Optimization
&lt;/h2&gt;

&lt;p&gt;🤸‍♂️ What Is Optimization? Optimization means making your game run as fast and smooth as possible. SIMPLE.&lt;/p&gt;

&lt;p&gt;When you optimize your game, you:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;🤏 Reduce loading times.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🖥️ Make the game work on weaker computers or phones.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;💉 Prevent lag and crashes.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Rule 1: Memory Management&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;When you’re developing a game, memory is your most valuable resource.&lt;/p&gt;

&lt;p&gt;Every player movement, every enemy on the screen, every explosion needs a little piece of memory to function. Unfortunately, &lt;strong&gt;memory isn’t unlimited.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you don’t manage memory properly, your game can get slow, laggy, or even crash. That’s why memory management is a critical skill every game developer needs. Let’s break it down step by step, with detailed examples in Python.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Strategy #1: Memory Pooling&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This strategy is simple: reuse Objects Instead of Creating New Ones** Memory pooling is like recycling for your game. Instead of creating new objects every time you need one, you reuse objects you’ve already created.  &lt;/p&gt;

&lt;p&gt;Creating and destroying objects repeatedly takes up time and memory. Let's say you are building a shooting game where the player fires 10 bullets per second. If you create a new bullet for each shot, your game could quickly slow down.  &lt;/p&gt;

&lt;p&gt;Here’s how you can implement memory pooling for bullets in a shooting game:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Bullet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;  &lt;span class="c1"&gt;# Bullet starts as inactive
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;shoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;  &lt;span class="c1"&gt;# Activate the bullet
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bullet fired at position (&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;)!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;  &lt;span class="c1"&gt;# Deactivate the bullet so it can be reused
&lt;/span&gt;
&lt;span class="c1"&gt;# Create a pool of 10 bullets
&lt;/span&gt;&lt;span class="n"&gt;bullet_pool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Bullet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fire_bullet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Look for an inactive bullet in the pool
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;bullet&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;bullet_pool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;bullet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;bullet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Reuse the inactive bullet
&lt;/span&gt;            &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No bullets available!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# All bullets are in use
&lt;/span&gt;
&lt;span class="c1"&gt;# Example usage
&lt;/span&gt;&lt;span class="nf"&gt;fire_bullet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Fires a bullet at position (10, 20)
&lt;/span&gt;&lt;span class="nf"&gt;fire_bullet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Fires another bullet at position (30, 40)
&lt;/span&gt;&lt;span class="n"&gt;bullet_pool&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Reset the first bullet
&lt;/span&gt;&lt;span class="nf"&gt;fire_bullet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Reuses the reset bullet
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🍵 Explanation: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;Bullet&lt;/code&gt; Class: Defines what a bullet does and keeps track of whether it’s active (in use) or not.
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;bullet_pool&lt;/code&gt;: A list of 10 reusable bullets.
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;fire_bullet&lt;/code&gt; Function: Finds an inactive bullet, reuses it, and sets its position.
&lt;/li&gt;
&lt;li&gt;Recycling Bullets: When you’re done with a bullet, you reset it so it can be reused.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Strategy #2. Data Structure Optimization&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The way you store your data can make or break your game’s performance. Choosing the wrong data structure is like trying to carry water in a leaky bucket—it’s inefficient and messy.  &lt;/p&gt;

&lt;p&gt;Let’s say you’re making a game for four players, and you want to keep track of their scores. You could use a list, but a fixed-size array is more efficient because it uses less memory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;

&lt;span class="c1"&gt;# Create a fixed-size array to store player scores
&lt;/span&gt;&lt;span class="n"&gt;player_scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;i&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;  &lt;span class="c1"&gt;# 'i' means integers
&lt;/span&gt;
&lt;span class="c1"&gt;# Update scores
&lt;/span&gt;&lt;span class="n"&gt;player_scores&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;  &lt;span class="c1"&gt;# Player 1 scores 10 points
&lt;/span&gt;&lt;span class="n"&gt;player_scores&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;  &lt;span class="c1"&gt;# Player 3 scores 15 points
&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;player_scores&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Output: array('i', [10, 0, 15, 0])
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🍵 Explanation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;array&lt;/code&gt; Module:&lt;/strong&gt; Creates a fixed-size array of integers (&lt;code&gt;'i'&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixed Size:&lt;/strong&gt; You can’t accidentally add or remove elements, which prevents bugs and saves memory.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficient Updates:&lt;/strong&gt; Updating scores is quick and uses minimal resources.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Strategy #3. Memory Profiling&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Even if your code seems perfect, hidden memory problems can still exist. Memory profiling helps you monitor how much memory your game is using and find issues like memory leaks.  &lt;/p&gt;

&lt;p&gt;Python has a built-in tool called &lt;code&gt;tracemalloc&lt;/code&gt; that tracks memory usage. Here’s how to use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tracemalloc&lt;/span&gt;

&lt;span class="c1"&gt;# Start tracking memory
&lt;/span&gt;&lt;span class="n"&gt;tracemalloc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Simulate memory usage
&lt;/span&gt;&lt;span class="n"&gt;large_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;  &lt;span class="c1"&gt;# A list of squares
&lt;/span&gt;
&lt;span class="c1"&gt;# Check memory usage
&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;peak&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tracemalloc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_traced_memory&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Current memory usage: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; MB&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Peak memory usage: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;peak&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; MB&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Stop tracking memory
&lt;/span&gt;&lt;span class="n"&gt;tracemalloc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🍵 Explanation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start Tracking:&lt;/strong&gt; &lt;code&gt;tracemalloc.start()&lt;/code&gt; begins monitoring memory usage.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trigger Memory Use:&lt;/strong&gt; Create a large list to use up memory.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check Usage:&lt;/strong&gt; Get the current and peak memory usage, converting it to megabytes for readability.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stop Tracking:&lt;/strong&gt; &lt;code&gt;tracemalloc.stop()&lt;/code&gt; ends the tracking session.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now it’s your turn to practice these strategies and take your game development skills to the next level!&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Rule 2: Asset Streaming (Load Only What You Need)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you load the entire world at once, your game will choke and die. You don’t need that drama. Instead, &lt;strong&gt;stream assets as the player needs them&lt;/strong&gt;. This is called asset streaming. &lt;/p&gt;

&lt;p&gt;For instance, inside your game, you may have a huge open-world with forests, deserts, and cities. Why load all those levels at once when the player is only in the forest? Makes no sense, right? Load &lt;strong&gt;only what’s needed&lt;/strong&gt; and keep your game lean, fast, and smooth.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Strategy #1: Segment and Prioritize&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let’s break this down with an example. Your player is exploring different levels: Forest, Desert, and City. We’ll only load a level when the player enters it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here’s how to make it work in Python:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loaded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;  &lt;span class="c1"&gt;# Starts as unloaded
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loaded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Loading level: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loaded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;  &lt;span class="c1"&gt;# Mark the level as loaded
&lt;/span&gt;
&lt;span class="c1"&gt;# Create levels
&lt;/span&gt;&lt;span class="n"&gt;levels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Forest&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Desert&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;City&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;enter_level&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;level_name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;levels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;level_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Load the level if it hasn’t been loaded yet
&lt;/span&gt;            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Entered &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;level_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Level not found!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Handle invalid level names
&lt;/span&gt;
&lt;span class="c1"&gt;# Simulate entering levels
&lt;/span&gt;&lt;span class="nf"&gt;enter_level&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Forest&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Loads and enters the forest
&lt;/span&gt;&lt;span class="nf"&gt;enter_level&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;City&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# Loads and enters the city
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚡Explanation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Levels Class:&lt;/strong&gt; Each level has a name (e.g., Forest) and a “loaded” status. If it’s loaded, it doesn’t load again.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Loading:&lt;/strong&gt; The &lt;code&gt;enter_level&lt;/code&gt; function finds the level the player wants to enter and loads it only if it hasn’t been loaded yet.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency:&lt;/strong&gt; Levels not visited don’t waste memory. The game runs smoothly because it only focuses on what the player needs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is efficiency at its finest. &lt;strong&gt;No wasted memory, no wasted time.&lt;/strong&gt; Your player moves; your game adapts. That’s how you dominate.  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Strategy #2: Asynchronous Loading (No Waiting Allowed)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Nobody likes waiting. Freezing screens? Laggy loading? It’s amateur hour. You need &lt;strong&gt;asynchronous loading&lt;/strong&gt;—this loads assets in the background while your player keeps playing.  &lt;/p&gt;

&lt;p&gt;Imagine downloading a huge map while still exploring the current one. Your game keeps moving, the player stays happy.&lt;/p&gt;

&lt;p&gt;Here’s how to simulate asynchronous loading in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AssetLoader&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;asset_name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;asset_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;asset_name&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loaded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Starting to load &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;asset_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Simulates loading time
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loaded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;asset_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; loaded!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;async_load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;asset_name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AssetLoader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;asset_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Load in a separate thread
&lt;/span&gt;
&lt;span class="c1"&gt;# Simulate async loading
&lt;/span&gt;&lt;span class="nf"&gt;async_load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Forest Map&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Player is still exploring...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Wait for loading to finish
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🍵 Demonstration:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Separate Threads:&lt;/strong&gt; The &lt;code&gt;threading&lt;/code&gt; module creates a new thread to load assets without freezing the main game.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simulated Delay:&lt;/strong&gt; The &lt;code&gt;time.sleep&lt;/code&gt; function fakes the loading time to mimic how it works in a real game.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smooth Gameplay:&lt;/strong&gt; The player can continue playing while the new level or asset loads in the background.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With asynchronous loading, &lt;strong&gt;your player stays in the zone&lt;/strong&gt;, and your game feels seamless. Pro-level stuff.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Strategy 3: Level of Detail (LOD) Systems – Be Smart About Quality&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Not everything in your game needs to look like it’s been rendered by a Hollywood studio. If an object is far away, lower its quality. It’s called &lt;strong&gt;Level of Detail (LOD)&lt;/strong&gt;, and it’s how you keep your game’s performance sharp.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Using LOD for a Tree&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s a Python simulation of switching between high and low detail:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Tree&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;distance&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distance&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Close-up
&lt;/span&gt;            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rendering high-detail tree!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# Far away
&lt;/span&gt;            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rendering low-detail tree.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Simulate different distances
&lt;/span&gt;&lt;span class="n"&gt;close_tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Tree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;far_tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Tree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;distance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;close_tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# High detail
&lt;/span&gt;&lt;span class="n"&gt;far_tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;    &lt;span class="c1"&gt;# Low detail
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🍵 Explanation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Distance Matters:&lt;/strong&gt; The &lt;code&gt;distance&lt;/code&gt; property determines how far the tree is from the player.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High vs. Low Detail:&lt;/strong&gt; If the tree is close, render it in high detail. If it’s far, use low detail to save memory and processing power.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimized Performance:&lt;/strong&gt; The player doesn’t notice the difference, but your game runs smoother and faster.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is how you keep the balance between beauty and performance. Your game looks stunning up close but doesn’t waste resources on faraway objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  🧳To Summarize
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency Wins:&lt;/strong&gt; Only load what you need, when you need it. No wasted memory.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Player Satisfaction:&lt;/strong&gt; Smooth gameplay keeps players engaged and avoids frustration.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Professional Quality:&lt;/strong&gt; These techniques are how AAA games stay fast and responsive.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;🫵 Your move now:&lt;/strong&gt; Go apply these strategies, keep your game lean, and make sure your players never even think about lag.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Rule 3: Frame Rate Stabilization&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The frame rate is how many pictures (frames) your game shows per second. If it’s unstable, your game will stutter and feel broken.  &lt;/p&gt;

&lt;p&gt;The secret? Keep the workload for each frame consistent.  &lt;/p&gt;

&lt;p&gt;🚦Here’s how you can control the timing in a game loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;game_loop&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;fixed_time_step&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.016&lt;/span&gt;  &lt;span class="c1"&gt;# 16 milliseconds = 60 frames per second
&lt;/span&gt;    &lt;span class="n"&gt;last_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;current_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;elapsed_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_time&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;last_time&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;elapsed_time&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;fixed_time_step&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# Update game logic
&lt;/span&gt;            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Updating game...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;last_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_time&lt;/span&gt;

&lt;span class="c1"&gt;# Run the game loop
&lt;/span&gt;&lt;span class="nf"&gt;game_loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;⚖️ The game updates at a steady rate (60 times per second).
&lt;/li&gt;
&lt;li&gt;🪂 This make smooth gameplay, no matter how slow or fast the computer is.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🎯Techniques to EXCEL:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Optimize Rendering Paths: Fewer draw calls. Smarter culling. Simplicity wins.&lt;/li&gt;
&lt;li&gt;Dynamic Resolution Scaling: When the pressure’s on, scale down resolution to maintain the frame rate. Players won’t even notice.&lt;/li&gt;
&lt;li&gt;Fixed Time Step: Keep your physics and logic consistent. Frame rate fluctuations shouldn’t mean chaos.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Rule 4: GPU and CPU Optimization&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Your computer has two main processors:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;CPU:&lt;/strong&gt; Handles logic, like moving a character or calculating scores.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GPU:&lt;/strong&gt; Handles graphics, like drawing your game world.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;👇 Here's what you have to do for GPU/CPU optimization:&lt;/p&gt;

&lt;p&gt;Profile Everything: Use tools to pinpoint bottlenecks and strike hard where it hurts.&lt;br&gt;
Shader Optimization: Shaders are resource hogs. Simplify them, streamline them, and cut the fat.&lt;br&gt;
Multithreading: Spread tasks across CPU cores. Don’t overload one and leave the others idle.&lt;/p&gt;

&lt;p&gt;If one is working too hard while the other is idle, your game will lag.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution? Multithreading.&lt;/strong&gt;&lt;br&gt;
Let’s split tasks between two threads:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update_game_logic&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Updating game logic...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;render_graphics&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Rendering graphics...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Run tasks on separate threads
&lt;/span&gt;&lt;span class="n"&gt;logic_thread&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;update_game_logic&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;graphics_thread&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;render_graphics&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;logic_thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;graphics_thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;🎰 One thread handles logic.
&lt;/li&gt;
&lt;li&gt;🛣️ Another thread handles graphics.
&lt;/li&gt;
&lt;li&gt;⚖️ This balances the workload and prevents bottlenecks.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;👏 Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Optimization isn’t just for “smart” people. It’s simple if you take it step by step:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Manage memory like a pro.&lt;/strong&gt; Don’t waste it.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stream assets.&lt;/strong&gt; Load only what you need.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the frame rate stable.&lt;/strong&gt; No stuttering.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Balance the workload.&lt;/strong&gt; Use the CPU and GPU wisely.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Start optimizing NOW. Your future self will thank you.  &lt;/p&gt;

&lt;p&gt;Visit my website &lt;a href="http://codewithshahan.com/" rel="noopener noreferrer"&gt;codewithshahan &lt;/a&gt; to grab my book "Clean Code Zero to One" to improve your game optimization skills. &lt;/p&gt;

&lt;p&gt;Read more: &lt;a href="https://dev.to/codewithshahan/clean-code-zero-to-one-4ihk"&gt;Clean Code Zero to One&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>python</category>
      <category>cleancode</category>
      <category>performance</category>
    </item>
    <item>
      <title>How to Write Better Code for Agile Software Development (Handbook)</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Thu, 06 Feb 2025 14:10:12 +0000</pubDate>
      <link>https://dev.to/codewithshahan/how-to-write-better-code-for-agile-software-development-handbook-417k</link>
      <guid>https://dev.to/codewithshahan/how-to-write-better-code-for-agile-software-development-handbook-417k</guid>
      <description>&lt;p&gt;Building scalable software applications requires writing clean code that’s so simple that any dev can understand it.&lt;/p&gt;

&lt;p&gt;In this article, I’ll explain and demonstrate what clean code is. Then I’ll share my favorite clean code patterns for building modern Agile applications.&lt;/p&gt;

&lt;p&gt;I won’t use complex jargon. I’ll hit you with simple, clear JavaScript examples that focus on the core concepts. Straight to the point, no nonsense – that’s how I roll.&lt;/p&gt;

&lt;p&gt;Let’s get started.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxh3j6ccn1hc3euc3lfyl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxh3j6ccn1hc3euc3lfyl.png" alt="Image of agile software development meme" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Agile, where change is the only constant, clean code is your armor. It makes you adaptable, swift, and, most importantly, in control.&lt;/p&gt;

&lt;p&gt;Here’s the truth: writing clean code is not optional if you want to survive in the software development industry. Fortunately, we human beings are able to master clean code with some effort and practice. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Cost of Bad Code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdai6npb55j71sguj6kl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdai6npb55j71sguj6kl.png" alt="Image of cost of messy code vs clean code graph by shahan" width="500" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To explain this stack bar graph, in the initial development phase, bad code is &lt;strong&gt;slightly&lt;/strong&gt; more costly to change than clean code.&lt;/p&gt;

&lt;p&gt;But as we move into the maintenance and refactoring phases, the gap widens significantly, with bad code costing nearly twice as much as clean code.&lt;/p&gt;

&lt;p&gt;By the legacy phase, bad code reaches 100% cost – now it’s extremely expensive to update, while clean code remains more manageable at 45%.&lt;/p&gt;

&lt;p&gt;As of now, the most recent analysis on the cost of poor software quality in the U.S. is the 2022 report by the Consortium for Information and Software Quality (&lt;a href="http://cisq.org" rel="noopener noreferrer"&gt;cisq.org&lt;/a&gt;). This report estimates that poor software quality cost the U.S. economy at least $2.41 trillion in 2022, with technical debt accounting for about $1.52 trillion of this amount.&lt;/p&gt;

&lt;p&gt;You can &lt;a href="https://www.it-cisq.org/the-cost-of-poor-quality-software-in-the-us-a-2022-report/" rel="noopener noreferrer"&gt;read more about that here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Recent discussions continue to highlight the significant impact of technical debt on software quality and business performance.&lt;/p&gt;

&lt;p&gt;For instance, &lt;a href="https://vfunction.com/blog/how-to-manage-technical-debt" rel="noopener noreferrer"&gt;a 2024 survey&lt;/a&gt; indicated that for more than 50% of companies, technical debt accounts for greater than a quarter of their total IT budget. And this can really hinder innovation if it’s not addressed.&lt;/p&gt;

&lt;p&gt;As you can see, there’s no doubt that bad code is a costly problem in software development.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Clean Coder vs. Messy Coder&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here’s a graph that shows the journey of &lt;strong&gt;two types&lt;/strong&gt; of coders:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6ubf77uwipf4gtucw8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6ubf77uwipf4gtucw8q.png" alt="Image of clean code vs bad code graph chart" width="604" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;⚠️ The Messy Coder (Red line):&lt;/strong&gt; Starts fast but crashes hard. The more lines they write, the more trouble they make.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;⚡ The Clean Coder (Blue line):&lt;/strong&gt; Starts slow but stays consistent. Growth doesn’t stop — it accelerates. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🫵 Now, you decide which line you want to follow. &lt;/p&gt;

&lt;p&gt;AI Can’t Save You If Your Code is a Mess 🗑️&lt;/p&gt;

&lt;p&gt;When you get stuck writing code, you might turn to AI. But let me tell you something: AI can’t save you if your code is a mess. &lt;/p&gt;

&lt;p&gt;It’s like building a house on sand. Sure, it stands for a while, but one strong gust of wind or big wave, and it collapses.&lt;/p&gt;

&lt;p&gt;Remember: AI is just a tool. If you don’t know how to write clean, scalable applications, you're setting yourself up for failure. &lt;/p&gt;

&lt;p&gt;If you can’t maintain the code you write, you’re in trouble. &lt;/p&gt;

&lt;p&gt;I’ve seen it over and over again: developers who know five programming languages. They can build apps, websites, software. They know algorithms and data structures like the back of their hand.&lt;/p&gt;

&lt;p&gt;But when faced with a large project or someone else’s messy code, they crumble.&lt;/p&gt;

&lt;p&gt;They’re like an aerospace engineer who designs and builds their own planes but doesn’t know how to fly them. They crash into their own code.&lt;/p&gt;

&lt;p&gt;This was me...once upon a time. I’d write thousands of lines of code, only to realize I couldn’t even understand what I wrote last week. It was chaos for me.&lt;/p&gt;

&lt;p&gt;But then it hit me — every developer struggles with this. It wasn't about how much I knew. It was about how I organized and structured what I knew. In other words, it was about knowing the art of programming itself.&lt;/p&gt;

&lt;p&gt;I decided to escape this trap. After five months of intense work — four to five hours a day writing, designing, and researching — I created something I wish I had when I started programming. A book that’s a complete beginner’s guide: &lt;strong&gt;&lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One.&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnvqegyfwy8zj31qnbbfo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnvqegyfwy8zj31qnbbfo.png" alt="cover image of clean code zero to one: from messy code to masterpiece" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to learn more about the book, I give you all the details at the end of this tutorial. So read on to learn more about writing clean code.&lt;/p&gt;

&lt;h2&gt;
  
  
  12 Clean Code Design Patterns for Building Agile Applications ⚖️
&lt;/h2&gt;

&lt;p&gt;If your code doesn’t follow these modern clean code design patterns, you could be creating a ticking time bomb. These patterns are your tools. Master them and enjoy the success of your projects. Let me show you one by one.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🌿 Use Names That Mean Something&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Naming your variables or functions b or x is not helpful. Call them what they are so they’re easier to understand. Here’s an example of both a bad and good variable name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Weak and vague&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Strong and clear&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numberOfUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;People who write unclear names don’t want to own their mistakes. Don’t be that person.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1httisvhttuys6kef9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1httisvhttuys6kef9u.png" alt="Comic showing a bad vs a good variable name, by Shahan" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🔨 Keep Functions Laser-Focused (SRP)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A function should do &lt;strong&gt;one thing&lt;/strong&gt;—and do it perfectly. This is called the Single Responsibility Principle (&lt;strong&gt;SRP&lt;/strong&gt;).&lt;/p&gt;

&lt;p&gt;Good code is like a hammer. It hits one nail, not ten. For example, if you are hiring someone to do everything in your company — finance, sales, marketing, janitorial work, and so on — they’ll likely fail miserably because they can’t focus one one thing. The same goes for your classes in code.&lt;/p&gt;

&lt;p&gt;🚧 When a class or function does more than one thing, it becomes a tangled mess. Debugging it feels like solving a puzzle upside down. If your class handles both user input and database operations, for example, it’s not multitasking — it’s madness. Break it up. One method, one job.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔥 My Rule:&lt;/strong&gt; Your code works for you. Keep it sharp, focused, and controllable, or it’s going to control you. Here is how to make that happen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Clean: One job, one focus&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;logTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`User: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, Total: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Messy: Trying to do EVERYTHING&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateAndLogTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`User: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, Total: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🪧 When you mix tasks, you mix in confusion. As simple as that.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🚪 Use Comments Thoughtfully&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;There is a great saying among professional developers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“ Code speaks for itself. ”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You don’t explain what a door does every time someone walks into a room, do you? Your code should work the same way.&lt;/p&gt;

&lt;p&gt;Comments aren’t bad, but if your code can’t stand on its own, then you may have a problem.&lt;/p&gt;

&lt;p&gt;🪧 A good comment should tell “why” not “how or what”. If a developer doesn’t understand “how” something works, then they likely aren’t going to understand “why” either.&lt;/p&gt;

&lt;p&gt;Here are some short examples of good comments vs bad comments. I’ll also show you a real-world project for writing clean comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1: Bad Comment 👎&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Multiply the price by the quantity to calculate the total&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a &lt;strong&gt;bad comment&lt;/strong&gt; because it simply repeats what the code already says. The code &lt;code&gt;price * quantity&lt;/code&gt; is self-explanatory, so the comment doesn’t add anything useful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good Comment: 👍&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the code is clear and simple, &lt;strong&gt;you don’t need a comment.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzt1fx5miz7jfw09bled.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzt1fx5miz7jfw09bled.png" alt="Image illustrating unnecessary comment vs " width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2: Bad Comment 👎&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Check if the user logged in&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isUserLoggedIn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This comment is bad because it doesn’t explain why the &lt;code&gt;isUserLoggin()&lt;/code&gt; exists. It just explains what happens. But we already know that this is an auth function. This comment is a waste of time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good Example 👍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The user is authenticated before accessing protected resources&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isUserLoggedIn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a &lt;strong&gt;good comment&lt;/strong&gt; because it explains &lt;strong&gt;why&lt;/strong&gt; the code exists. It tells us that the function checks if the user is authenticated before allowing access to sensitive parts of the app. It focuses on the bigger picture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpnwh4ssmfb8jgctboyej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpnwh4ssmfb8jgctboyej.png" alt="Before: " width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;⚡ Best Practices for Writing Good Comments&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Explain the “Why,” not the “What”:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Write comments to explain the purpose or context of the code, not what the code is doing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Avoid obvious comments:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Don’t write comments for things the code already makes clear.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keep them short and precise:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Write concise comments that are easy to read and directly explain the purpose.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Update comments regularly:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Outdated comments can mislead developers, so always update them when the code changes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Real-World Example (with Good Comments) 🛒&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s implement these practices into a real-world project: a large e-commerce application. One function calculates shipping costs based on the order details. Here's the full code, I will explain each comment below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Shipping rules:&lt;/span&gt;
&lt;span class="c1"&gt;// - Free shipping for orders over $100&lt;/span&gt;
&lt;span class="c1"&gt;// - Standard shipping ($10) for orders below $100&lt;/span&gt;
&lt;span class="c1"&gt;// - Additional $5 for international orders&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateShipping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;shippingCost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Check if the order qualifies for free shipping&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;shippingCost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Free shipping&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;shippingCost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Standard shipping cost&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Add additional cost for international orders&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isInternational&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;shippingCost&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;shippingCost&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Example usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;order1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isInternational&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;order2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;isInternational&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;calculateShipping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 0&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;calculateShipping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 15&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the start of the function, we include a comment explaining the rules for shipping costs. This gives the reader an overview of the logic without needing to read the full code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Shipping rules:&lt;/span&gt;
&lt;span class="c1"&gt;// - Free shipping for orders over $100&lt;/span&gt;
&lt;span class="c1"&gt;// - Standard shipping ($10) for orders below $100&lt;/span&gt;
&lt;span class="c1"&gt;// - Additional $5 for international orders&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, the first condition checks if the order total is greater than or equal to $100. A comment here clarifies &lt;strong&gt;why&lt;/strong&gt; free shipping is applied.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Check if the order qualifies for free shipping&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;shippingCost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Free shipping&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second condition applies an additional charge for international shipping. The comment explains &lt;strong&gt;why&lt;/strong&gt; the extra cost is added.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Add additional cost for international orders&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isInternational&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;shippingCost&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why are these comments good?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you’re working in a team of 20 developers. Someone reads the &lt;code&gt;calculateShipping&lt;/code&gt; function six months later. Without these comments, they might waste time guessing why international orders have an extra fee. Good comments clarify the why and save hours of frustration.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🧩 Make Your Code Readable&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If someone reading your code feels like they’re solving a riddle, you’ve already become a troublemaker. Here is the proof:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Clean: Reads like a story&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Welcome!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Please log in.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Messy: Feels like chaos&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Welcome!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Please log in.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your code is messy and hard to read, it will confuse others—and even yourself later! Imagine coming back to your own code after six months and feeling like you’re reading a foreign language. Readable code saves time, reduces bugs, and makes everyone’s life easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🍵 Why is Readability Important?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For yourself:&lt;/strong&gt; When you revisit your code after weeks or months, clean code helps you pick up where you left off without wasting time figuring out what you did.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For your team:&lt;/strong&gt; If someone else reads your code, they shouldn’t have to solve a puzzle. Clean code makes teamwork smoother and prevents miscommunication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fewer bugs:&lt;/strong&gt; Clear code is easier to debug because you can quickly spot mistakes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;🧙‍♂️ How to Write Readable Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s build a simple program to manage books in a library. We’ll make it clean and readable and then I will break down this code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// A class to represent a book&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Book&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isAvailable&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isAvailable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;isAvailable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;borrow&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isAvailable&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isAvailable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`You borrowed "&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;".`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Sorry, "&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;" is not available.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;returnBook&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isAvailable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`You returned "&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;".`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// A function to display available books&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;displayAvailableBooks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;books&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Available books:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isAvailable&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`- &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; by &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Example usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;book1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Book&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;The Clean Coder&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Robert Martin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;book2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Book&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You Don’t Know JS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kyle Simpson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;book3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Book&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Eloquent JavaScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Marijn Haverbeke&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;library&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;book1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;book2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;book3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nf"&gt;displayAvailableBooks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;library&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Show available books&lt;/span&gt;
&lt;span class="nx"&gt;book1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;borrow&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Borrow a book&lt;/span&gt;
&lt;span class="nf"&gt;displayAvailableBooks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;library&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Show available books again&lt;/span&gt;
&lt;span class="nx"&gt;book1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;returnBook&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Return the book&lt;/span&gt;
&lt;span class="nf"&gt;displayAvailableBooks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;library&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Final list&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We created a &lt;code&gt;Book&lt;/code&gt; class to represent each book. It has properties like &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;author&lt;/code&gt;, and &lt;code&gt;isAvailable&lt;/code&gt; to track its status.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;borrow&lt;/code&gt; method checks if the book is available. If yes, it marks it as unavailable and prints a message.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;returnBook&lt;/code&gt; method makes the book available again.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;displayAvailableBooks&lt;/code&gt; function loops through the library and prints only the books that are available.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We create three books (&lt;code&gt;book1&lt;/code&gt;, &lt;code&gt;book2&lt;/code&gt;, &lt;code&gt;book3&lt;/code&gt;) and store them in a &lt;code&gt;library&lt;/code&gt; array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We borrow and return books, showing how the list of available books changes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you can see, readable code is not just about style. It saves time, prevents bugs, and preserves your code as useful for years to come.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🏌️ Test Everything You Write&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you don’t take the time to write tests, you shouldn’t be surprised if your code breaks. If you do want to write tests, follow this unit testing strategy to catch problems ahead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Is Unit Testing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Concretely, unit testing checks individual parts of your code (like functions or classes) to ensure they work correctly. Just like checking each brick of your house for soundness before building the walls.&lt;/p&gt;

&lt;p&gt;Let me give you an example of how unit testing works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Calculator&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Test it (Unit Test)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;calculator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Calculator&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;calculator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Addition failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;calculator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Subtraction failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s what’s going on in this code:&lt;/p&gt;

&lt;p&gt;First, we create the calculator class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Calculator&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Calculator&lt;/code&gt; class has two methods: &lt;code&gt;add&lt;/code&gt; and &lt;code&gt;subtract&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;add(a, b)&lt;/code&gt; takes two numbers and returns their sum.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;subtract(a, b)&lt;/code&gt; takes two numbers and returns their difference.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next, we set up the tests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;calculator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Calculator&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we’re creating an instance of the &lt;code&gt;Calculator&lt;/code&gt; class to test its methods.&lt;/p&gt;

&lt;p&gt;Then we write test cases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;calculator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Addition failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;calculator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Subtraction failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;console.assert(condition, message)&lt;/code&gt; checks if the condition is &lt;code&gt;true&lt;/code&gt;. If it’s &lt;code&gt;false&lt;/code&gt;, the message ("Addition failed" or "Subtraction failed") is displayed in the console.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;First test&lt;/strong&gt;: &lt;code&gt;calculator.add(2, 3) === 5&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Calls the &lt;code&gt;add&lt;/code&gt; method with &lt;code&gt;2&lt;/code&gt; and &lt;code&gt;3&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  Checks if the result is &lt;code&gt;5&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Second test&lt;/strong&gt;: &lt;code&gt;calculator.subtract(5, 3) === 2&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Calls the &lt;code&gt;subtract&lt;/code&gt; method with &lt;code&gt;5&lt;/code&gt; and &lt;code&gt;3&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  Checks if the result is &lt;code&gt;2&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;So what happens if something breaks? It’s pretty simple to solve any issues that arise here. In this case, if the &lt;code&gt;add&lt;/code&gt; or &lt;code&gt;subtract&lt;/code&gt; method doesn’t work correctly, the test will fail. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;calculator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Addition failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The condition &lt;code&gt;calculator.add(2, 3) === 6&lt;/code&gt; is &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The console will display: &lt;code&gt;"Addition failed"&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Real-World Example: Testing a Login System 👥&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s test a simple login system to see how unit testing works in a real-world scenario.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Auth&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1234&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Test the Auth class&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Auth&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;et5t45#@&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Login failed for valid credentials&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;wrongpassword&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Login succeeded for invalid credentials&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, create the &lt;code&gt;Auth&lt;/code&gt; class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Auth&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1234&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;login&lt;/code&gt; method checks if the username is &lt;code&gt;"admin"&lt;/code&gt; and the password is &lt;code&gt;"1234"&lt;/code&gt;. If both match, it returns &lt;code&gt;true&lt;/code&gt; – otherwise, &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Next, set up the tests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Auth&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create an instance of the &lt;code&gt;Auth&lt;/code&gt; class. Then write the test cases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1234&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Login failed for valid credentials&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;wrongpassword&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Login succeeded for invalid credentials&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;First test&lt;/strong&gt;: Checks if valid credentials (&lt;code&gt;"admin"&lt;/code&gt;, &lt;code&gt;"1234"&lt;/code&gt;) succeed. If not, &lt;code&gt;"Login failed for valid credentials"&lt;/code&gt; is displayed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Second test&lt;/strong&gt;: Checks if invalid credentials (&lt;code&gt;"user"&lt;/code&gt;, &lt;code&gt;"wrongpassword"&lt;/code&gt;) fail. If not, &lt;code&gt;"Login succeeded for invalid credentials"&lt;/code&gt; is displayed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🌱 Why testing results in clean code:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You naturally write smaller, more focused functions to make your code testable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tests verify that your code behaves as expected under different conditions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With tests in place, you can confidently update your code, knowing the tests will catch any mistakes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;💉 Use Dependency Injection&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Hardcoding dependencies is like tattooing someone’s name on your forehead — it’s permanent, can be abrasive, and locks you in.&lt;/p&gt;

&lt;p&gt;So, what does Dependency Injection do? It lets you manage your code's relationships by passing dependencies as arguments. It’s flexible, adaptable, and maintainable.&lt;/p&gt;

&lt;p&gt;To demonstrate how it works, here I’m using the Nodemailer dependency for sending emails to users:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Dependency: Sending emails with Nodemailer&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nodemailer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;nodemailer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sendEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transporter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;nodemailer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createTransport&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="cm"&gt;/* config */&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;transporter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendMail&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;programmingwithshahan@gmail.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ To save yourself from risk, make sure to avoid &lt;strong&gt;hardcoding&lt;/strong&gt; dependencies. Use abstraction or configuration files for secure maintenance.&lt;/p&gt;

&lt;p&gt;This is just one example. As a developer, you may use hundreds of libraries or dependencies.&lt;/p&gt;

&lt;p&gt;I’m not saying you shouldn’t rely on dependencies/libraries at all, as nowadays it is hard to avoid them. But you should be very careful before installing them in your coding projects.&lt;/p&gt;

&lt;p&gt;You should check the security, performance, quality, or functionality of an organization's software systems. Because they sometimes contain risks that can ruin your entire project.&lt;/p&gt;

&lt;p&gt;🚧 Always control your tools, don't let them control you.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;📂 Clean Project Structures&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A well-organized project is the difference between a &lt;strong&gt;trash heap&lt;/strong&gt; and a high-end &lt;strong&gt;boutique&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here is how each folder should be organized:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9xwyg9iqqcybz21lsgxz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9xwyg9iqqcybz21lsgxz.png" alt="Image of clean code project structure by shahan" width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your codebase looks like a junk drawer, you’ve already caused trouble for your future self.&lt;/p&gt;

&lt;p&gt;Let’s go through the clean project structure you can see above to better understand it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; &lt;code&gt;myProjet/src&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is the main container for your entire application. Everything your app needs is stored inside this folder. It has subfolders to keep things tidy and managed in one place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; &lt;code&gt;components&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is where you keep all the reusable pieces of your app. You can use these components in multiple places without building them again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; &lt;code&gt;services&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is the "brain" of your app. It handles all the work behind the scenes for both the frontend and backend. &lt;code&gt;emailService.js&lt;/code&gt;, &lt;code&gt;userService.js&lt;/code&gt; and &lt;code&gt;productService.js&lt;/code&gt; are some of the example files for your &lt;code&gt;services&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; &lt;code&gt;utils&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This contains all the small, handy tools you need to make your application run smoothly and make your life easier. For example, &lt;code&gt;formatedate.js&lt;/code&gt;, &lt;code&gt;validateEmail.js&lt;/code&gt; and &lt;code&gt;generateId.js&lt;/code&gt; are some of the common utils files to make reusable pieces of components for your entire project.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;5.&lt;/strong&gt; &lt;code&gt;tests&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Conventionally, test files are typically located &lt;strong&gt;outside&lt;/strong&gt; the &lt;code&gt;src&lt;/code&gt; folder, at the project root level. This keeps your production code (&lt;code&gt;src&lt;/code&gt;) separate from your test code (&lt;code&gt;tests&lt;/code&gt;), making it cleaner and easier to manage. Have a look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;myProject/
├── src/              # Production code
│   ├── components/
│   ├── services/
│   └── utils/
├── tests/            # Test files
│   ├── components/
│   ├── services/
│   └── utils/
├── package.json      # Project configuration
└── README.md         # Documentation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some developers may prefer creating one testing file inside the &lt;code&gt;test&lt;/code&gt; folder to test everything in one place. Unfortunately, it may feel clean at first, but as your project grows, you’ll have to find and search for specific code blocks. It’s ugly and can produce unexpected testing results. So breaking them into multiple testing files inside the &lt;code&gt;tests&lt;/code&gt; folder is highly recommended.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world example 📧&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So let me create a clean, durable project structure for you to apply in any future projects you might work on. Needless to say, clean project structure is the foundation of building a maintainable project.&lt;/p&gt;

&lt;p&gt;From our previous email sending application example, we will write a clean project structure for this app. We want to build an application that sends emails to users. Your clean project structure for this app should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6v6rlc5qiplgxz1h4dps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6v6rlc5qiplgxz1h4dps.png" alt="Image of email app clean code project structure by shahan" width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, I packed every subfolder and file inside the &lt;code&gt;src&lt;/code&gt; folder which is the main container of our application. Inside the &lt;code&gt;src&lt;/code&gt; folder, we created &lt;code&gt;components&lt;/code&gt;, &lt;code&gt;services&lt;/code&gt;, &lt;code&gt;utiles&lt;/code&gt;. Finally, we have a manageable &lt;code&gt;test&lt;/code&gt; folder outside the &lt;code&gt;src&lt;/code&gt; folder to test each component independently. This test folder has nothing to do with our production code that is located inside the &lt;code&gt;src&lt;/code&gt; folder.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🤹‍♂️ Be Consistent with Formatting&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Don’t write code like you’re 10 different people. Be consistent with your formatting.&lt;/p&gt;

&lt;p&gt;Use tools like &lt;a href="https://prettier.io/" rel="noopener noreferrer"&gt;Prettier&lt;/a&gt; or &lt;a href="https://eslint.org/" rel="noopener noreferrer"&gt;ESLint&lt;/a&gt; to enforce a consistent style. If every file looks different, you’re creating chaos that no one wants to fix.&lt;/p&gt;

&lt;p&gt;I would say that consistency in formatting is one of the most important aspects of writing clean code.&lt;/p&gt;

&lt;p&gt;Have a look...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46zu4k5nnrkcdesgqrye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46zu4k5nnrkcdesgqrye.png" alt="Image of consistent formatting snippets from clean code zero to one book" width="800" height="960"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Always use 2 spaces for indentation&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dimensions must be positive numbers.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Add meaningful whitespace for readability&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rectangle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Clear separation of logic&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;area&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rectangle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rectangle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Area: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;area&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s examine some of the aspects of this code that make it clean:&lt;/p&gt;

&lt;h4&gt;
  
  
  1️⃣ Consistent Indentation
&lt;/h4&gt;

&lt;p&gt;Why 2 or 4 spaces? It’s clean, minimal, and universally accepted in many JavaScript style guides. It doesn’t overwhelm the eyes, and the code structure stands out clearly. When you mix inconsistent indentation (2 spaces here, 4 spaces there), you confuse people—and confused people make mistakes.&lt;/p&gt;

&lt;h4&gt;
  
  
  2️⃣ Meaningful Whitespace: Giving Code Room to Breathe
&lt;/h4&gt;

&lt;p&gt;That extra line break between the rectangle definition and the &lt;code&gt;try&lt;/code&gt; block is like a pause in a sentence — it gives the reader time to process.&lt;/p&gt;

&lt;h4&gt;
  
  
  3️⃣ Clear Separation of Logic: Modular Thinking
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;area&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rectangle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rectangle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Area: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;area&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look at how the logic is divided into clear sections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First, the calculation (&lt;code&gt;calculateArea&lt;/code&gt; function).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, the output (&lt;code&gt;console.log&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, error handling (&lt;code&gt;catch&lt;/code&gt; block).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each task has its own space and purpose.&lt;/p&gt;

&lt;h4&gt;
  
  
  4️⃣ Readable Error Handling
&lt;/h4&gt;

&lt;p&gt;When you throw errors or log messages, you format them cleanly. No vague or cryptic messages here. A developer seeing this will immediately know the problem.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dimensions must be positive numbers.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🐦‍⬛ General tips for consistent formatting:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use 2 or 4 spaces for indentation consistently throughout your codebase. Avoid tabs to maintain uniformity across different editors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep lines to a maximum of 100-120 characters to prevent horizontal scrolling and improve readability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Group related logic together and separate blocks of code with blank lines to highlight their purpose.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, avoid over-aligning code. Instead, let indentation naturally guide the flow of logic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;✋ Stop Hardcoding Values&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Hardcoding values is a lazy way to code. Here is the proof:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Bad: Hardcoded and rigid&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;maxUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentUsers&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;maxUsers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Too many users!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Clean: Dynamic and flexible&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MAX_USERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentUsers&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;MAX_USERS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Too many users!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You see, changing this variable won’t surprise you in the future. You know exactly where to find it to change uncertain values.&lt;/p&gt;

&lt;p&gt;Its best to store your fixed values in the global configuration (config) file.&lt;/p&gt;

&lt;p&gt;🪧 So, avoid hardcoding values at all costs. Hardcoding is the shortcut that may drive your future self (or others) crazy.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🤏 Keep Functions Short&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If your function is longer than 20 lines, it’s probably trying to do too much_._&lt;/p&gt;

&lt;p&gt;Short functions are sharp functions. They hit their mark every time.&lt;/p&gt;

&lt;p&gt;Long, bloated functions are messy and hard to read, but short functions are clear and focused. Here is how your large functions should break down:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;updateCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;addItemToCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;logTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addItemToCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let me explain this code so you understand why breaking down large functions is a winning strategy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Main Function:&lt;/strong&gt; &lt;code&gt;updateCart()&lt;/code&gt; calls smaller helper functions to handle specific tasks like:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-  Adds the item to the cart.

-  Calculates the total price.

-  Logs the details of the transaction.

-  Finally, it returns the total price.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Instead of one long block of code that tries to do everything, it delegates tasks to helper functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Helper Function:&lt;/strong&gt; &lt;code&gt;addItemToCart()&lt;/code&gt; This function &lt;strong&gt;only&lt;/strong&gt; handles adding the item to the cart. if you need to change how items are added (for example, checking for duplicates). You could just edit this small function instead of digging through a giant block of code in &lt;code&gt;updateCart&lt;/code&gt;. That’s how you write clean code functions that’s a joy to read and easy to maintain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Happens If Functions Are Too Long? 💤&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s say you didn’t break down the &lt;code&gt;updateCart&lt;/code&gt; function. Here’s what it might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;updateCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Added &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. Total is now &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What are the problems here?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It’s trying to do everything.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It’s hard to read, especially if it grows bigger.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If something breaks, you’ll waste time figuring out which part is the problem.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now the choice is yours: stick with the messy all-in-one approach or practice the clean one function one job mindset.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;⛺ Follow the Boy Scout Rule&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Always leave your campsite cleaner than you found it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let me break it down for you. You don’t just use something and leave it worse than before. That’s inconsiderate behavior. Real professionals leave things better than they found them.&lt;/p&gt;

&lt;p&gt;In coding terms, every time you touch the codebase, &lt;strong&gt;make it better.&lt;/strong&gt; Clean it up, refactor messy parts, and improve readability. If you don’t, you’re just piling on garbage that will eventually collapse on your head.&lt;/p&gt;

&lt;p&gt;Here is an example. Instead of improving it, we’re just adding more layers of complexity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Original code: Hard to read, poorly named variables&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// We're adding to it but not cleaning it up&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calcDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;discountRate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;final&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;discountRate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;final&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After: it gets better every time. Here’s how a disciplined coder works — they improve as they go:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Improved code: Clear names, refactored for clarity&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateSubtotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateDiscountedTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;discountRate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculateSubtotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;discount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;discountRate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;subtotal&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;discount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, anyone can tell what’s happening at a glance. Because we’ve broken down the code into smaller, more focused functions. Thus, adding new features won’t break existing functionality. 🏕️&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🏟️ Follow the Open/Closed Principle&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This design principle suggests your code should be designed to allow extensions without changing the existing foundation.&lt;/p&gt;

&lt;p&gt;You want to add features &lt;em&gt;—&lt;/em&gt; not rip it apart every time you upgrade_._ Modifying old code to fit new requirements is exactly like trying to rebuild your house every time you buy new furniture. It’s not sustainable.&lt;/p&gt;

&lt;p&gt;Let’s see how you can build smarter, scalable code that lets you add features without breaking everything else.&lt;/p&gt;

&lt;h4&gt;
  
  
  Before: Violating the principle
&lt;/h4&gt;

&lt;p&gt;You’ve got a class to handle payments — simple enough. At first, it just handles credit cards.&lt;/p&gt;

&lt;p&gt;But then your boss shows up and says, &lt;em&gt;“Hey, now we need PayPal support.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And because you didn’t bother learning clean code, your code looks like a spaghetti monster straight out of a legacy enterprise system from 1995. Here’s the masterpiece you’ve crafted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PaymentProcessor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;paymentType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;paymentType&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;creditCard&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Processing credit card payment of &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;paymentType&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paypal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Processing PayPal payment of &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Unsupported payment type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;paymentProcessor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PaymentProcessor&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;paymentProcessor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;creditCard&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;paymentProcessor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;paypal&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alas! Every new payment type (like Apple Pay, Google Pay, and so on) requires modifying the &lt;code&gt;processPayment&lt;/code&gt; method. Needless to say, you risk breaking existing functionality while adding new features. If you had learned this principle, you might not be in this mess.&lt;/p&gt;

&lt;p&gt;Don’t worry: I’ll help you to fix this. First, we need to refactor the code. Instead of modifying the existing class, we’ll extend its functionality using &lt;a href="https://stackify.com/oop-concept-polymorphism/" rel="noopener noreferrer"&gt;polymorphism&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;javascriptCopy&lt;/span&gt; &lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="c1"&gt;// Base class&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PaymentProcessor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;processPayment() must be implemented&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Credit card payment&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CreditCardPayment&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;PaymentProcessor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Processing credit card payment of &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// PayPal payment&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PayPalPayment&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;PaymentProcessor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Processing PayPal payment of &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Adding a new payment type? Just extend the class!&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ApplePayPayment&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;PaymentProcessor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Processing Apple Pay payment of &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;payments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CreditCardPayment&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PayPalPayment&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ApplePayPayment&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;payments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;processPayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, adding new payment methods doesn’t require changing the existing &lt;code&gt;PaymentProcessor&lt;/code&gt; class. You just created a new subclass. So the original code remains untouched, meaning there’s no risk of breaking existing features.&lt;/p&gt;

&lt;p&gt;Each payment type has its own class, and adding PayPal payment support, for example, doesn’t break the code. Now you can reply to your boss: &lt;em&gt;“Of course, I will add this feature in 5 minutes.”&lt;/em&gt; Your promotion is waiting for you to accept it.&lt;/p&gt;

&lt;p&gt;I share even more tips in my book &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Modern Best Practices to Help You Write Clean Code: A Summary 🥷&lt;/p&gt;

&lt;p&gt;Now let me show you the best practices and summarise our 12 Clean Code design principles to help you write clean code for agile application development.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔎 Common Code Smells and How to Fix Them
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;💊 Duplication: If you're copying code, you’re creating more work for yourself. Extract it into a function, and do it right.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🛤️ Long methods: If your method needs a scroll bar, it's doing too much. Break it down, keep it focused.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;👑 King objects: No class should be doing everything. Simplify responsibilities, or your codebase will become messy.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  💬 Effective Commenting Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;💭 When to comment: Only comment if the code isn't clear. If it is, comments are just clutter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🫗 Clarity: Comments should tell why, not what. If your code needs explaining, it might be too complex.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🌴 Avoid redundancy: Don't comment what's obvious. If your function is addNumbers, don't comment it does that.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🧼 Refactoring Techniques for Clean Code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🏭 Extract methods: Big methods? Break them down. It's not just about cleanliness –– it's about control.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🫕Rename variables: If your variable names don’t shout their purpose, change and improve them. Precision in naming is precision in thought.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🍃 Simplify conditionals: If your conditionals look like algebra, simplify them. If a == true, just write if(a).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🧪 Testing and Clean Code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🧙 Unit tests: Test every piece of code like you're interrogating a suspect. No stone unturned.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🏇TDD (Test Driven Development): Write tests first. It's not just about catching bugs, it's about knowing exactly what your code should do before you write it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🧽 Clean tests: Your tests should be as clean as your code. If they're messy, they’re not going to be helpful.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🐛 Error Handling and Clean Code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;⁉️ Exceptions: Use them. They're not just for errors, they're also for keeping your code clean from error clutter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🖍️ Fail fast: If something's wrong, stop right there. Don't let errors add up. Deal with them immediately.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🚨 Logging: Log like you're documenting a crime scene. Clear, precise, and only what's necessary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🌱 Code Reviews and Clean Code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🚢 Process: Have a system. No cowboy coding. Review, critique, improve.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🔪 Tools: Use tools that make reviews easy. They're not just for catching mistakes, they're also for teaching discipline.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🧦 Culture: Cultivate a culture where feedback is gold. Help your team learn how to handle and receive critiques.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Automated Tools for Maintaining Clean Code ⚓
&lt;/h2&gt;

&lt;p&gt;Tools and automation techniques can be really helpful in writing clean code. If you’re not using the right tools and automating things to save yourself time, you’re missing out.&lt;/p&gt;

&lt;p&gt;You think you can "eyeball" your way through code quality? Guess again. Without automation, this is what happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;👎 You miss obvious mistakes because you're "too busy."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🤕 Your code looks different in every file, making collaboration a headache.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🪦 Deployment breaks because you skipped a critical test.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Successful developers use the right tools to automate code and get things done. Here are four strategies for maintaining clean code using modern tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1️⃣ Static Analysis&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Static analysis is actually a code inspector that reads through your code and points out potential issues early on. The best part? It works &lt;strong&gt;before&lt;/strong&gt; runtime, catching errors that could otherwise lead to crashes, downtime, or embarrassing bugs.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;How does it work?&lt;/strong&gt;
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Syntax checking&lt;/strong&gt;: It looks at your code to analyze everything written in the correct syntax. If you misspell a variable or forget a closing bracket, it’ll call you out instantly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code quality rules&lt;/strong&gt;: Tools like ESLint enforce rules like consistent indentation, avoiding unused variables, and sticking to best practices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Error prevention&lt;/strong&gt;: It identifies logic errors, such as using variables that haven’t been defined, or making comparisons that don’t make sense.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s how static analysis works in action:&lt;/p&gt;

&lt;h4&gt;
  
  
  🚨 Before static analysis:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sume&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Typo, unnoticed until runtime&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Problem&lt;/strong&gt;: The typo in &lt;code&gt;sume&lt;/code&gt; will only cause an error when the code runs, and that could lead to frustrating debugging sessions or worse — breaking the app in production.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  🚑 After static analysis (using ESLint):
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;codeError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sume&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;not&lt;/span&gt; &lt;span class="nx"&gt;defined&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Solution&lt;/strong&gt;: &lt;a href="https://eslint.org/" rel="noopener noreferrer"&gt;ESLint&lt;/a&gt; immediately flags the typo before you even run the code. The error is caught early, saving you time and headaches.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2️⃣ Automated Code Formatting&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Before Formatting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="p"&gt;){&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nf"&gt;calculate &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Problem&lt;/strong&gt;: Inconsistent spacing and formatting make the code harder to read.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  After using Prettier:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Solution&lt;/strong&gt;: Clean, consistent, and professional formatting is applied automatically. No more nitpicking over spaces or alignment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pretty basic stuff though. I covered this in case you write code in notepad or something where IDE is not provided (for example, a job interview).&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3️⃣ Continuous Integration (CI) Testing&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;CI testing make sure every new change to your code is verified automatically. It’s like a safety net that catches bugs introduced during development. CI tools run your tests every time you push code, so nothing breaks after deployment.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;How Does CI Testing Work?&lt;/strong&gt;
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Triggers on change&lt;/strong&gt;: Each time code is committed, the CI tool (like &lt;a href="https://github.com/features/actions" rel="noopener noreferrer"&gt;GitHub Actions&lt;/a&gt;, &lt;a href="https://www.jenkins.io/" rel="noopener noreferrer"&gt;Jenkins&lt;/a&gt;) runs automated tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Feedback&lt;/strong&gt;: It gives you instant feedback if something fails.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prevents broken code&lt;/strong&gt;: Commits only clean, and the working code gets merged into the main branch.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4️⃣ CI/CD pipelines&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We also use CI/CD pipelines as a continuous process that includes code building, testing, and deployment, while CI testing is a part of that process that focuses on automating the testing of code changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Differece between CI/CD pipelines vs CI testing:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CI/CD pipelines:&lt;/strong&gt; A CI/CD pipeline combines code building, testing, and deployment into a single process. This process make sure that all changes to the main branch code are releasable to production. CI/CD pipelines can reduce deployment time, decrease costs, and improve team collaboration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CI testing:&lt;/strong&gt; CI testing is the process of automatically testing code changes that are integrated into a central repository. CI testing focuses on making sure the codebase is stable and that integration issues are resolved. CI testing help developer build software that is stable, bug-free, and meets functional requirements&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🚧 This is what CI testing CI/CD pipelines concepts are really about. Not as complex as it seems. So let me elaborate more on CI testing with GitHub Actions, as we usually run tests through automated tools nowadays.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;⚡ Continuous Integration (CI) Testing with GitHub Actions&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As I said earlier, CI tools run automated tests every time you push code or open a pull request. This guarantees that only working, bug-free code gets merged into the main branch.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Set Up CI Testing with GitHub Actions
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create Your Repository&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set up a GitHub repository for your project. Then, push your code to GitHub using the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git init
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial commit for CI Testing"&lt;/span&gt;
git branch &lt;span class="nt"&gt;-M&lt;/span&gt; main
git remote add origin https://github.com/codewithshahan/codewithshahan.git
git push &lt;span class="nt"&gt;-u&lt;/span&gt; origin main

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or you can create a new repo from your GitHub account without using the command. Just login to your GItHub account and visit dashboard. Here you will find a “New” button to create a brand new repo:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwu4mnv92uvvbcyn95bo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwu4mnv92uvvbcyn95bo.png" alt="image of creating a new repo on github by Shahan" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Add a GitHub Actions Workflow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Navigate to your repository’s &lt;strong&gt;Actions&lt;/strong&gt; tab. To do this, first, you have to visit your repo on Github (you will find the link after creating your repo). In this case, I created a new repo called “codewithshahan”. Here, look for the &lt;strong&gt;Actions&lt;/strong&gt; tab on the right side of the navigation bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxs63er6prc63ph8c8vp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxs63er6prc63ph8c8vp0.png" alt="Image of github actions navigation tab by shahan" width="800" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After navigating the Actions tab, scroll down a little and you will find the &lt;strong&gt;continuous integration&lt;/strong&gt; section:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6je4zwug4js9khb27oxz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6je4zwug4js9khb27oxz.png" alt="Image of CI (Continuous Integration) testing on Github Actions Page by Shahan" width="800" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose a setup workflow yourself. I will use Node.js for this project.&lt;/p&gt;

&lt;p&gt;After clicking the configure button, a &lt;code&gt;node.js.yml&lt;/code&gt; file will be created automatically, and you can adjust the code depending on your goals.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxsxic171busrm0f4k44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxsxic171busrm0f4k44.png" alt="Image of GitHub workflow snippet for automated testing by Shahan" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I won’t go into detail about how should modify your &lt;code&gt;.yml&lt;/code&gt; file. It depends on your project goals and personal preference. Also, it is a whole different broader topic and as this article has already become quite long, so I’ll explain it in a future article. For now, just stick with this foundational knowledge.&lt;/p&gt;

&lt;p&gt;This CI Testing workflow is best for modern application development. Your app remains stable while incorporating key features including testing (e,g. Dark Mode), Building and deploying applications directly within your GitHub repository. This way, you can push your code confidently, knowing your code is always clean and ready for production.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Role of Documentation in Agile Software Development 🚣
&lt;/h2&gt;

&lt;p&gt;If you want your code to be top-notch, you need to understand how to write good documentation. If you think documentation is just about scribbling down how the code works, you’re wrong. It's about explaining &lt;strong&gt;why&lt;/strong&gt; it works, not just how it works. That’s where most people miss the mark.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. 🚡 Create &lt;strong&gt;Useful Docs (Explain Why, Not Just How)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When you write documentation, you're not just throwing down some instructions for how to use the code. You're telling the next person (or even yourself in the future) why this piece of code exists in the first place. That’s the difference between good and bad documentation.&lt;/p&gt;

&lt;p&gt;Bad docs leave people scratching their heads. They’re too vague, too simple, and they don’t answer the big questions. If your documentation is unclear, that likely means your thinking is unclear. You’re basically saying, &lt;em&gt;"I don’t care if you understand this, it works, just use it."&lt;/em&gt; That’s not helpful.&lt;/p&gt;

&lt;p&gt;Great documentation answers the tough questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;✅ Why did you choose this approach over another?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✅ Why does this function exist? What problem does it solve?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✅ Why did you write this code the way you did?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your docs are just regurgitating how to use the code, you’re not being as helpful as you can be. Start thinking deeper and explaining the reasoning behind everything.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. ⏳ &lt;strong&gt;Keep the Docs Updated (Outdated Docs Are Worse Than No Docs)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Outdated documentation is the worst. In fact, it can be worse than having no docs at all. When you leave documentation that’s out of sync with the code, you’re doing your future self — or whoever has to deal with it next — a huge disservice.&lt;/p&gt;

&lt;p&gt;Every time your code changes, your documentation needs to change too. It has to reflect the current state of things. Don’t mislead future developers (or yourself) by leaving outdated info that will only confuse them and waste their time. If something is no longer relevant, delete it. Outdated documentation is the equivalent of a cluttered mind — it holds you back.&lt;/p&gt;

&lt;p&gt;Make it a habit to check and update your documentation regularly. The minute a line of code changes, so should your documentation. Period.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. 🚆 &lt;strong&gt;Integrate Comments (Good Comments in Code Are Part of Documentation)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Here’s the deal — comments in your code should &lt;strong&gt;integrate&lt;/strong&gt; with your documentation. Good comments aren’t just a crutch for developers who can’t explain their code elsewhere. They should improve your docs, not replace them.&lt;/p&gt;

&lt;p&gt;Comments are supplements to your documentation. You write clean, understandable code that needs minimal explanation, but when something isn’t crystal clear, throw in a comment. Remember the rule for comments in your code: explain the &lt;strong&gt;why&lt;/strong&gt;, not the &lt;strong&gt;how&lt;/strong&gt;. It’s the same here. Don’t repeat yourself. Let your code do the talking. Comments should complement the bigger picture of your documentation, not act as a band-aid for sloppy code.&lt;/p&gt;

&lt;p&gt;🪧 Great code should be self-explanatory. Fix the code, then add comments for clarification if necessary. Keep comments clean, short, and to the point.&lt;/p&gt;

&lt;p&gt;If you want to write clean, efficient, and maintainable code, documentation is key. Stop thinking of docs as an afterthought or something you do to fill space. It’s an extension of your code — your way of communicating clearly and effectively. It’s your roadmap for future developers, and it’s a reflection of your thought process.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion 🏁
&lt;/h2&gt;

&lt;p&gt;Clean code isn't a nice-to-have –– it's a must-have for those who aim to lead. It's about control, efficiency, and improvement over time in the long run. And ultimately, it’ll help you succeed in the game of agile software development. &lt;/p&gt;

&lt;p&gt;🪧 If you want to truly master your craftsmanship, write clean code, and let the efficiency speak for itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Frequently Asked Questions About Clean Code 🧯
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What is clean code?&lt;/strong&gt; It's code that doesn't make you want to throw your laptop out the window.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Why is clean code important in Agile?&lt;/strong&gt; Because Agile is about speed and change, and you can't be quick with a mess.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What are code smells?&lt;/strong&gt; Signs that you're about to lose control of your codebase.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;How can I improve commenting?&lt;/strong&gt; Only comment on what's necessary, and make sure each comment adds value, not noise.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thank you for being with me. You can visit my &lt;a href="https://x.com/shahancd" rel="noopener noreferrer"&gt;Twitter account&lt;/a&gt; or &lt;a href="https://www.codewithshahan.com" rel="noopener noreferrer"&gt;my website&lt;/a&gt; to read more posts about clean code and Agile application development. Until next time… keep improving your codebase.&lt;/p&gt;

&lt;p&gt;If you’re serious about mastering clean code and taking your programming career to the next level, then my book is for you: &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;&lt;strong&gt;Clean Code Zero to One&lt;/strong&gt;&lt;/a&gt;. This book is your full guide from zero to one in clean code, from messy code to masterpiece. I am offering a 50% discount using the code "earlybird" — only for the first 50 copies. Plus, there’s a 30-day money-back guarantee — no risk, all reward.&lt;/p&gt;




&lt;h2&gt;
  
  
  Other Trending Handbooks
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/complete-guide-to-css-transform-functions-and-properties/" rel="noopener noreferrer"&gt;Learn CSS Transform&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/how-to-create-a-static-blog-with-lume/" rel="noopener noreferrer"&gt;Build a Static Blog&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/how-to-build-an-ai-chatbot-with-redis-python-and-gpt/" rel="noopener noreferrer"&gt;Build an AI Chatbot&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/what-is-programming-tutorial-for-beginners/" rel="noopener noreferrer"&gt;What is Programming?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/python-code-examples-sample-script-coding-tutorial-for-beginners/" rel="noopener noreferrer"&gt;Python Code Examples&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/a-practical-guide-to-start-opensource-contributions/" rel="noopener noreferrer"&gt;Open Source for Devs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/http-full-course/" rel="noopener noreferrer"&gt;HTTP Networking in JS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/how-to-write-unit-tests-in-react-redux/" rel="noopener noreferrer"&gt;Write React Unit Tests&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/introduction-to-algorithms-with-javascript-examples/" rel="noopener noreferrer"&gt;Learn Algorithms in JS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/how-to-write-clean-code/" rel="noopener noreferrer"&gt;How to Write Clean Code&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/the-php-handbook/" rel="noopener noreferrer"&gt;Learn PHP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/the-java-handbook/" rel="noopener noreferrer"&gt;Learn Java&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/the-swift-handbook/" rel="noopener noreferrer"&gt;Learn Swift&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/learn-golang-handbook/" rel="noopener noreferrer"&gt;Learn Golang&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/get-started-with-nodejs/" rel="noopener noreferrer"&gt;Learn Node.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/complete-guide-to-css-grid/" rel="noopener noreferrer"&gt;Learn CSS Grid&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/learn-solidity-handbook/" rel="noopener noreferrer"&gt;Learn Solidity&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/the-express-handbook/" rel="noopener noreferrer"&gt;Learn Express.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/javascript-es-modules-and-module-bundlers/" rel="noopener noreferrer"&gt;Learn JS Modules&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/apache-kafka-handbook/" rel="noopener noreferrer"&gt;Learn Apache Kafka&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/rest-api-design-best-practices-build-a-rest-api/" rel="noopener noreferrer"&gt;REST API Best Practices&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/front-end-javascript-development-react-angular-vue-compared/" rel="noopener noreferrer"&gt;Front-End JS Development&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/build-consume-and-document-a-rest-api/" rel="noopener noreferrer"&gt;Learn to Build REST APIs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/build-strongly-typed-polymorphic-components-with-react-and-typescript/" rel="noopener noreferrer"&gt;Intermediate TS and React&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/command-line-for-beginners/" rel="noopener noreferrer"&gt;Command Line for Beginners&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/an-introduction-to-operating-systems/" rel="noopener noreferrer"&gt;Intro to Operating Systems&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/building-consuming-and-documenting-a-graphql-api/" rel="noopener noreferrer"&gt;Learn to Build GraphQL APIs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/oss-security-best-practices/" rel="noopener noreferrer"&gt;OSS Security Best Practices&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/design-patterns-for-distributed-systems/" rel="noopener noreferrer"&gt;Distributed Systems Patterns&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.freecodecamp.org/news/an-introduction-to-software-architecture-patterns/" rel="noopener noreferrer"&gt;Software Architecture Patterns&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building clean reusable React components 🌱</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Sat, 04 Jan 2025 13:40:25 +0000</pubDate>
      <link>https://dev.to/codewithshahan/building-clean-reusable-react-components-241l</link>
      <guid>https://dev.to/codewithshahan/building-clean-reusable-react-components-241l</guid>
      <description>&lt;p&gt;What are reusable React components? They are independent pieces of code that can be &lt;em&gt;reused&lt;/em&gt; throughout your website to save you time and effort.  &lt;/p&gt;

&lt;p&gt;They can be anything from simple buttons to complex forms. 🦋&lt;/p&gt;

&lt;h2&gt;
  
  
  🙎 Why Use Clean Reusable Components?
&lt;/h2&gt;

&lt;p&gt;As your website grows, you can easily add new features by combining existing components. This makes your code more scalable and adaptable.&lt;/p&gt;

&lt;p&gt;Plus, you can use your clean reusable code in future projects without writing it again from scratch. Any doubt? keep reading...📖&lt;/p&gt;




&lt;h2&gt;
  
  
  🏭 How to Make Clean Reusable React Components
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F415bke91bx930mf6o1xb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F415bke91bx930mf6o1xb.png" alt="Image OF HOW TO BUILD CLEAN REUSABLE COMPONENT IN REACT" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the &lt;strong&gt;two most important things&lt;/strong&gt; to keep in mind when creating clean reusable React components:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. 🩼 &lt;strong&gt;Avoid Side Effects&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Don't put logic that interacts with external data (like making API calls) directly inside a reusable component. Instead, pass this logic as props to the component.  &lt;/p&gt;

&lt;p&gt;For example, if a button does more than just looking pretty, like fetching data from the internet, it might not be reusable. 👎 &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🪧 This is a reusable button component. But it lacks best practices.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
   I will show you why in the &lt;em&gt;example section.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is a reusable button component (bad practice!)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Click&lt;/span&gt; &lt;span class="nx"&gt;Me&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. 🗃️ &lt;strong&gt;Use Props&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Props are arguments you pass to a component to customize its behavior and appearance. This allows you to use the same component for different purposes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is a button component that can change its color&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Click&lt;/span&gt; &lt;span class="nx"&gt;Here&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is still a bad practice because you have a fixed label called "Click Here". If you want to change the text on your button to, let's say: "Sign Up", then you would have to go back to the button component and make that change. 🙎 &lt;/p&gt;

&lt;p&gt;That means &lt;em&gt;every time&lt;/em&gt; you want to use a &lt;em&gt;different&lt;/em&gt; text, we'd have to go back and edit the code. In other words, it's NO longer reusable. 🪦&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💪 Challenge:&lt;/strong&gt; So what's the solution?&lt;br&gt;
You already have the answer. But if you don't, I am going to show you in the example section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌴 Hint:&lt;/strong&gt; Think about how you might want to use the component in different situations and design it to be flexible and adaptable.&lt;/p&gt;
&lt;h2&gt;
  
  
  🍃Examples of Reusable React Components
&lt;/h2&gt;

&lt;p&gt;Here are some common examples of reusable React components, along with some code examples to get you started:&lt;/p&gt;
&lt;h3&gt;
  
  
  Buttons
&lt;/h3&gt;

&lt;p&gt;Basic buttons with different styles and functionalities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Button component&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;
      &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`padding-2 shadow-none hover:shadow background-light-&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; hover:background-dark-&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Using the Button component&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Click Here&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Button clicked!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, I did not write "Click Here" in the button component. I want to make my button reusable, and thus it doesn't know anything about custom styles or texts.  &lt;/p&gt;

&lt;p&gt;So, I passed them as props (i.e., color, label, and onClick) to change them in the future without touching the original button components. Hope that makes it clear.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🪜Solution:&lt;/strong&gt; You need to pass each functionality as props in the reusable component.&lt;/p&gt;

&lt;h3&gt;
  
  
  Navbars
&lt;/h3&gt;

&lt;p&gt;Navigation bars that provide consistent navigation across your website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Navbar component&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Navbar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;isLoggedIn&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;navbar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;navbar-container&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;navbar-logo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;logo&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;logo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;navbar-links&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Home&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/about&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;About&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/contact&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Contact&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/profile&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Profile&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/login&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Login&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="p"&gt;)}&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Navbar&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Using the Navbar component&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Navbar&lt;/span&gt; &lt;span class="nx"&gt;isLoggedIn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, I passed &lt;code&gt;&amp;lt;Navbar isLoggedIn={true} /&amp;gt;&lt;/code&gt;  &lt;/p&gt;

&lt;p&gt;This line triggers the Navbar component and passes the isLoggedIn prop with a value of true, indicating the user is logged in. This will display the "Profile" link and hide the "Login" link.&lt;/p&gt;

&lt;p&gt;Similar to the button component, the Navbar component is reusable and accepts props to customize its behavior. Perfect! 👏&lt;/p&gt;

&lt;h2&gt;
  
  
  🤙 Why API Calls in a Button Component is a Bad Practice
&lt;/h2&gt;

&lt;p&gt;Now, you understand everything about reusable components in React.&lt;br&gt;&lt;br&gt;
Let's dig deeper by solving a complex problem.&lt;/p&gt;

&lt;p&gt;Consider the scenario where you have a button that does an API call. The code for the button component can be the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;doAPICall&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SaveButton&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;
      &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;doAPICall&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="p"&gt;}}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;Save&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;SaveButton&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is quite clear that you can’t reuse the above button in_ multiple_ places as this button component contains a &lt;strong&gt;side-effect&lt;/strong&gt; (&lt;code&gt;doAPICall()&lt;/code&gt;) inside it. ⚠️&lt;/p&gt;

&lt;p&gt;You can make this component reusable. First, you'll have to extract the side-effect and pass that as a prop to the button component like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;doAPICall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Does an API call to save the current state of the app.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SaveButton&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;doAPICall&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The button component should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SaveButton&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;onClick&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;
      &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;Save&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the above button can now be reused anywhere you want to save data with the click of a button. The button can now be used like this in multiple places: 🏗️&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;saveUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Does an API call to save the user.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;saveProject&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Does an API call to save the project.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SaveButton&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;saveUser&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SaveButton&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;saveProject&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also make the button component more reusable by using a &lt;code&gt;prop&lt;/code&gt; to control the label:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;saveUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Does an API call to save the user.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;saveProject&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Does an API call to save the project.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SaveButton&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;saveUser&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Save user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SaveButton&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;saveProject&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Save project&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The button component should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SaveButton&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;label&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;
      &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🚨 &lt;strong&gt;Early Bird Offer&lt;/strong&gt; 🚨
&lt;/h3&gt;

&lt;p&gt;If you’re &lt;strong&gt;serious about mastering clean code&lt;/strong&gt; and taking your web development career to the next level, then this book is for you. Grab &lt;strong&gt;&lt;em&gt;&lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt; today with a &lt;strong&gt;50% discount&lt;/strong&gt; using the code &lt;strong&gt;"earlybird"&lt;/strong&gt; — only for the first 50 developers! Plus, enjoy a &lt;strong&gt;30-day money-back guarantee&lt;/strong&gt; — no risk, all reward.&lt;/p&gt;

&lt;h2&gt;
  
  
  👏 Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations! You've successfully learned how to build clean reusable React components. &lt;/p&gt;

&lt;p&gt;Remember, reusable components are the building blocks of robust React development. By practicing clean React components, you can build cleaner, more efficient, and more maintainable React applications.&lt;br&gt;&lt;br&gt;
The more you practice, the better you'll become at identifying opportunities to use them in your projects!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📖 Read More:&lt;/strong&gt; &lt;a href="https://dev.to/codewithshahan/how-to-write-clean-code-tips-for-developers-with-examples-25ic"&gt;10 bulletproof rules for writing clean code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for taking the time to read this article. Until next time.. Keep learning and you can follow me on &lt;a href="https://x.com/shahancd" rel="noopener noreferrer"&gt;𝕏&lt;/a&gt; for the latest updates on programming and clean code.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The future of frontend development (2025)</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Tue, 31 Dec 2024 15:08:19 +0000</pubDate>
      <link>https://dev.to/codewithshahan/the-future-of-frontend-developer-2025-54me</link>
      <guid>https://dev.to/codewithshahan/the-future-of-frontend-developer-2025-54me</guid>
      <description>&lt;p&gt;The environment of front-end development is CHANGING dramatically.&lt;/p&gt;

&lt;p&gt;Thanks to technological developments, artificial intelligence (AI), and the growth of no-code/low-code platforms. &lt;/p&gt;

&lt;p&gt;Let's look at the &lt;strong&gt;&lt;em&gt;new trends&lt;/em&gt;&lt;/strong&gt; and examine the future of frontend developers.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤖 &lt;strong&gt;Machine Learning (AI)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5wp7y4ftx1zanagmuqqm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5wp7y4ftx1zanagmuqqm.png" alt="Image of frontend future frontend developer in 2025" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One popular concern in the technology world is whether artificial intelligence (AI) will replace front-end developers over the next decade.&lt;/p&gt;

&lt;p&gt;The answer is simple: &lt;strong&gt;No.&lt;/strong&gt; AI won’t replace you, but it will replace those &lt;u&gt;who fail to adapt.&lt;/u&gt;  &lt;/p&gt;

&lt;p&gt;AI is actually &lt;em&gt;changing&lt;/em&gt; the way we work. Tools like &lt;strong&gt;GitHub Copilot&lt;/strong&gt;, &lt;strong&gt;CodeGeeX&lt;/strong&gt;, and &lt;strong&gt;Figma’s FigJam AI&lt;/strong&gt; are automating repetitive tasks, such as writing boilerplate code or generating designs.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s the truth:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;👀 AI isn’t here to steal your job; it’s here to &lt;strong&gt;amplify your capabilities.&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;⌛ It saves up your time for &lt;strong&gt;creative, high-impact tasks&lt;/strong&gt; that AI can’t handle. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sam Altman&lt;/strong&gt;, CEO of OpenAI, said it best:  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“&lt;em&gt;If AI can do most jobs better than humans, we need to figure out how to share those resources so everyone has a good life.&lt;/em&gt;” &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;😨 &lt;strong&gt;Concerns About Losing Your Job?&lt;/strong&gt;&lt;br&gt;
While AI and automation are expected to impact certain aspects of front-end development, &lt;em&gt;the fear of job displacement is largely unfounded.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;AI is a tool, and its effectiveness &lt;em&gt;depends&lt;/em&gt; on the person using it. &lt;/p&gt;

&lt;p&gt;Developers who use AI creatively and make the most of its potential will be in the new era of innovation. They can hold a stable and dynamic career.&lt;/p&gt;

&lt;h2&gt;
  
  
  💼📈 Job Outlook and Opportunities
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7owg3ydw09z5a6hfqtbs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7owg3ydw09z5a6hfqtbs.png" alt="Image of future frontend developer job outlook" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Frontend developers are still in &lt;strong&gt;high demand&lt;/strong&gt; in 2025. The numbers speak for themselves.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here are some average salaries for front-end developers based on their job titles in the USA:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🤳 &lt;strong&gt;Mobile Applications Developer&lt;/strong&gt;: $99,257/year
&lt;/li&gt;
&lt;li&gt;🧑‍💼 &lt;a href="https://dev.to/codewithshahan/the-best-way-to-learn-web-development-a10"&gt;&lt;strong&gt;Web Application Developer&lt;/strong&gt;:&lt;/a&gt; $85,840/year
&lt;/li&gt;
&lt;li&gt;🧑‍✈️ &lt;strong&gt;Software Developer&lt;/strong&gt;: $87,521/year
&lt;/li&gt;
&lt;li&gt;👨‍🔬 &lt;strong&gt;Lead Web Developer:&lt;/strong&gt; $108,800/year&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(Source: &lt;a href="https://www.zippia.com/" rel="noopener noreferrer"&gt;Zippia&lt;/a&gt;)  &lt;/p&gt;

&lt;p&gt;Front-end developers make &lt;strong&gt;&lt;em&gt;$44.3&lt;/em&gt;&lt;/strong&gt; an hour on average, with the finance sector paying the highest wages for these professionals. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does this mean for you?&lt;/strong&gt;&lt;br&gt;
If you keep up with the &lt;strong&gt;latest&lt;/strong&gt; coding techniques, frameworks, and trends, your earning potential will only &lt;em&gt;grow&lt;/em&gt;.  &lt;/p&gt;




&lt;h2&gt;
  
  
  🪴 No-Code/Low-Code Platforms
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ni4fdaobh6hbgt029cl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ni4fdaobh6hbgt029cl.png" alt="Image of low code/no-code platforms for future frontend developers" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Platforms like &lt;strong&gt;Webflow&lt;/strong&gt;, &lt;strong&gt;Bubble&lt;/strong&gt;, and &lt;strong&gt;Squarespace&lt;/strong&gt; are allowing non-developers to create &lt;em&gt;functional websites&lt;/em&gt; without writing a single line of code.😨&lt;/p&gt;

&lt;p&gt;Wait a minute...does this mean frontend development is dead? &lt;/p&gt;

&lt;p&gt;Absolutely NOT.  &lt;/p&gt;

&lt;p&gt;Here’s why:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔫 These platforms are &lt;strong&gt;tools&lt;/strong&gt;, NOT replacements. They simplify basic tasks, &lt;strong&gt;&lt;em&gt;but they can’t handle complex, custom-built systems.&lt;/em&gt;&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;🦸‍♂️ As a developer, you’ll still be needed to &lt;strong&gt;build efficient scalable and maintainable applications by following Clean Code principles&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In fact, knowing HOW to integrate no-code/low-code tools into your workflow will make you even more valuable.  &lt;/p&gt;




&lt;h2&gt;
  
  
  🌱 Writing Clean Code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo1eu3em5fz23a4jkoz2t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo1eu3em5fz23a4jkoz2t.png" alt="Image of clean code zero to one for frontend developers" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Messy code = wasted time and broken projects.&lt;br&gt;
Clean code = scalable, maintainable software.&lt;/p&gt;

&lt;p&gt;Let’s be honest—AI and automation are making it easier to write code, &lt;strong&gt;but they’re also making it easier to write messy, unmanageable code.&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;If you don’t know how to write clean code:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🤦 You’ll spend hours fixing bugs and refactoring.
&lt;/li&gt;
&lt;li&gt;🩼 Your projects will break under the weight of complexity
&lt;/li&gt;
&lt;li&gt;💔 Your development organization will be at its knees &lt;/li&gt;
&lt;li&gt;🤜 or even getting rejected in the job interview&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Clean code isn’t an optional.&lt;/strong&gt; It’s the &lt;strong&gt;foundation&lt;/strong&gt; of building scalable, maintainable software.  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“The only way to make the deadline — the only way to go fast — is to keep the code as clean as possible at all times. Even bad code can function. But if code isn’t clean, it can bring a development organization to its knees. Every year, countless hours and significant resources are lost because of poorly written code. But it doesn’t have to be that way ” — Uncle Bob&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s why I wrote &lt;em&gt;Clean Code Zero to One&lt;/em&gt;—a beautifully design, very easy-to-understand textbook to master clean code principles that no one has ever written like this before (&lt;em&gt;thousands of digital illustrations&lt;/em&gt; and real-world graphical examples).&lt;/p&gt;

&lt;p&gt;🐦 &lt;strong&gt;Early Birds Sell: 50% OFF&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Start your 2025 with the most valuable skills you need: learning how to write Clean Code first.&lt;/p&gt;

&lt;p&gt;That literally separates amateur developers from true professionals. &lt;/p&gt;

&lt;p&gt;If you’re &lt;strong&gt;serious about mastering clean code&lt;/strong&gt; and taking your web development career to the next level, then this book is for you. Grab &lt;strong&gt;&lt;em&gt;&lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt; today with a &lt;strong&gt;50% discount&lt;/strong&gt; using the code &lt;strong&gt;"earlybird"&lt;/strong&gt; — only for the first 50 developers! Plus, enjoy a &lt;strong&gt;30-day money-back guarantee&lt;/strong&gt; — no risk, all reward.  &lt;/p&gt;




&lt;h2&gt;
  
  
  👏 &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The future of front-end development is bright, but only for those willing to adjust their skills. Use AI as an improvement but not as a liability. And most importantly, learn to write &lt;strong&gt;clean, maintainable code that AI can't handle&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Your career doesn’t depend on how fast you code — &lt;strong&gt;it depends on how well you code.&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Front-end developers need to adapt to these developments and keep learning new skills in order to remain competitive in a field that offers &lt;strong&gt;creativity and flexibility.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Overall, front-end developers are in high demand, and those who can adjust to the changing market will have many chances to succeed in the years to come.&lt;/p&gt;




&lt;p&gt;Thanks for taking the time to read this article. &lt;/p&gt;

&lt;p&gt;Stay tuned for more valuable content, and if you ever wondered why we need to learn Clean Code first? You can look at this article: &lt;a href="https://dev.to/codewithshahan/clean-code-zero-to-one-4ihk"&gt;Clean Code Zero to One&lt;/a&gt;&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>career</category>
    </item>
    <item>
      <title>10 Bulletproof Rules for Writing Clean Code 🔥</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Fri, 27 Dec 2024 15:49:32 +0000</pubDate>
      <link>https://dev.to/codewithshahan/how-to-write-clean-code-tips-for-developers-with-examples-25ic</link>
      <guid>https://dev.to/codewithshahan/how-to-write-clean-code-tips-for-developers-with-examples-25ic</guid>
      <description>&lt;p&gt;If you're in a messy room, you can’t find your &lt;em&gt;keys&lt;/em&gt;. Clothes everywhere, books &lt;em&gt;piled&lt;/em&gt; up. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycmp5iq27vz3625fv6y8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycmp5iq27vz3625fv6y8.gif" alt="messy room gif image" width="346" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That applied to messy code. It’s the SAME disaster, &lt;em&gt;except&lt;/em&gt; now it’s your brain that’s LOSING its energy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jtyh7daj5a1ejci9e10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jtyh7daj5a1ejci9e10.png" alt="Image of clean code uncle bob quote" width="500" height="600"&gt;&lt;/a&gt;&lt;br&gt;
Clean code, on the other hand, is like walking into a spotless room. Everything is exactly where it should be. No stress. No confusion. Just clarity.  &lt;/p&gt;

&lt;p&gt;Here’s the truth: writing clean code is NOT optional if you want to survive in software development. AI already writes cleaner code than you. &lt;/p&gt;

&lt;p&gt;Fortunately, as the best creation on earth, we human beings are able to master clean code. &lt;/p&gt;

&lt;p&gt;You can write messy code and be the person who struggles to fix &lt;em&gt;every&lt;/em&gt; bug, getting rejected from the job interview and failing to build a manageable startup, or you can &lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;&lt;strong&gt;master clean code&lt;/strong&gt;&lt;/a&gt; and DOMINATE &lt;em&gt;every project&lt;/em&gt; you touch.  &lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;Clean Coder vs. Messy Coder&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Here’s a graph that shows the journey of &lt;strong&gt;two types&lt;/strong&gt; of coders:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6ubf77uwipf4gtucw8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6ubf77uwipf4gtucw8q.png" alt="Image of clean code vs bad code graph chart" width="604" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;⚠️ Bad Coder (Red line):&lt;/strong&gt; Starts fast but crashes hard. The more lines they write, the more trouble they make.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;⚡ Clean Code (Blue line):&lt;/strong&gt; Starts slow but stays consistent. Growth doesn’t stop—&lt;em&gt;it accelerates.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🫵 Now, you decide &lt;strong&gt;&lt;em&gt;which line&lt;/em&gt;&lt;/strong&gt; you want to follow.&lt;/p&gt;
&lt;h3&gt;
  
  
  🐦 &lt;strong&gt;Early Bird Sells: 50% OFF&lt;/strong&gt; 🚨
&lt;/h3&gt;

&lt;p&gt;If you’re &lt;strong&gt;serious about mastering clean code&lt;/strong&gt; and taking your programming career to the next level, then this book is for you: &lt;strong&gt;&lt;em&gt;&lt;a href="https://codewithshahan.gumroad.com/l/cleancode-zero-to-one" rel="noopener noreferrer"&gt;Clean Code Zero to One&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;. I am offering &lt;strong&gt;50% discount&lt;/strong&gt; using the code &lt;strong&gt;"earlybird"&lt;/strong&gt; — only for the first 50 copies! Plus, enjoy a &lt;strong&gt;30-day money-back guarantee&lt;/strong&gt; — no risk, all reward. Or KEEP struggling with your buggy code. I can't visit your desk to fix it for you. &lt;/p&gt;
&lt;h2&gt;
  
  
  Cost of Bad Code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdai6npb55j71sguj6kl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdai6npb55j71sguj6kl.png" alt="Image of messy code graph by shahan" width="500" height="600"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
To demonstrate this chart, in the &lt;strong&gt;initial development phase&lt;/strong&gt;, bad code is &lt;em&gt;slightly&lt;/em&gt; more costly to change than clean code. &lt;/p&gt;

&lt;p&gt;However, as we move to the &lt;strong&gt;maintenance and refactoring phases&lt;/strong&gt;, the gap widens SIGNIFICANTLY, with bad code &lt;em&gt;costing nearly TWICE as much as clean code.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;By the &lt;strong&gt;legacy phase&lt;/strong&gt;, bad code reaches &lt;strong&gt;100% cost&lt;/strong&gt;, now its EXTREMELY expensive to update, while clean code remains &lt;strong&gt;more manageable at 45%.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No doubt, bad code is a COSTLY problem in software development.&lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;10 Bulletproof Rules for Writing Clean Code&lt;/strong&gt;
&lt;/h2&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;1. Use Names That Mean Something&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Naming your variables or functions &lt;em&gt;b&lt;/em&gt; or &lt;em&gt;x&lt;/em&gt; is a crime. Call them what they are.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Weak and vague&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Strong and clear&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numberOfUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;People who write unclear names DON'T want to own their mistakes. &lt;strong&gt;Don’t be that person.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;2. Keep Functions Laser-Focused (SRP)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A function should do &lt;strong&gt;one thing&lt;/strong&gt;—and do it perfectly. This is called the Single Responsibility Principle (&lt;strong&gt;SRP&lt;/strong&gt;).&lt;/p&gt;

&lt;p&gt;Good code is like a &lt;em&gt;hammer&lt;/em&gt;. It hits ONE nail, &lt;em&gt;not ten&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Clean: One job, one focus&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;logTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`User: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, Total: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Dirty: Trying to do EVERYTHING&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateAndLogTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`User: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, Total: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you mix tasks, you mix CONFUSION with disaster.  &lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;3. Silent Comments&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You don’t explain what a door does EVERY time someone walks into a room. Your code should work the same way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Clean: Self-explanatory&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;userAge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Messy: Needs an explanation&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// This means "age of the user"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Comments &lt;em&gt;aren’t bad&lt;/em&gt;, but &lt;strong&gt;if your code can’t stand on its own, you’ve already failed.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;4. Make Your Code Readable&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If someone reading your code feels like &lt;em&gt;they’re solving a riddle,&lt;/em&gt; you ALREADY became a troublemaker.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Clean: Reads like a story&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Welcome!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Please log in.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Messy: Feels like chaos&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Welcome!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Please log in.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Readable code isn’t just for others—&lt;em&gt;it’s for you six months from now.&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;5. Test Everything You Write&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you’re too lazy to write tests, DON'T complain when your code breaks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Calculator&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Test it (Unit Test)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;calculator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Calculator&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;calculator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Addition failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;calculator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Subtraction failed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Tests are your insurance policy&lt;/strong&gt;. Ignore them, and &lt;em&gt;you’re gambling with your time.&lt;/em&gt;  &lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;6. Beware of Dependencies&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Dependencies are like DEALS. Get the RIGHT ones, and you WIN. Choose badly, and you’re &lt;em&gt;locked&lt;/em&gt; into something you’ll regret.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Dependency: Sending emails with Nodemailer&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nodemailer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;nodemailer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sendEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transporter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;nodemailer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createTransport&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="cm"&gt;/* config */&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;transporter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendMail&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;you@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Avoid hardcoding dependencies. Use &lt;strong&gt;abstraction&lt;/strong&gt; or &lt;strong&gt;configuration files&lt;/strong&gt; for secure maintenance.&lt;/p&gt;

&lt;p&gt;This is just one example. As a developer, you may use HUNDREDS of libraries or dependencies. &lt;/p&gt;

&lt;p&gt;I am not saying you should not rely on them, nowadays it is hard to avoid them. But you should be very careful BEFORE installing them in your coding projects. &lt;/p&gt;

&lt;p&gt;You should check the security, performance, quality or functionality of an organization's software systems. Because &lt;strong&gt;they sometimes contain risks that can ruin your ENTIRE project.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Always CONTROL your tools, don't let them control YOU.  &lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;7. Organize Project Like a Boss&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A well-organized project is the difference &lt;em&gt;between&lt;/em&gt; a &lt;strong&gt;garage sale&lt;/strong&gt; and a &lt;em&gt;high-end&lt;/em&gt; &lt;strong&gt;boutique&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here is how EACH folder should be organized:&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9xwyg9iqqcybz21lsgxz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9xwyg9iqqcybz21lsgxz.png" alt="Image of clean code project structure by shahan" width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your codebase looks like a junk drawer, you’ve already lost the respect of your &lt;em&gt;future self.&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An Email App's Clean Project Structure:&lt;/strong&gt;&lt;br&gt;
Let's say you are building an application that sends emails to users. Your clean project structure should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6v6rlc5qiplgxz1h4dps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6v6rlc5qiplgxz1h4dps.png" alt="Image of email app clean code project structure by shahan" width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  &lt;strong&gt;8. Be Consistent with Formatting&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Don’t code like a person with 10 personalities. Be consistent with your formatting.  &lt;/p&gt;

&lt;p&gt;Use tools like &lt;a href="https://prettier.io/" rel="noopener noreferrer"&gt;Prettier&lt;/a&gt; or &lt;a href="https://eslint.org/" rel="noopener noreferrer"&gt;ESLint&lt;/a&gt; to enforce your CONSISTENT style. If every file looks different, you’re creating chaos that NO ONE wants to fix.  &lt;/p&gt;

&lt;p&gt;I would say, consistency in formatting is one of the most important aspects of clean coding.&lt;/p&gt;

&lt;p&gt;Have a look...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46zu4k5nnrkcdesgqrye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46zu4k5nnrkcdesgqrye.png" alt="Image of consistent formatting snippets from clean code zero to one book" width="800" height="960"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use &lt;em&gt;2 or 4 spaces&lt;/em&gt; for &lt;strong&gt;indentation&lt;/strong&gt; consistently throughout your codebase. &lt;em&gt;Avoid tabs&lt;/em&gt; to maintain &lt;strong&gt;uniformity&lt;/strong&gt; across different editors.&lt;/p&gt;

&lt;p&gt;Keep lines to a &lt;em&gt;maximum of 100-120 characters&lt;/em&gt; to prevent &lt;strong&gt;horizontal scrolling&lt;/strong&gt; and improve readability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Group related logic&lt;/strong&gt; &lt;em&gt;together&lt;/em&gt; and &lt;strong&gt;separate blocks&lt;/strong&gt; of code with &lt;em&gt;blank lines&lt;/em&gt; to &lt;em&gt;highlight&lt;/em&gt; their purpose.&lt;/p&gt;

&lt;p&gt;Finally, &lt;strong&gt;avoid over-aligning code&lt;/strong&gt;; instead, let &lt;strong&gt;indentation&lt;/strong&gt; naturally guide the flow of logic.&lt;/p&gt;


&lt;h3&gt;
  
  
  &lt;strong&gt;9. Stop Hardcoding Values&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Hardcoding is laziness disguised as effort.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Bad: Hardcoded and rigid&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;maxUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentUsers&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;maxUsers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Too many users!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Clean: Dynamic and flexible&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MAX_USERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentUsers&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;MAX_USERS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Too many users!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, avoid it at all costs. Hardcoding is the &lt;em&gt;shortcut&lt;/em&gt; that sends you &lt;em&gt;off&lt;/em&gt; a cliff.  &lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;10. Keep Functions Short&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If your function is &lt;strong&gt;&lt;em&gt;longer than 20 lines&lt;/em&gt;&lt;/strong&gt;, it’s probably &lt;em&gt;trying to do too much.&lt;/em&gt; Break it down.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;updateCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;addItemToCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;logTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addItemToCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Short functions are &lt;em&gt;sharp&lt;/em&gt; functions. &lt;strong&gt;They hit their mark EVERY time.&lt;/strong&gt;  &lt;/p&gt;




&lt;p&gt;Read more: &lt;a href="https://dev.to/codewithshahan/writing-clean-reusable-components-in-react-best-practices-2gka"&gt;writing clean, reusable components in React&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Master the art of programming!</title>
      <dc:creator>Programming with Shahan</dc:creator>
      <pubDate>Thu, 26 Dec 2024 09:17:45 +0000</pubDate>
      <link>https://dev.to/codewithshahan/master-the-art-of-programming-6cp</link>
      <guid>https://dev.to/codewithshahan/master-the-art-of-programming-6cp</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/codewithshahan/clean-code-zero-to-one-4ihk" class="crayons-story__hidden-navigation-link"&gt;Clean Code Zero to One&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/codewithshahan" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F643041%2F4bf2d91a-2cc2-4670-88b3-9183a0435fdd.png" alt="codewithshahan profile" class="crayons-avatar__image" width="800" height="800"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/codewithshahan" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Programming with Shahan
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Programming with Shahan
                
              
              &lt;div id="story-author-preview-content-2175285" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/codewithshahan" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F643041%2F4bf2d91a-2cc2-4670-88b3-9183a0435fdd.png" class="crayons-avatar__image" alt="" width="800" height="800"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Programming with Shahan&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/codewithshahan/clean-code-zero-to-one-4ihk" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Dec 26 '24&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/codewithshahan/clean-code-zero-to-one-4ihk" id="article-link-2175285"&gt;
          Clean Code Zero to One
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/webdev"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;webdev&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/programming"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;programming&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/beginners"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;beginners&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/codewithshahan/clean-code-zero-to-one-4ihk" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;64&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/codewithshahan/clean-code-zero-to-one-4ihk#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              8&lt;span class="hidden s:inline"&gt; comments&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
  </channel>
</rss>
