<?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>Forem: Gaurav Dalvi</title>
    <description>The latest articles on Forem by Gaurav Dalvi (@gauravdalvi).</description>
    <link>https://forem.com/gauravdalvi</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%2F745679%2F72c64a97-9655-46bc-b948-67da4a26c7fa.jpeg</url>
      <title>Forem: Gaurav Dalvi</title>
      <link>https://forem.com/gauravdalvi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gauravdalvi"/>
    <language>en</language>
    <item>
      <title>Git Hooks — The Developer's Silent Sidekick</title>
      <dc:creator>Gaurav Dalvi</dc:creator>
      <pubDate>Fri, 18 Apr 2025 13:00:00 +0000</pubDate>
      <link>https://forem.com/gauravdalvi/git-hooks-the-developers-silent-sidekick-1obe</link>
      <guid>https://forem.com/gauravdalvi/git-hooks-the-developers-silent-sidekick-1obe</guid>
      <description>&lt;p&gt;You know that gut-punch feeling when you push broken code, forget to run tests, or write a commit message so vague it could be the title of a Christopher Nolan film?&lt;/p&gt;

&lt;p&gt;Yep. Been there, done that.&lt;/p&gt;

&lt;p&gt;But what if I told you Git can &lt;em&gt;automate&lt;/em&gt; that slap-on-the-wrist your tech lead usually gives you during code review?&lt;/p&gt;

&lt;p&gt;Meet &lt;strong&gt;Git Hooks&lt;/strong&gt; — your silent sidekick for clean commits, consistent messages, and fewer "oops" moments.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 What Are Git Hooks?
&lt;/h2&gt;

&lt;p&gt;Git hooks are executable scripts that Git runs before or after certain events like commits, pushes, merges, rebases, and more. Think of them as little robot assistants standing guard over your version control flow.&lt;/p&gt;

&lt;p&gt;They live in this path (by default):&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;...and are disabled until you make them executable and give them real jobs.&lt;/p&gt;




&lt;h2&gt;
  
  
  🦸‍♂️ Why Should You Care?
&lt;/h2&gt;

&lt;p&gt;Let’s be honest: we're all human.&lt;/p&gt;

&lt;p&gt;We forget to run tests.&lt;/p&gt;

&lt;p&gt;We commit &lt;code&gt;debug.log&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We write commit messages like &lt;code&gt;fix stuff&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Git hooks automate the "are-you-sure" part of development — catching mistakes &lt;em&gt;before&lt;/em&gt; they hit the repo.&lt;/p&gt;

&lt;p&gt;Now, let me show you the ones you're actually likely to use in real life — the ones that save developers from daily embarrassment.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 &lt;code&gt;pre-commit&lt;/code&gt; — &lt;em&gt;Stop Bad Code Before It Happens&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;When it runs:&lt;/strong&gt; Before a commit is finalized.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it's useful:&lt;/strong&gt;&lt;br&gt;
Block broken, unformatted, or careless code from entering your repo. Consider this your first line of defense.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Lint your code before committing&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;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Linting your code..."&lt;/span&gt;
npm run lint
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$?&lt;/span&gt; &lt;span class="nt"&gt;-ne&lt;/span&gt; 0 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"❌ Linting failed! Fix errors before committing."&lt;/span&gt;
  &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📌 Save this in &lt;code&gt;.git/hooks/pre-commit&lt;/code&gt; and make it executable:&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;h2&gt;
  
  
  💡 &lt;code&gt;commit-msg&lt;/code&gt; — &lt;em&gt;Enforce Commit Message Discipline&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;When it runs:&lt;/strong&gt; After you write your commit message, before the commit is saved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it's useful:&lt;/strong&gt;&lt;br&gt;
Protects your repo from cryptic, non-informative commit messages like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;misc changes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example: Enforce Conventional Commits&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;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="nv"&gt;message&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;pattern&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"^(feat|fix|chore|docs|style|refactor|test|perf|ci|build|revert)(&lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="s2"&gt;.+&lt;/span&gt;&lt;span class="se"&gt;\)&lt;/span&gt;&lt;span class="s2"&gt;)?: .{1,50}"&lt;/span&gt;

&lt;span class="k"&gt;if&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;"&lt;/span&gt;&lt;span class="nv"&gt;$message&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-qE&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$pattern&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"❌ Invalid commit message!"&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"✅ Format should be: feat(scope): description"&lt;/span&gt;
  &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  💡 &lt;code&gt;pre-push&lt;/code&gt; — &lt;em&gt;The Final Defense Line&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;When it runs:&lt;/strong&gt; Before your code is pushed to the remote.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it's useful:&lt;/strong&gt;&lt;br&gt;
Ensure tests pass or builds are successful before anyone else gets your code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Run tests before push&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;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Running tests before push..."&lt;/span&gt;
npm &lt;span class="nb"&gt;test
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$?&lt;/span&gt; &lt;span class="nt"&gt;-ne&lt;/span&gt; 0 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"❌ Tests failed! Push aborted."&lt;/span&gt;
  &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  💡 &lt;code&gt;post-merge&lt;/code&gt; — &lt;em&gt;Sync After Merging&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;When it runs:&lt;/strong&gt; After a &lt;code&gt;git merge&lt;/code&gt; completes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it's useful:&lt;/strong&gt;&lt;br&gt;
Prevent those "works on my machine" moments after pulling changes that added new dependencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Auto-install dependencies if &lt;code&gt;package.json&lt;/code&gt; changed&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;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;git diff-tree &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nt"&gt;--name-only&lt;/span&gt; &lt;span class="nt"&gt;--no-commit-id&lt;/span&gt; ORIG_HEAD HEAD | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s2"&gt;"package.json"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"package.json changed — running npm install..."&lt;/span&gt;
  npm &lt;span class="nb"&gt;install
&lt;/span&gt;&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  💡 &lt;code&gt;post-checkout&lt;/code&gt; — &lt;em&gt;Welcome to Your New Branch&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;When it runs:&lt;/strong&gt; Every time you checkout a branch or commit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it's useful:&lt;/strong&gt;&lt;br&gt;
Automatically reset environment configs or remind yourself which branch you're on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Notify current branch&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;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="nv"&gt;branch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git rev-parse &lt;span class="nt"&gt;--abbrev-ref&lt;/span&gt; HEAD&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"✅ You're now on branch: &lt;/span&gt;&lt;span class="nv"&gt;$branch&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📚 Other Git Hooks You Should Know (But Use When Needed)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Hook Name&lt;/th&gt;
&lt;th&gt;Purpose &amp;amp; When It Runs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;applypatch-msg&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Before applying a patch with &lt;code&gt;git am&lt;/code&gt;. Validate commit messages in patches.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pre-applypatch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Before a patch is applied. Often used for prep steps.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;post-applypatch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;After a patch is applied. Good for notifications or rebuilds.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;prepare-commit-msg&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Modify auto-generated commit messages (e.g., squash, merge templates).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;post-commit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;After a commit completes. Log events or trigger notifications.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pre-rebase&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Before a rebase starts. Block protected branches or warn users.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pre-merge-commit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Before a merge commit is created. Validate merge intentions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pre-auto-gc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Before Git performs automatic garbage collection.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;post-rewrite&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;After rewriting commits via rebase or amend. Useful for cleanup.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🔗 How to Share Hooks Across Teams?
&lt;/h2&gt;

&lt;p&gt;Git doesn’t track &lt;code&gt;.git/hooks&lt;/code&gt; (by design) — so if you want team-wide consistency, you have two main solutions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Husky&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Perfect for JavaScript/TypeScript projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hooks are stored inside your version-controlled codebase.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy to set up with &lt;strong&gt;npx husky install&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Lefthook&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Language-agnostic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Great for teams working across different stacks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Centralizes hooks under version control.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Git Hooks won't write better code for you — but they &lt;em&gt;will&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Save you from human error.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make you look like the professional you pretend to be on LinkedIn.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep your team's history clean and consistent.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;pre-commit&lt;/code&gt; for code quality.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;commit-msg&lt;/code&gt; for consistent commit messages.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pre-push&lt;/code&gt; for last-minute sanity checks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And watch how your workflow instantly levels up.&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>cleancode</category>
      <category>programming</category>
    </item>
    <item>
      <title>Essential Linux Commands Every Developer Should Master</title>
      <dc:creator>Gaurav Dalvi</dc:creator>
      <pubDate>Thu, 17 Apr 2025 13:00:00 +0000</pubDate>
      <link>https://forem.com/gauravdalvi/essential-linux-commands-every-developer-should-master-232f</link>
      <guid>https://forem.com/gauravdalvi/essential-linux-commands-every-developer-should-master-232f</guid>
      <description>&lt;p&gt;Let’s face it: if you're writing code and not using Linux (or at least the terminal), you’re missing out on half the developer experience — the half where you actually feel like a hacker from a ‘90s movie.&lt;/p&gt;

&lt;p&gt;Whether you’re deploying, debugging, or just flexing in front of your coworkers, these Linux commands are essential tools in your utility belt.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 pwd — Print Working Directory
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Translation:&lt;/strong&gt; “Where the heck am I?”&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;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This one tells you your current location in the filesystem jungle. Like GPS, but for your terminal.&lt;/p&gt;




&lt;h2&gt;
  
  
  📂 ls — List Directory Contents
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Translation:&lt;/strong&gt; “Show me what’s in this folder.”&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;ls
ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add &lt;code&gt;-l&lt;/code&gt; for detailed info and &lt;code&gt;-a&lt;/code&gt; to uncover hidden treasures (&lt;code&gt;.env&lt;/code&gt;, &lt;code&gt;.git&lt;/code&gt;, &lt;code&gt;.Iforgotaboutthis&lt;/code&gt;).&lt;/p&gt;




&lt;h2&gt;
  
  
  🚪 cd — Change Directory
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Translation:&lt;/strong&gt; “Get me out of here.”&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;cd&lt;/span&gt; /path/to/destination
&lt;span class="nb"&gt;cd&lt;/span&gt; ~  &lt;span class="c"&gt;# Go to home&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; -  &lt;span class="c"&gt;# Go back&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Essential for moving around like a pro instead of exiting the terminal and opening File Explorer like a peasant.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔥 rm — Remove Files or Directories
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Translation:&lt;/strong&gt; “Delete like you mean 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;rm &lt;/span&gt;file.txt
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; folder/
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; /  &lt;span class="c"&gt;# Don’t. Ever.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-r&lt;/code&gt; flag removes folders recursively. &lt;code&gt;-f&lt;/code&gt; makes it ruthless. Combining both is like giving your terminal a bazooka.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧹 mkdir &amp;amp; rmdir — Make / Remove Directory
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;new_folder
&lt;span class="nb"&gt;rmdir &lt;/span&gt;old_folder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simple yet essential. &lt;code&gt;mkdir -p&lt;/code&gt; even creates nested directories like a boss:&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;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; projects/nextjs/my-awesome-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📝 touch — Create an Empty File
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;newfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No need to open VS Code just to create a file. &lt;code&gt;touch&lt;/code&gt; and go!&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 grep — Search Through Files
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Translation:&lt;/strong&gt; “Ctrl + F for the terminal.”&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;grep&lt;/span&gt; &lt;span class="s1"&gt;'TODO'&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Search for specific text patterns. Super useful when your codebase has more bugs than features.&lt;/p&gt;




&lt;h2&gt;
  
  
  🪓 chmod — Change File Permissions
&lt;/h2&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 script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Grants execution rights. Because not all heroes wear capes; some just need the right permissions.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏃 ./ — Run Executables
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./myscript.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you wrote a script but the terminal says “permission denied,” check your &lt;code&gt;chmod&lt;/code&gt; (see above). Once executable, this is how you run it.&lt;/p&gt;




&lt;h2&gt;
  
  
  🦸 sudo — SuperUser Do
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Translation:&lt;/strong&gt; “I know what I’m doing... probably.”&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;sudo &lt;/span&gt;apt-get update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Gives you superpowers. Use wisely, or you might brick your OS and end up spending the weekend reinstalling Linux.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌐 curl — Transfer Data from URLs
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.example.com/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Download files, test APIs, or pretend you're working on your terminal when you're actually sending cat GIFs.&lt;/p&gt;




&lt;h2&gt;
  
  
  💣 kill &amp;amp; killall — Stop Processes
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;kill&lt;/span&gt; &amp;lt;PID&amp;gt;
killall node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When &lt;code&gt;Ctrl + C&lt;/code&gt; just isn’t enough, &lt;code&gt;kill&lt;/code&gt; is the polite way to ask processes to die. &lt;code&gt;killall&lt;/code&gt;... well, does what the name says.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧪 top / htop — Monitor Processes
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;top
htop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Real-time view of CPU and memory usage. &lt;code&gt;htop&lt;/code&gt; is the cool, colorful cousin of &lt;code&gt;top&lt;/code&gt;. Install it, thank me later.&lt;/p&gt;




&lt;h2&gt;
  
  
  📦 tar — Archive and Extract Files
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-czvf&lt;/span&gt; archive.tar.gz folder/
&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-xzvf&lt;/span&gt; archive.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because zipping and unzipping files shouldn’t require dragging anything.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧾 man — Manual Pages
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lost? Confused? Broken? Type &lt;code&gt;man&lt;/code&gt; + command and let the terminal's ancient wisdom guide you.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Learning Linux commands is like learning to cook. At first, you’ll burn a lot of files (&lt;code&gt;rm -rf&lt;/code&gt;) and confuse &lt;code&gt;cd&lt;/code&gt; with &lt;code&gt;mkdir&lt;/code&gt;, but once you’re comfortable, you’ll be able to whip up deployments, debug servers, and automate tasks like a chef plating Michelin-star code.&lt;/p&gt;

&lt;p&gt;So, stop Googling “How to delete file Linux” and start memorizing the essentials.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>cli</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Write Code Like A Pro: Mastering The SOLID Principles</title>
      <dc:creator>Gaurav Dalvi</dc:creator>
      <pubDate>Wed, 16 Apr 2025 13:00:00 +0000</pubDate>
      <link>https://forem.com/gauravdalvi/write-code-like-a-pro-mastering-the-solid-principles-e8</link>
      <guid>https://forem.com/gauravdalvi/write-code-like-a-pro-mastering-the-solid-principles-e8</guid>
      <description>&lt;p&gt;If you're a developer, you've probably heard whispers of this ancient wisdom in code reviews, design docs, or the hushed conversations between two senior devs in the corner of your office:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"You should follow SOLID principles."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But what exactly are these? Some kind of secret cult? A new JavaScript framework? Fear not — SOLID is simply an acronym, and one of the best blueprints for writing maintainable, scalable, and... non-disaster-prone code.&lt;/p&gt;

&lt;p&gt;Let’s break it down, with some real-world humor sprinkled in.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 S — Single Responsibility Principle (SRP)
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"One class, one reason to change."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world analogy:&lt;/strong&gt;&lt;br&gt;
Imagine you hired a plumber to fix your sink, and halfway through the job, he starts giving you a lecture on tax planning. That’s what violating SRP feels like in code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code example:&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserManager&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;deleteUser&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;generateUserReport&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// 🚨 Mixing concerns!&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserManager&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;deleteUser&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&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 java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserReportGenerator&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;generateUserReport&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each class now does one job. Fewer surprise side effects, fewer headaches.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 O — Open/Closed Principle (OCP)
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"Software entities should be open for extension, but closed for modification."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world analogy:&lt;/strong&gt;&lt;br&gt;
When your phone gets a new feature, you install an app. You don’t break out a screwdriver and start rewiring the motherboard. Your code should work the same way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code example:&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NotificationService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Email"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* send email */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SMS"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* send SMS */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;NotificationSender&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;EmailSender&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;NotificationSender&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* send email */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SMSSender&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;NotificationSender&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* send SMS */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NotificationService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;NotificationSender&lt;/span&gt; &lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;NotificationService&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;NotificationSender&lt;/span&gt; &lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sender&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;notify&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;New types? Just add a new class. Your core logic stays untouched, stress levels stay low.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 L — Liskov Substitution Principle (LSP)
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"Objects of a superclass should be replaceable with objects of its subclasses without affecting correctness."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world analogy:&lt;/strong&gt;&lt;br&gt;
If you rent a car, you expect to drive it — whether it’s a sedan, SUV, or convertible. If the rental company handed you a boat with wheels, you'd be furious.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code example:&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Bird&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;fly&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* flying logic */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Penguin&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Bird&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;fly&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&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="nf"&gt;UnsupportedOperationException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Penguins can't fly!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Better:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Bird&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;FlyingBird&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Bird&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;fly&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Sparrow&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;FlyingBird&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* eat */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;fly&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* fly */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Penguin&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Bird&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* eat */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now penguins aren’t pretending to be something they’re not. Less deception, fewer exceptions.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 I — Interface Segregation Principle (ISP)
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"No client should be forced to depend on methods it does not use."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world analogy:&lt;/strong&gt;&lt;br&gt;
Ordering a coffee and getting a full 10-course meal, whether you asked for it or not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code example:&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Robot&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* working... */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ??? Robots don't eat! */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Better:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Workable&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Eatable&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Human&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Workable&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Eatable&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* work */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* eat */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Robot&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Workable&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* work */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now each class only implements what it actually needs. Simple. Clean. Logical.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 D — Dependency Inversion Principle (DIP)
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;"Depend on abstractions, not on concretions."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world analogy:&lt;/strong&gt;&lt;br&gt;
If your smartphone was hard-wired to only work with one charger brand, you’d riot. Thankfully, it uses USB or wireless — an abstraction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code example:&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserRepository&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt; &lt;span class="n"&gt;db&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;MySQLDatabase&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;saveUser&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;connect&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt; &lt;span class="cm"&gt;/* save logic */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserRepository&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;UserRepository&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Database&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;saveUser&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;connect&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt; &lt;span class="cm"&gt;/* save logic */&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can swap databases like changing socks. Dependency injection = freedom.&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Wrapping Up
&lt;/h2&gt;

&lt;p&gt;SOLID principles are like traffic rules for your code. They won’t stop you from writing spaghetti, but they’ll give you the map to a much safer, maintainable, and scalable design.&lt;/p&gt;

&lt;p&gt;If you start noticing that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;your classes are doing too many things,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;adding a new feature breaks four others,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;or your code makes you want to fake your own death and start a new identity...&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...chances are, you're breaking one (or more) SOLID principles.&lt;/p&gt;

&lt;p&gt;Stick to them and your future self — and your teammates — will silently thank you.&lt;/p&gt;

</description>
      <category>java</category>
      <category>cleancode</category>
      <category>solidprinciples</category>
      <category>programming</category>
    </item>
    <item>
      <title>Microservices: Because Monoliths Are So 2009</title>
      <dc:creator>Gaurav Dalvi</dc:creator>
      <pubDate>Tue, 15 Apr 2025 13:00:00 +0000</pubDate>
      <link>https://forem.com/gauravdalvi/microservices-because-monoliths-are-so-2009-5le</link>
      <guid>https://forem.com/gauravdalvi/microservices-because-monoliths-are-so-2009-5le</guid>
      <description>&lt;p&gt;If you’ve ever stared at a 10,000-line &lt;code&gt;App.java&lt;/code&gt; file and whispered to yourself, &lt;em&gt;“There has to be a better way…”&lt;/em&gt; — congratulations, you’ve unlocked the microservices chapter of your developer journey.&lt;/p&gt;

&lt;p&gt;Welcome to the distributed spaghetti buffet 🍝 — where every service is its own restaurant, with its own chef, ingredients, and occasionally, its own plumbing problems.&lt;/p&gt;

&lt;p&gt;Let’s dig into microservices: why they exist, how to not mess them up, and what they &lt;em&gt;don’t&lt;/em&gt; tell you in the Netflix tech blog.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧐 Why Microservices?
&lt;/h2&gt;

&lt;p&gt;Because &lt;em&gt;"it worked on my machine"&lt;/em&gt; doesn't scale.&lt;/p&gt;

&lt;p&gt;Microservices break your application into independently deployable, loosely coupled services — each responsible for a specific piece of functionality. Think: auth service, order service, notification service, and maybe that one weird analytics service you inherited from an intern in 2018. Yes, it still works. No one knows how.&lt;/p&gt;

&lt;p&gt;In theory, this means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Smaller codebases = easier to understand and test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Teams can work in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can deploy just what changed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tech stack freedom per service.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice, this means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You’ve got 15 Git repos, 17 CI/CD pipelines, and 25 different opinions on which API gateway to use.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧩 Design Principles: Or How to Avoid a Distributed Disaster
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Single Responsibility, Not Single Line of Code
&lt;/h3&gt;

&lt;p&gt;Every microservice should have a &lt;strong&gt;single business capability&lt;/strong&gt;. If your “user-service” also handles emails, payments, and the office coffee machine, you’re doing it wrong. That’s not a service — it’s a Frankenstein.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Data Isolation: No Peeking!
&lt;/h3&gt;

&lt;p&gt;Each service should own its own data. Yes, it feels wasteful to duplicate some data. Yes, it leads to eventual consistency. But it also avoids the &lt;em&gt;“why did deleting a user break inventory?”&lt;/em&gt; conversations.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pro tip: Embrace the chaos. Eventual consistency is a feature, not a bug. Just like Kubernetes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3. Communication: Choose Your Weapons Wisely
&lt;/h3&gt;

&lt;p&gt;Synchronous (REST, gRPC): Easy, familiar, but brittle. Asynchronous (Kafka, RabbitMQ): Resilient, scalable, but welcome to the debugging dark forest.&lt;/p&gt;

&lt;p&gt;Use sync when you need immediate response. Use async when you want to sleep at night.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Tooling You’ll Actually Use
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;API Gateway&lt;/strong&gt; – NGINX, Kong, or just a tired Node.js app pretending it’s not a monolith.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Service Discovery&lt;/strong&gt; – Consul, Eureka, or writing service names on Post-its and hoping for the best.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Observability&lt;/strong&gt; – Jaeger + Prometheus + Grafana. Or just a lot of &lt;code&gt;console.log&lt;/code&gt;. No judgment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CI/CD&lt;/strong&gt; – GitHub Actions, Jenkins, or that one Bash script nobody wants to touch.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔥 Common Pitfalls (and How to Avoid Them)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Too Many Services, Too Soon
&lt;/h3&gt;

&lt;p&gt;Just because you &lt;em&gt;can&lt;/em&gt; split everything into services doesn’t mean you &lt;em&gt;should&lt;/em&gt;. Start with a modular monolith and break off services when needed. Otherwise, you’ll spend more time wiring things than building features.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Distributed Monolith
&lt;/h3&gt;

&lt;p&gt;If your services can’t function independently and deployments must happen in lockstep — congrats, you just recreated a monolith with extra steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Ignoring Observability
&lt;/h3&gt;

&lt;p&gt;If you don’t know what your services are doing, who they’re talking to, or how they’re failing — you’re driving blindfolded. At night. In production.&lt;/p&gt;




&lt;h2&gt;
  
  
  💬 Real Talk: Do You Even Need Microservices?
&lt;/h2&gt;

&lt;p&gt;If your team is fewer than 5 devs, your product’s still pivoting, or your infra budget is “whatever’s free on Heroku,” then &lt;strong&gt;no&lt;/strong&gt; — you probably don’t need microservices right now.&lt;/p&gt;

&lt;p&gt;Start simple. Scale complexity only when you &lt;em&gt;must&lt;/em&gt;. Complexity is a cost — not a badge of honor.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Final Thoughts: Herding Cats, One Service at a Time
&lt;/h2&gt;

&lt;p&gt;Microservices are not a silver bullet. They’re more like a box of sharp knives — incredibly useful, but also capable of cutting you if you’re not careful.&lt;/p&gt;

&lt;p&gt;If done right, they offer scalability, team autonomy, and faster iteration.&lt;/p&gt;

&lt;p&gt;If done wrong, well… let’s just say I hope you enjoy reading 400-line stack traces that jump across five services.&lt;/p&gt;

&lt;p&gt;Thanks for reading — may your services stay stateless, your queues stay unblocked, and your deployments stay drama-free. 💥&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>networking</category>
      <category>api</category>
      <category>node</category>
    </item>
    <item>
      <title>JavaScript’s Event Loop — Explained Like You're Five (But With More Sarcasm)</title>
      <dc:creator>Gaurav Dalvi</dc:creator>
      <pubDate>Mon, 14 Apr 2025 13:00:00 +0000</pubDate>
      <link>https://forem.com/gauravdalvi/javascripts-event-loop-explained-like-youre-five-but-with-more-sarcasm-3bie</link>
      <guid>https://forem.com/gauravdalvi/javascripts-event-loop-explained-like-youre-five-but-with-more-sarcasm-3bie</guid>
      <description>&lt;h2&gt;
  
  
  🧠 First, a Little Brain Primer: JavaScript Is Single-Threaded
&lt;/h2&gt;

&lt;p&gt;Imagine JavaScript as a cook in a small kitchen with one burner. That’s right, it can only cook &lt;strong&gt;one dish at a time&lt;/strong&gt;. If you ask it to make toast, brew coffee, and flip pancakes, it has to &lt;strong&gt;queue those tasks&lt;/strong&gt;. Multitasking? Pfft. JavaScript is more of a "brb, doing this one thing first" kinda guy.&lt;/p&gt;

&lt;p&gt;But... JavaScript is weirdly fast, and can handle lots of tasks at once — or so it seems. The trick? It's all about &lt;strong&gt;asynchronous operations&lt;/strong&gt; and the &lt;strong&gt;event loop&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗️ Stack, Queue, and Web APIs — The Cast of Characters
&lt;/h2&gt;

&lt;p&gt;Before we talk about the Event Loop itself, let’s meet the team:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Call Stack (a.k.a. “The Do-Right-Now Zone”)
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Call Stack&lt;/strong&gt; is where functions go to get executed. It’s LIFO (Last In, First Out) — think of it as a stack of pancakes, where the last one you put on is the first one you eat. Yum.&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;sayHi&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;Hi!&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;sayHi&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Goes on the stack, gets executed, gets popped off.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Easy peasy. But what if we add:&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="nf"&gt;setTimeout&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;Hello after 0ms&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="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hold on... &lt;strong&gt;0ms?!&lt;/strong&gt; That should run immediately, right?&lt;/p&gt;

&lt;p&gt;Wrong. This is where &lt;strong&gt;Web APIs&lt;/strong&gt; and the &lt;strong&gt;Event Loop&lt;/strong&gt; pull off their little magic trick.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Web APIs (a.k.a. “The Outsourcing Department”)
&lt;/h3&gt;

&lt;p&gt;When you use &lt;code&gt;setTimeout&lt;/code&gt;, &lt;code&gt;fetch&lt;/code&gt;, or DOM events, you’re not dealing with core JavaScript anymore. These are &lt;strong&gt;browser-provided APIs&lt;/strong&gt; (also available in Node.js through different means). JavaScript offloads tasks to them — like giving your assistant a to-do list and going back to binge Netflix (or run more code).&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Callback Queue (Task Queue) (a.k.a. “The Waiting Room”)
&lt;/h3&gt;

&lt;p&gt;Once the Web APIs finish their job — say, your timer is up — they dump the callback into the &lt;strong&gt;Callback Queue&lt;/strong&gt;, where it patiently waits to be noticed by the Event Loop like an intern waving for coffee orders.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔁 Enter the Event Loop
&lt;/h2&gt;

&lt;p&gt;Imagine a tiny robot constantly checking:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;“Is the Call Stack empty?”&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Yes: “Cool, I’ll grab the next thing from the Callback Queue.”&lt;/li&gt;
&lt;li&gt;❌ No: “I’ll chill for a bit. Let the stack do its thing.”&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;That’s the &lt;strong&gt;Event Loop&lt;/strong&gt;. It’s a bouncer at an exclusive club (the call stack), letting in callbacks only when there’s room.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔬 Let’s Visualize It (in Code)
&lt;/h2&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;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;Start&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;setTimeout&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;Timeout callback&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="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&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;Promise microtask&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;End&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;Output?&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;Start
End
Promise microtask
Timeout callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Wait, WHAT? Isn’t 0ms faster than a promise?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ah, my young padawan, welcome to the dark arts of the &lt;strong&gt;Microtask Queue&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ Microtasks vs. Macrotasks: The Plot Thickens
&lt;/h2&gt;

&lt;p&gt;There’s &lt;strong&gt;another&lt;/strong&gt; queue: the &lt;strong&gt;Microtask Queue&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Microtasks include: &lt;code&gt;Promise.then&lt;/code&gt;, &lt;code&gt;queueMicrotask&lt;/code&gt;, and &lt;code&gt;MutationObserver&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Macrotasks (aka regular tasks) include: &lt;code&gt;setTimeout&lt;/code&gt;, &lt;code&gt;setInterval&lt;/code&gt;, I/O events.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After &lt;strong&gt;each&lt;/strong&gt; turn of the event loop, the engine:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Executes all microtasks 🧠&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then checks the callback queue 🧾&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So in our code above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stack runs &lt;code&gt;console.log("Start")&lt;/code&gt; and &lt;code&gt;"End"&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then microtasks run: &lt;code&gt;"Promise microtask"&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;THEN the timeout callback: &lt;code&gt;"Timeout callback"&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The event loop is like: “Okay, before I do anything else, let me finish these tiny tasks. Then I’ll get to the big stuff.”&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 So Why Does Any of This Matter?
&lt;/h2&gt;

&lt;p&gt;Because &lt;strong&gt;understanding the event loop saves lives&lt;/strong&gt; (okay, maybe just your sanity). Here’s when it’s crucial:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Preventing &lt;strong&gt;UI freezing&lt;/strong&gt; (e.g. when you block the main thread).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Writing &lt;strong&gt;efficient async code&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Debugging weird issues where code doesn’t run in the order you expect.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoiding 3 AM existential crises caused by &lt;code&gt;setTimeout(..., 0)&lt;/code&gt; not running “immediately.”&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧪 Bonus: Block the Stack and See the Chaos
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;setTimeout&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;I'm late!&lt;/span&gt;&lt;span class="dl"&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="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="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;e9&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="c1"&gt;// Block the stack&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;Done blocking&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;Even though the timer says "0ms", it runs &lt;strong&gt;after the big loop&lt;/strong&gt; finishes. Why? Because the &lt;strong&gt;call stack&lt;/strong&gt; was busy — the Event Loop couldn't slip anything in.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 TL;DR (Too Long; Debugged Recently)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;JavaScript runs in a &lt;strong&gt;single-threaded&lt;/strong&gt; event loop model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;Call Stack&lt;/strong&gt; runs code line by line.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Async tasks go to &lt;strong&gt;Web APIs&lt;/strong&gt;, then to the &lt;strong&gt;Callback Queue&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;Event Loop&lt;/strong&gt; adds them to the stack &lt;strong&gt;only when it's empty&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Microtasks&lt;/strong&gt; (like Promises) get priority over normal tasks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Blocking the main thread blocks everything — avoid it like pineapple on pizza (unless you're into that).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Understanding the Event Loop is like knowing how the magician pulls off the trick. It doesn’t make the show any less fun — but it &lt;em&gt;does&lt;/em&gt; make you better at building the show.&lt;/p&gt;

&lt;p&gt;Now go forth and write better asynchronous code — and maybe tell &lt;code&gt;setTimeout&lt;/code&gt; to chill once in a while.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How Does the Internet Work? (A.k.a. The Most Epic Game of Digital Hide and Seek)</title>
      <dc:creator>Gaurav Dalvi</dc:creator>
      <pubDate>Sun, 13 Apr 2025 15:00:00 +0000</pubDate>
      <link>https://forem.com/gauravdalvi/how-does-the-internet-work-aka-the-most-epic-game-of-digital-hide-and-seek-14j2</link>
      <guid>https://forem.com/gauravdalvi/how-does-the-internet-work-aka-the-most-epic-game-of-digital-hide-and-seek-14j2</guid>
      <description>&lt;p&gt;Let’s be honest: the internet feels like magic. You type in “how to cook Maggi in 2 minutes” (even though we all know it takes at least 5), and boom — millions of answers appear instantly. But have you ever stopped mid-scroll and wondered:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does this wizardry even work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don’t worry, I’ve got you covered. By the end of this post, you’ll know how your memes travel across the globe and what’s really happening behind those cat videos buffering.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Step 1: It All Starts With a Thought
&lt;/h2&gt;

&lt;p&gt;Let’s say you want to visit a website — like &lt;a href="https://blog.gauravdalvi.com" rel="noopener noreferrer"&gt;blog.gauravdalvi.com&lt;/a&gt;. You open your browser and type it in.&lt;/p&gt;

&lt;p&gt;You just initiated an epic digital quest.&lt;/p&gt;

&lt;p&gt;But your computer doesn’t actually know what "&lt;a href="https://blog.gauravdalvi.com" rel="noopener noreferrer"&gt;blog.gauravdalvi.com&lt;/a&gt;" is. Computers don’t speak human; they speak &lt;strong&gt;IP addresses&lt;/strong&gt;, which are like phone numbers for websites (but less likely to be saved in your contacts).&lt;/p&gt;




&lt;h2&gt;
  
  
  🧭 Step 2: DNS – The Internet’s Phone Book (Only Nerdier)
&lt;/h2&gt;

&lt;p&gt;Here’s where the &lt;strong&gt;DNS (Domain Name System)&lt;/strong&gt; jumps in. Think of it like the bouncer outside a club:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“You said &lt;a href="https://blog.gauravdalvi.com" rel="noopener noreferrer"&gt;blog.gauravdalvi.com&lt;/a&gt;? Lemme check the list... Yep! Its IP address is 185.199.108.153. You’re good to go.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Your browser uses this IP address to find the real server where the blog lives. Without DNS, you'd have to remember numbers like it’s 1998 again. No thanks.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Step 3: HTTP – The Messenger on a Mission
&lt;/h2&gt;

&lt;p&gt;Once your browser knows the IP, it sends a request — like a digital letter — using a protocol called &lt;strong&gt;HTTP&lt;/strong&gt; or the newer, shinier &lt;strong&gt;HTTPS&lt;/strong&gt; (the 'S' stands for "Secure", or "Stop snooping, Karen").&lt;/p&gt;

&lt;p&gt;It’s like saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Hey &lt;a href="https://blog.gauravdalvi.com" rel="noopener noreferrer"&gt;blog.gauravdalvi.com&lt;/a&gt;, can you send me your homepage? kthxbye.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This request zooms through multiple servers, routers, and switches, crossing cities and sometimes oceans — all in milliseconds.&lt;/p&gt;




&lt;h2&gt;
  
  
  🖥️ Step 4: Servers – The Internet’s Kitchens
&lt;/h2&gt;

&lt;p&gt;Now imagine the website you’re trying to access is a fancy restaurant. The server is the kitchen.&lt;/p&gt;

&lt;p&gt;When your request hits the server, it fires up the backend (code, databases, CMSes, and maybe even some tears), processes your request, and sends back the webpage — HTML, CSS, JavaScript, images, and all.&lt;/p&gt;

&lt;p&gt;Yes, it’s basically DoorDash, but for data.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛣️ Step 5: The Internet Highway – How the Data Travels
&lt;/h2&gt;

&lt;p&gt;This part is wild.&lt;/p&gt;

&lt;p&gt;Your request and the server’s response travel through a global network of cables — including &lt;strong&gt;undersea fiber-optic cables&lt;/strong&gt; stretching across continents. Think about it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;That dog meme you liked this morning probably swam through the Atlantic Ocean to get to your phone.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(Okay, not literally, but close enough.)&lt;/p&gt;

&lt;p&gt;Routers act like traffic cops, guiding each data packet to its destination via the fastest route. Sometimes, your data takes detours. Sometimes it gets stuck in traffic. Yes, the internet has lag too.&lt;/p&gt;




&lt;h2&gt;
  
  
  📦 Step 6: Packets – The Data Burritos
&lt;/h2&gt;

&lt;p&gt;Here’s a fun one: the web page isn’t sent all at once. It’s chopped into tiny &lt;strong&gt;data packets&lt;/strong&gt; — like digital burritos wrapped with labels saying, “This is part 4 of 72, don’t lose it.”&lt;/p&gt;

&lt;p&gt;These packets fly through the internet and get reassembled on your device faster than you can say “buffering.”&lt;/p&gt;




&lt;h2&gt;
  
  
  🔄 Step 7: Rendering – Your Browser Gets to Work
&lt;/h2&gt;

&lt;p&gt;Now your browser rolls up its sleeves and gets to work. It takes all those packets, reads the HTML, grabs the CSS to make it look pretty, runs the JavaScript to add interactivity, and voilà:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your blog loads.&lt;/strong&gt; 🎉&lt;/p&gt;

&lt;p&gt;Unless it doesn't. Then you hit refresh. Or start blaming your Wi-Fi. Or your ISP. Or your router. Or Mercury retrograde. All valid options.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔐 Bonus: Encryption – Because Privacy Is Kinda Important
&lt;/h2&gt;

&lt;p&gt;If the website uses HTTPS (and it should), all of the above communication is encrypted. Meaning, even if someone tries to eavesdrop mid-journey, all they see is gibberish.&lt;/p&gt;

&lt;p&gt;So when you send a password or payment details, it's scrambled like eggs — only the server knows how to unscramble it.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧩 TL;DR – A Dramatic Recap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You type a URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DNS finds the IP address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your browser sends a request to that address using HTTP(S).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The server receives it, processes it, and sends back the data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data travels through routers, undersea cables, and satellites (sometimes).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your device gets the data in chunks (packets) and renders the page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You enjoy your content while occasionally cursing slow internet speeds.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚡ The Internet Is a Miracle of Coordination
&lt;/h2&gt;

&lt;p&gt;It’s a wild combo of code, hardware, physics, and caffeine that keeps it all running. And now that you know how it works, you’ll appreciate it the next time a video loads &lt;em&gt;without buffering&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Or at least you’ll know who to blame when it doesn’t. 😄&lt;/p&gt;

</description>
      <category>networking</category>
      <category>webdev</category>
      <category>web</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Unlocking the Power of the Console Object: Beyond console.log()</title>
      <dc:creator>Gaurav Dalvi</dc:creator>
      <pubDate>Sat, 12 Apr 2025 15:00:00 +0000</pubDate>
      <link>https://forem.com/gauravdalvi/unlocking-the-power-of-the-console-object-beyond-consolelog-5dfg</link>
      <guid>https://forem.com/gauravdalvi/unlocking-the-power-of-the-console-object-beyond-consolelog-5dfg</guid>
      <description>&lt;p&gt;The &lt;code&gt;console&lt;/code&gt; object is like the Swiss Army knife of debugging—except most developers only use one tool: &lt;code&gt;console.log()&lt;/code&gt;. But what if I told you there’s an entire world of powerful methods hidden inside &lt;code&gt;console&lt;/code&gt;, waiting to make your debugging experience 10x better? In this guide, we’ll explore the underrated and often ignored features of the &lt;code&gt;console&lt;/code&gt; object that will boost your JavaScript debugging skills.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. &lt;code&gt;console.table()&lt;/code&gt; – Pretty Print Your Data 📊
&lt;/h2&gt;

&lt;p&gt;Tired of messy arrays and objects cluttering your console? &lt;code&gt;console.table()&lt;/code&gt; makes them readable!&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;users&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;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Admin&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;id&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User&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;id&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Charlie&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Editor&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;table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This outputs a neat table instead of an unreadable object dump. Perfect for debugging API responses!&lt;/p&gt;




&lt;h2&gt;
  
  
  2. &lt;code&gt;console.warn()&lt;/code&gt; &amp;amp; &lt;code&gt;console.error()&lt;/code&gt; – Color Code Your Logs ⚠️
&lt;/h2&gt;

&lt;p&gt;If all your logs look the same, debugging becomes a nightmare. Use &lt;code&gt;console.warn()&lt;/code&gt; for warnings and &lt;code&gt;console.error()&lt;/code&gt; for errors to make important messages stand out.&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;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;This is a warning!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Yellow text&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="s1"&gt;Something went wrong!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Red text&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Errors even include a stack trace, helping you track down issues faster!&lt;/p&gt;




&lt;h2&gt;
  
  
  3. &lt;code&gt;console.group()&lt;/code&gt; – Organize Logs Like a Pro 📂
&lt;/h2&gt;

&lt;p&gt;Ever wanted to categorize logs into collapsible sections? &lt;code&gt;console.group()&lt;/code&gt; and &lt;code&gt;console.groupEnd()&lt;/code&gt; let you do just that!&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;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User Info&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;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Name: Alice&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;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Role: Admin&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;groupEnd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, your console stays clean and structured. Nested groups? Also possible! 😎&lt;/p&gt;




&lt;h2&gt;
  
  
  4. &lt;code&gt;console.count()&lt;/code&gt; – Track Function Calls 🔢
&lt;/h2&gt;

&lt;p&gt;Need to track how many times a function is executed? &lt;code&gt;console.count()&lt;/code&gt; keeps count for you.&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;fetchData&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;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fetchData called&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// API call simulation&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;This prints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetchData called: 1
fetchData called: 2
fetchData called: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Super useful for debugging loops and recursive functions!&lt;/p&gt;




&lt;h2&gt;
  
  
  5. &lt;code&gt;console.time()&lt;/code&gt; – Measure Performance ⏱️
&lt;/h2&gt;

&lt;p&gt;Performance optimization starts with measuring execution time. &lt;code&gt;console.time()&lt;/code&gt; and &lt;code&gt;console.timeEnd()&lt;/code&gt; make it easy.&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;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Loop Timer&lt;/span&gt;&lt;span class="dl"&gt;'&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="mi"&gt;1000000&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="c1"&gt;// Some heavy computation&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;timeEnd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Loop Timer&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;Now you’ll know exactly how long your functions take to run. 🚀&lt;/p&gt;




&lt;h2&gt;
  
  
  6. &lt;code&gt;console.trace()&lt;/code&gt; – See the Call Stack 🔍
&lt;/h2&gt;

&lt;p&gt;Need to debug function calls? &lt;code&gt;console.trace()&lt;/code&gt; prints a full call stack.&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;first&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;second&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;second&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;third&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;third&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;trace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Trace log&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;first&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can see exactly where your function was called from!&lt;/p&gt;




&lt;h2&gt;
  
  
  7. &lt;code&gt;console.assert()&lt;/code&gt; – Conditional Debugging ✅
&lt;/h2&gt;

&lt;p&gt;Instead of manually checking conditions, let &lt;code&gt;console.assert()&lt;/code&gt; do the work.&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;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;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;assert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User is not an adult!&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 the condition is false, an error message appears. Great for debugging validation logic!&lt;/p&gt;




&lt;h2&gt;
  
  
  8. &lt;code&gt;console.dir()&lt;/code&gt; – Inspect Objects in Depth 🔎
&lt;/h2&gt;

&lt;p&gt;When &lt;code&gt;console.log()&lt;/code&gt; isn’t enough, &lt;code&gt;console.dir()&lt;/code&gt; provides a deeper look at object properties and methods.&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;dir&lt;/span&gt;&lt;span class="p"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is especially useful for exploring DOM elements!&lt;/p&gt;




&lt;h2&gt;
  
  
  9. &lt;code&gt;console.clear()&lt;/code&gt; – Declutter Your Console 🧹
&lt;/h2&gt;

&lt;p&gt;Want to start fresh? &lt;code&gt;console.clear()&lt;/code&gt; wipes your console clean.&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;clear&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Perfect when debugging gets messy!&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts 🏁
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;console&lt;/code&gt; object is far more powerful than just &lt;code&gt;console.log()&lt;/code&gt;. By mastering these advanced methods, you can debug faster, write cleaner code, and look like a JavaScript genius in front of your teammates.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Mastering Minikube: A Deep Dive Beyond the Basics</title>
      <dc:creator>Gaurav Dalvi</dc:creator>
      <pubDate>Fri, 11 Apr 2025 15:11:46 +0000</pubDate>
      <link>https://forem.com/gauravdalvi/mastering-minikube-a-deep-dive-beyond-the-basics-48b9</link>
      <guid>https://forem.com/gauravdalvi/mastering-minikube-a-deep-dive-beyond-the-basics-48b9</guid>
      <description>&lt;p&gt;Minikube is an awesome tool for running Kubernetes locally, but let's be real—most people just &lt;code&gt;minikube start&lt;/code&gt; and call it a day. But there's so much more you can do! In this post, I'm diving into some intermediate-level features and optimizations to help you squeeze every last drop of power out of Minikube.&lt;/p&gt;




&lt;h2&gt;
  
  
  Advanced Minikube Features You Should Know
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Choosing the Right Driver for Performance&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Minikube supports multiple drivers, and picking the right one can make a huge difference in speed and resource usage.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Docker Driver&lt;/strong&gt;: The fastest and most efficient choice if you already use Docker.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VirtualBox&lt;/strong&gt;: Works when Docker isn’t an option, but it’s a bit heavier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;KVM2 (Linux only)&lt;/strong&gt;: Great for speed and isolation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HyperKit (macOS only)&lt;/strong&gt;: A solid, lightweight option for Mac users.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To set your preferred driver permanently:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube config &lt;span class="nb"&gt;set &lt;/span&gt;driver docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or just specify it when starting Minikube:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube start &lt;span class="nt"&gt;--driver&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. &lt;strong&gt;Running Multiple Clusters Like a Pro&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Sometimes, one Minikube instance isn't enough. Need different environments for testing? No problem.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube start &lt;span class="nt"&gt;-p&lt;/span&gt; dev-cluster
minikube start &lt;span class="nt"&gt;-p&lt;/span&gt; staging-cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Switch between them easily:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl config use-context minikube-dev-cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shut down or delete specific clusters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube stop &lt;span class="nt"&gt;-p&lt;/span&gt; dev-cluster
minikube delete &lt;span class="nt"&gt;-p&lt;/span&gt; staging-cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. &lt;strong&gt;Give It More Juice: Resource Allocation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Minikube starts with minimal resources, which is fine for small tests but not great for serious work. Bump it up with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube start &lt;span class="nt"&gt;--memory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4g &lt;span class="nt"&gt;--cpus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check if it's struggling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. &lt;strong&gt;Supercharging Minikube with Addons&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Minikube comes with built-in addons that can make your life easier.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;metrics-server&lt;/strong&gt;: Enables Kubernetes Metrics API (handy for &lt;code&gt;kubectl top&lt;/code&gt; commands).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ingress&lt;/strong&gt;: Enables Ingress Controller for routing (because nobody wants to keep using &lt;code&gt;kubectl port-forward&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;dashboard&lt;/strong&gt;: Gives you a web UI to manage your cluster.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To enable an addon:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube addons &lt;span class="nb"&gt;enable &lt;/span&gt;metrics-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List all available addons:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube addons list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. &lt;strong&gt;Keeping Data Persistent (So It Doesn't Vanish on Restart)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;By default, Minikube wipes everything when restarted. If you need persistent storage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PersistentVolumeClaim&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-pvc&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;accessModes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ReadWriteOnce&lt;/span&gt;
  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; pvc.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check if it's working:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pvc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. &lt;strong&gt;Making LoadBalancers Work Locally&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Minikube doesn’t support external LoadBalancers like a cloud provider would, but there's a hack for that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl expose deployment my-app &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;LoadBalancer &lt;span class="nt"&gt;--port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;80
minikube tunnel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, it assigns an external IP, making it act like a real LoadBalancer!&lt;/p&gt;

&lt;h3&gt;
  
  
  7. &lt;strong&gt;Using Profiles for Different Configurations&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Profiles let you create different Minikube setups for different projects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube start &lt;span class="nt"&gt;-p&lt;/span&gt; dev &lt;span class="nt"&gt;--cpus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2 &lt;span class="nt"&gt;--memory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4g
minikube start &lt;span class="nt"&gt;-p&lt;/span&gt; staging &lt;span class="nt"&gt;--cpus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4 &lt;span class="nt"&gt;--memory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Switch between them with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;minikube profile list
minikube profile use dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8. &lt;strong&gt;Building Docker Images Inside Minikube&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Minikube doesn't use your local Docker daemon by default. If you don’t want to push images to Docker Hub just to test them, use this trick:&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;eval&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;minikube docker-env&lt;span class="si"&gt;)&lt;/span&gt;
docker build &lt;span class="nt"&gt;-t&lt;/span&gt; my-app:v1 &lt;span class="nb"&gt;.&lt;/span&gt;
kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; deployment.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your image is available inside Minikube without any extra hassle!&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Minikube is more than just a local Kubernetes playground—it can be a powerful testing and development tool if used right. By leveraging multi-cluster management, persistent storage, optimized resource allocation, and built-in addons, you can make Minikube feel almost like a production cluster (well, almost).&lt;/p&gt;

</description>
      <category>devops</category>
      <category>microservices</category>
      <category>cicd</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>What is Webpack?</title>
      <dc:creator>Gaurav Dalvi</dc:creator>
      <pubDate>Fri, 11 Apr 2025 15:09:30 +0000</pubDate>
      <link>https://forem.com/gauravdalvi/what-is-webpack-371g</link>
      <guid>https://forem.com/gauravdalvi/what-is-webpack-371g</guid>
      <description>&lt;p&gt;Alright, let’s talk about Webpack—because chances are, you’ve heard of it but might still be wondering what exactly it does. Simply put, &lt;strong&gt;Webpack is a tool that takes all your JavaScript, CSS, images, and other assets and bundles them together&lt;/strong&gt; so your website loads faster and runs smoother.&lt;/p&gt;

&lt;p&gt;Imagine you’re packing for a trip. Instead of carrying 10 different bags, wouldn’t it be easier to fit everything into one organized suitcase? That’s exactly what Webpack does for your code!&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Do We Need Webpack?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Problem Before Webpack
&lt;/h3&gt;

&lt;p&gt;Back in the day, websites loaded multiple JavaScript files and CSS stylesheets separately. This led to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Slow load times&lt;/strong&gt; (more files = more requests = longer waiting).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Messy dependency management&lt;/strong&gt; (files relying on each other could break easily).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bloated, unoptimized code&lt;/strong&gt; (unnecessary scripts and styles slowing things down).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Webpack Solution
&lt;/h3&gt;

&lt;p&gt;Webpack makes life easier by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Combining all files&lt;/strong&gt; into a single, optimized bundle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minimizing and compressing code&lt;/strong&gt; to improve performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handling modern JavaScript (ES6+), TypeScript, and CSS preprocessors&lt;/strong&gt; effortlessly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improving page speed&lt;/strong&gt; by eliminating unused code (tree shaking) and loading only what's needed (lazy loading).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Providing a development server&lt;/strong&gt; that auto-refreshes when changes are made.
Basically, it takes all the annoying, repetitive parts of frontend development and automates them.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How Does Webpack Work?
&lt;/h2&gt;

&lt;p&gt;At its core, Webpack follows a simple process: &lt;strong&gt;Find, Process, Bundle.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Entry Point
&lt;/h3&gt;

&lt;p&gt;Webpack starts by looking at the main JavaScript file—the &lt;strong&gt;entry point&lt;/strong&gt;—to figure out what the project needs.&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;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/index.js&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;h3&gt;
  
  
  2. Output
&lt;/h3&gt;

&lt;p&gt;Once Webpack processes everything, it spits out the final bundled file.&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;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bundle.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;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;__dirname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/dist&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;h3&gt;
  
  
  3. Loaders
&lt;/h3&gt;

&lt;p&gt;Loaders help Webpack understand files beyond JavaScript, like CSS and images.&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;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;rules&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="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;css$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;style-loader&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="s1"&gt;css-loader&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="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Plugins
&lt;/h3&gt;

&lt;p&gt;Plugins supercharge Webpack by adding extra features, like generating an HTML file automatically.&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;HtmlWebpackPlugin&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;html-webpack-plugin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&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;HtmlWebpackPlugin&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./src/index.html&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;h3&gt;
  
  
  5. Development vs. Production Mode
&lt;/h3&gt;

&lt;p&gt;Webpack has different modes for development and production. &lt;strong&gt;Development mode&lt;/strong&gt; gives fast builds, while &lt;strong&gt;production mode&lt;/strong&gt; optimizes everything for the best performance.&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;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;development&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// or 'production'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Webpack is like that friend who organizes everything so I don’t have to. It takes multiple files, optimizes them, and ensures the site loads fast. Whether you’re working with JavaScript, CSS, images, or even TypeScript, Webpack has your back.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
