<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amrishkhan Sheik Abdullah</title>
    <description>The latest articles on DEV Community by Amrishkhan Sheik Abdullah (@amrishkhan05).</description>
    <link>https://dev.to/amrishkhan05</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%2F3548760%2F33e01ff1-6b04-4553-bfae-848443ff42b2.jpeg</url>
      <title>DEV Community: Amrishkhan Sheik Abdullah</title>
      <link>https://dev.to/amrishkhan05</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amrishkhan05"/>
    <language>en</language>
    <item>
      <title>Unlocking the Power of the Browser Console: A Developer's Guide 🚀</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Fri, 17 Oct 2025 11:25:49 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/unlocking-the-power-of-the-browser-console-a-developers-guide-4n7k</link>
      <guid>https://dev.to/amrishkhan05/unlocking-the-power-of-the-browser-console-a-developers-guide-4n7k</guid>
      <description>&lt;p&gt;For web developers, the browser's developer console is an indispensable tool. It's more than just a place to spot error messages; it's a powerful debugging and development companion that can significantly streamline your workflow and enhance your productivity. This article delves into the depths of the &lt;code&gt;console&lt;/code&gt; object, exploring its popular methods and uncovering creative ways to leverage them.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the Console and Why is it Your Best Friend?
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;console&lt;/code&gt; object provides access to the browser's debugging console, allowing you to log information, inspect objects, and analyze your code's execution. It's like having a direct line of communication with your application, providing invaluable insights into what's happening under the hood. By mastering the console, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Debug with Ease:&lt;/strong&gt; Quickly identify and resolve issues by logging variable values, tracking function calls, and examining object properties.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Understand Code Flow:&lt;/strong&gt; Trace the execution of your code to pinpoint where things go wrong or to simply understand how different parts of your application interact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitor Performance:&lt;/strong&gt; Time and measure the performance of your code to identify and optimize bottlenecks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhance Productivity:&lt;/strong&gt; Utilize advanced console features to organize output, create interactive logs, and streamline your debugging process.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  The Most Popular Console Methods You Should Know
&lt;/h3&gt;

&lt;p&gt;While the &lt;code&gt;console&lt;/code&gt; object boasts a wide array of methods, a few stand out as the workhorses of every developer's toolkit.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. &lt;code&gt;console.log()&lt;/code&gt;: The Classic All-Rounder&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;console.log()&lt;/code&gt; method is the most frequently used and versatile method. It allows you to output any type of data to the console, from simple strings and numbers to complex objects and arrays.&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&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;User's name:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="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;User's age:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&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;User object:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Console Output:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h4&gt;
  
  
  &lt;strong&gt;2. &lt;code&gt;console.error()&lt;/code&gt;, &lt;code&gt;console.warn()&lt;/code&gt;, and &lt;code&gt;console.info()&lt;/code&gt;: Adding Context to Your Logs&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;These methods are similar to &lt;code&gt;console.log()&lt;/code&gt;, but they provide a visual distinction in the console, making it easier to categorize and filter your logs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;console.error()&lt;/code&gt;: Displays an error message, typically with a red background, to indicate a problem that needs immediate attention.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;console.warn()&lt;/code&gt;: Displays a warning message, often with a yellow background, to highlight potential issues that may not be critical but should be addressed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;console.info()&lt;/code&gt;: Displays an informational message, usually with a blue or gray icon, to provide general information.&lt;/li&gt;
&lt;/ul&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;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is an error message!&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;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is a warning message.&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;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is an informational message.&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;Console Output:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h4&gt;
  
  
  &lt;strong&gt;3. &lt;code&gt;console.table()&lt;/code&gt;: Visualizing Data in a Structured Way&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;When working with arrays of objects, &lt;code&gt;console.table()&lt;/code&gt; is a game-changer. It displays your data in a clean, interactive table, making it easy to read and analyze.&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;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="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="s2"&gt;Jane Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt; &lt;span class="p"&gt;},&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="s2"&gt;Peter Jones&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;35&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;&lt;strong&gt;Console Output:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h4&gt;
  
  
  &lt;strong&gt;4. &lt;code&gt;console.group()&lt;/code&gt; and &lt;code&gt;console.groupEnd()&lt;/code&gt;: Organizing Your Console Output&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;For complex applications with a lot of logging, the console can quickly become cluttered. &lt;code&gt;console.group()&lt;/code&gt; and &lt;code&gt;console.groupEnd()&lt;/code&gt; allow you to create collapsible groups of log messages, keeping your console organized and readable. You can even use &lt;code&gt;console.groupCollapsed()&lt;/code&gt; to create a group that is initially collapsed.&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="s2"&gt;User Details&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="s2"&gt;Name: John Doe&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="s2"&gt;Age: 30&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;&lt;strong&gt;Console Output:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Level Up Your Productivity with Advanced Console Techniques
&lt;/h3&gt;

&lt;p&gt;Beyond the basics, the &lt;code&gt;console&lt;/code&gt; object offers several advanced features that can significantly boost your productivity.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;1. &lt;code&gt;console.assert()&lt;/code&gt;: Conditional Logging&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;console.assert()&lt;/code&gt; allows you to log an error message only if a specified condition is &lt;code&gt;false&lt;/code&gt;. This is particularly useful for validating data and catching unexpected behavior.&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;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="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;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;x is not greater than y&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;Console Output:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h4&gt;
  
  
  &lt;strong&gt;2. &lt;code&gt;console.trace()&lt;/code&gt;: Tracing the Call Stack&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;When you need to understand how a particular function was called, &lt;code&gt;console.trace()&lt;/code&gt; comes to the rescue. It outputs a stack trace, showing the entire call path that led to the &lt;code&gt;console.trace()&lt;/code&gt; call.&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;foo&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;bar&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="p"&gt;}&lt;/span&gt;
  &lt;span class="nf"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;foo&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;Console Output:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h4&gt;
  
  
  &lt;strong&gt;3. &lt;code&gt;console.time()&lt;/code&gt; and &lt;code&gt;console.timeEnd()&lt;/code&gt;: Measuring Performance&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;To measure the time it takes for a piece of code to execute, you can use &lt;code&gt;console.time()&lt;/code&gt; and &lt;code&gt;console.timeEnd()&lt;/code&gt;. Simply call &lt;code&gt;console.time()&lt;/code&gt; with a label before the code you want to measure, and then call &lt;code&gt;console.timeEnd()&lt;/code&gt; with the same label after the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="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="s2"&gt;myTimer&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;100000&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 code&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="s2"&gt;myTimer&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;Console Output:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h4&gt;
  
  
  &lt;strong&gt;4. Styling Your Console Output with &lt;code&gt;%c&lt;/code&gt;&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Did you know you can style your console output with CSS? By using the &lt;code&gt;%c&lt;/code&gt; directive, you can add custom styles to your log messages, making them more visually appealing and easier to read.&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;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;%cThis is a styled message!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;color: blue; font-size: 20px; font-weight: bold;&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;Console Output:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The browser's &lt;code&gt;console&lt;/code&gt; object is a powerful and versatile tool that is essential for modern web development. By mastering its various methods and exploring its advanced features, you can significantly improve your debugging process, gain a deeper understanding of your code, and ultimately become a more productive and effective developer. So, the next time you're working on a web project, don't forget to open up the console and put these techniques into practice!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Demystifying SOLID: 5 Principles for Building Robust and Maintainable Software 🚀</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Tue, 14 Oct 2025 11:25:16 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/demystifying-solid-5-principles-for-building-robust-and-maintainable-software-2c9j</link>
      <guid>https://dev.to/amrishkhan05/demystifying-solid-5-principles-for-building-robust-and-maintainable-software-2c9j</guid>
      <description>&lt;p&gt;In the world of software development, some principles stand the test of time. Among the most influential are the &lt;strong&gt;SOLID principles&lt;/strong&gt;, a set of five design guidelines that empower developers to create software that is more understandable, flexible, and maintainable. Coined by Robert C. Martin (Uncle Bob), SOLID isn't a silver bullet, but rather a powerful framework for thinking about object-oriented design.&lt;/p&gt;

&lt;p&gt;Let's break down each principle with practical examples.&lt;/p&gt;




&lt;h3&gt;
  
  
  S - Single Responsibility Principle (SRP)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"A class should have only one reason to change."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This principle advocates for a class to have a single, well-defined purpose. If a class has multiple responsibilities, changes to one responsibility might inadvertently affect others, leading to unexpected bugs and a tangled codebase.&lt;/p&gt;

&lt;h4&gt;
  
  
  Bad Example (Violates SRP)
&lt;/h4&gt;

&lt;p&gt;Imagine a &lt;code&gt;Report&lt;/code&gt; class that's responsible for both generating the report data and printing it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 🐍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Report&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;generate_report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Logic to process report data
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Report Data: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print_report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;report_content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_report&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Printing: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;report_content&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript 📜&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Report&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;generateReport&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Logic to process report data&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Report Data: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;printReport&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reportContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generateReport&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Printing: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;reportContent&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it's bad:&lt;/strong&gt; This class has two reasons to change: a change in the data generation logic or a change in the printing mechanism (e.g., printing to a file, sending an email).&lt;/p&gt;

&lt;h4&gt;
  
  
  Good Example (Adheres to SRP)
&lt;/h4&gt;

&lt;p&gt;We split these responsibilities into separate classes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 🐍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ReportGenerator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Report Data: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ReportPrinter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;report_content&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Printing: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;report_content&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Usage
&lt;/span&gt;&lt;span class="n"&gt;generator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReportGenerator&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;printer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReportPrinter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;report_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;generator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sales Figures&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;printer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;report_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript 📜&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ReportGenerator&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Report Data: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ReportPrinter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reportContent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Printing: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;reportContent&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;generator&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;ReportGenerator&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;printer&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;ReportPrinter&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reportData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;generator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sales Figures&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;printer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reportData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, &lt;code&gt;ReportGenerator&lt;/code&gt; only cares about generating data, and &lt;code&gt;ReportPrinter&lt;/code&gt; only cares about printing. Each has one, and only one, reason to change.&lt;/p&gt;




&lt;h3&gt;
  
  
  O - Open/Closed Principle (OCP)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This principle suggests that you should be able to add new functionality without altering existing, working code. This is typically achieved through abstraction and polymorphism.&lt;/p&gt;

&lt;h4&gt;
  
  
  Bad Example (Violates OCP)
&lt;/h4&gt;

&lt;p&gt;Consider a function to calculate the total area of shapes, but it has to know about every concrete shape type.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 🐍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Violates OCP
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_total_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;shapes&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;total_area&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;shape&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;shapes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Circle&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;total_area&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nf"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;total_area&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;
        &lt;span class="c1"&gt;# To add a Triangle, we must modify this function!
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;total_area&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript 📜&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Violates OCP&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateTotalArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;shapes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;totalArea&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;shape&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;shapes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;circle&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;totalArea&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PI&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rectangle&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;totalArea&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="c1"&gt;// To add a Triangle, we must modify this function!&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;totalArea&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;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it's bad:&lt;/strong&gt; Every time a new shape is introduced, the &lt;code&gt;calculate_total_area&lt;/code&gt; function needs to be modified. It's not closed for modification.&lt;/p&gt;

&lt;h4&gt;
  
  
  Good Example (Adheres to OCP)
&lt;/h4&gt;

&lt;p&gt;We use polymorphism. Each shape knows how to calculate its own area.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 🐍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;NotImplementedError&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;

&lt;span class="c1"&gt;# We can add new shapes without changing calculate_total_area
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Triangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_total_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;shapes&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;calculate_area&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;shape&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;shapes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript 📜&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PI&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// We can add new shapes without changing calculateTotalArea&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Triangle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculateTotalArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;shapes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;shapes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;shape&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;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;calculateArea&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, the &lt;code&gt;calculate_total_area&lt;/code&gt; function is closed for modification. To add new shapes, we simply extend our system with new classes.&lt;/p&gt;




&lt;h2&gt;
  
  
  L - Liskov Substitution Principle (LSP) Good Example
&lt;/h2&gt;

&lt;p&gt;The best way to adhere to LSP in the shape example is to avoid making &lt;code&gt;Square&lt;/code&gt; a subtype of &lt;code&gt;Rectangle&lt;/code&gt;. Instead, both should inherit from a common abstraction like &lt;code&gt;Shape&lt;/code&gt; that doesn't define setters that could be misused, ensuring the behavior of the derived classes is consistent with what the client expects from the base class.&lt;/p&gt;

&lt;h3&gt;
  
  
  Good Example (Adheres to LSP)
&lt;/h3&gt;

&lt;p&gt;Both &lt;code&gt;Circle&lt;/code&gt; and &lt;code&gt;Rectangle&lt;/code&gt; (and &lt;code&gt;Square&lt;/code&gt;, if needed) are substitutes for the general &lt;code&gt;Shape&lt;/code&gt; base type, as neither breaks the contract defined by &lt;code&gt;Shape&lt;/code&gt;'s &lt;code&gt;calculate_area&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python 🐍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Base class defining the expected contract: calculation of area
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;NotImplementedError&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt;
    &lt;span class="c1"&gt;# Behavior is extended, not broken
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;
    &lt;span class="c1"&gt;# Behavior is extended, not broken
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;

&lt;span class="c1"&gt;# A function that expects a Shape will work correctly with any subtype (LSP is maintained)
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Shape&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# The client only calls a method that is correctly implemented by all subtypes
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Calculated area: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;calculate_area&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Usage: Both Circle and Rectangle are substitutable for Shape
&lt;/span&gt;&lt;span class="n"&gt;circle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;rectangle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;check_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;circle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;check_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rectangle&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;JavaScript 📜&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// A common base class/interface is used.&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;calculateArea must be implemented&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Circle&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// Behavior is extended, not broken&lt;/span&gt;
    &lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PI&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Shape&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// Behavior is extended, not broken&lt;/span&gt;
    &lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// A function that expects a Shape (i.e., an object with a calculateArea method)&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;checkArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// The client only calls a method that is correctly implemented by all subtypes&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Calculated area: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;calculateArea&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Usage: Both Circle and Rectangle are substitutable for the abstract Shape contract&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;circle&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;Circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rectangle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;checkArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;circle&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;checkArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rectangle&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By ensuring that derived classes don't alter the assumptions made by the client code when dealing with the base class (by using immutable properties or constructors), we uphold the Liskov Substitution Principle.&lt;/p&gt;




&lt;h3&gt;
  
  
  I - Interface Segregation Principle (ISP)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"Clients should not be forced to depend on interfaces they do not use."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This principle suggests that large, monolithic interfaces should be broken down into smaller, more specific ones. This way, classes only need to implement methods that are relevant to their functionality.&lt;/p&gt;

&lt;h4&gt;
  
  
  Bad Example (Violates ISP)
&lt;/h4&gt;

&lt;p&gt;Imagine a single, "fat" &lt;code&gt;Worker&lt;/code&gt; interface.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 🐍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;NotImplementedError&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;NotImplementedError&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Human&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Worker&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Human working&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Human eating&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Robot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Worker&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Robot working&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt; &lt;span class="c1"&gt;# Robots don't eat, but must implement the method.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript 📜&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Method not implemented!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Method not implemented!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Human&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;work&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;Human working&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;eat&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;Human eating&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="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Robot&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;work&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;Robot working&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;eat&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* Robots don't eat, but must implement the method. */&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;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it's bad:&lt;/strong&gt; The &lt;code&gt;Robot&lt;/code&gt; class is forced to implement an &lt;code&gt;eat&lt;/code&gt; method it doesn't need. This creates an unnatural dependency.&lt;/p&gt;

&lt;h4&gt;
  
  
  Good Example (Adheres to ISP)
&lt;/h4&gt;

&lt;p&gt;Segregate the interfaces into smaller, role-specific ones.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 🐍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Workable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;NotImplementedError&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Eatable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;NotImplementedError&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Human&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Workable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Eatable&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Human working&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Human eating&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Robot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Workable&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="c1"&gt;# Only implements what it needs
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Robot working&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript 📜&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In JS, this is often done with composition or smaller classes.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;workable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; working`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;eatable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; eating`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Human&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&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="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Human&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;workable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;eatable&lt;/span&gt;&lt;span class="p"&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="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&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="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Robot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;workable&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Only implements what it needs&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;human&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;Human&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;robot&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;Robot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;C-3PO&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;human&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Alice working&lt;/span&gt;
&lt;span class="nx"&gt;human&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;eat&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  &lt;span class="c1"&gt;// Alice eating&lt;/span&gt;
&lt;span class="nx"&gt;robot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;work&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// C-3PO working&lt;/span&gt;
&lt;span class="c1"&gt;// robot.eat(); // TypeError: robot.eat is not a function&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, &lt;code&gt;Robot&lt;/code&gt; only depends on the &lt;code&gt;Workable&lt;/code&gt; behavior. Clients can depend on smaller, more focused abstractions.&lt;/p&gt;




&lt;h3&gt;
  
  
  D - Dependency Inversion Principle (DIP)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;"1. High-level modules should not depend on low-level modules. Both should depend on abstractions."&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;"2. Abstractions should not depend on details. Details should depend on abstractions."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This principle is about decoupling. Instead of high-level logic depending directly on concrete low-level implementations, both should depend on an abstraction (like an interface). This is often achieved through &lt;strong&gt;Dependency Injection&lt;/strong&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Bad Example (Violates DIP)
&lt;/h4&gt;

&lt;p&gt;A &lt;code&gt;PasswordReminder&lt;/code&gt; (high-level) module is directly coupled to a &lt;code&gt;MySQLDatabase&lt;/code&gt; (low-level) module.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 🐍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Connecting to MySQL...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_user_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;User data from MySQL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PasswordReminder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# &amp;lt;-- Direct dependency!
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_user_data&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;JavaScript 📜&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight javascript"&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="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;connect&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;Connecting to MySQL...&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;getUserData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;User data from MySQL&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="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PasswordReminder&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dbConnection&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="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// &amp;lt;-- Direct dependency!&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dbConnection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dbConnection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUserData&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;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why it's bad:&lt;/strong&gt; The &lt;code&gt;PasswordReminder&lt;/code&gt; is completely tied to &lt;code&gt;MySQLDatabase&lt;/code&gt;. If we want to switch to a PostgreSQL database or use a mock database for testing, we have to change the &lt;code&gt;PasswordReminder&lt;/code&gt; class.&lt;/p&gt;

&lt;h4&gt;
  
  
  Good Example (Adheres to DIP)
&lt;/h4&gt;

&lt;p&gt;We introduce an abstraction that both modules can depend on. The dependency is "injected" into the high-level module.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Python 🐍&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DatabaseConnection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# The Abstraction
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;NotImplementedError&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_user_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;NotImplementedError&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DatabaseConnection&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="c1"&gt;# A Detail
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Connecting to MySQL...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_user_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;User data from MySQL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PostgreSQLDatabase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DatabaseConnection&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="c1"&gt;# Another Detail
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Connecting to PostgreSQL...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_user_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;User data from PostgreSQL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PasswordReminder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# High-level module
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db_connection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;DatabaseConnection&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="c1"&gt;# Depends on abstraction
&lt;/span&gt;        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db_connection&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_user_data&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# We can now 'inject' any database that follows the contract.
&lt;/span&gt;&lt;span class="n"&gt;mysql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;reminder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PasswordReminder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mysql&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript 📜&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In JS, the abstraction is often an implicit contract (duck typing).&lt;/span&gt;
&lt;span class="c1"&gt;// We expect any database object to have `connect` and `getUserData` methods.&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// A Detail&lt;/span&gt;
    &lt;span class="nf"&gt;connect&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;Connecting to MySQL...&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;getUserData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;User data from MySQL&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="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PostgreSQLDatabase&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// Another Detail&lt;/span&gt;
    &lt;span class="nf"&gt;connect&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;Connecting to PostgreSQL...&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;getUserData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;User data from PostgreSQL&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="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PasswordReminder&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// High-level module&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dbConnection&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// Depends on the abstraction (the contract)&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dbConnection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dbConnection&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dbConnection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;dbConnection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUserData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// We can now 'inject' any database that follows the contract.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mysql&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="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reminder&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;PasswordReminder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mysql&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reminder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By depending on an abstraction, our &lt;code&gt;PasswordReminder&lt;/code&gt; is now decoupled from the specific database implementation, making it more flexible, reusable, and testable.&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Adopting the SOLID principles is an investment in the long-term health of your codebase. It might seem like more work upfront, but it leads to software that is easier to scale, refactor, and understand. By building systems with single responsibilities, that are open to extension, with substitutable parts, lean interfaces, and inverted dependencies, you create a foundation for truly robust and elegant software. Happy coding!&lt;/p&gt;

</description>
      <category>solidprinciples</category>
      <category>programming</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>GitHub Code Setup: Choosing Your Workflow (HTTPS, SSH, Terminal, &amp; Desktop)</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Wed, 08 Oct 2025 14:38:01 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/github-code-setup-choosing-your-workflow-https-ssh-terminal-desktop-7op</link>
      <guid>https://dev.to/amrishkhan05/github-code-setup-choosing-your-workflow-https-ssh-terminal-desktop-7op</guid>
      <description>&lt;p&gt;Getting a codebase from GitHub onto your local machine is the first step in any development project. While the core action is always a "clone," the method you choose affects your daily workflow, security, and integration with the GitHub platform.&lt;/p&gt;

&lt;p&gt;Here's a detailed guide to the four main ways you can set up your code environment, complete with steps and examples for each.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Git Protocol Choice: HTTPS vs. SSH 🔑
&lt;/h2&gt;

&lt;p&gt;Before you even pick a tool (Terminal or Desktop), you must decide how your machine will &lt;strong&gt;authenticate&lt;/strong&gt; with GitHub.&lt;/p&gt;

&lt;h3&gt;
  
  
  A. HTTPS (The Simple Way)
&lt;/h3&gt;

&lt;p&gt;HTTPS uses your standard GitHub username and password, often combined with a &lt;strong&gt;Personal Access Token (PAT)&lt;/strong&gt; for authentication, or relies on a local &lt;strong&gt;credential manager&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pros&lt;/th&gt;
&lt;th&gt;Cons&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Simple Setup:&lt;/strong&gt; No key generation required.&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Token Reliance:&lt;/strong&gt; Requires authentication (password or PAT) for every push/pull unless a credential manager is used.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Universal:&lt;/strong&gt; Works everywhere without configuration.&lt;/td&gt;
&lt;td&gt;PATs can expire and require occasional regeneration.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;When to use it:&lt;/strong&gt; For quick, one-off projects, or when you are on a machine where you cannot set up SSH keys.&lt;/p&gt;

&lt;h3&gt;
  
  
  Crucial Missing Step: Setting up the Credential Manager (Recommended)
&lt;/h3&gt;

&lt;p&gt;To avoid entering your PAT or password constantly, you should configure Git to store your credentials securely.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Generate a PAT:&lt;/strong&gt; Go to GitHub $\rightarrow$ &lt;strong&gt;Settings&lt;/strong&gt; $\rightarrow$ &lt;strong&gt;Developer settings&lt;/strong&gt; $\rightarrow$ &lt;strong&gt;Personal access tokens&lt;/strong&gt; $\rightarrow$ &lt;strong&gt;Tokens (classic)&lt;/strong&gt;. Generate a new token with appropriate permissions (usually &lt;code&gt;repo&lt;/code&gt;). &lt;strong&gt;Copy this token immediately&lt;/strong&gt;; you won't see it again.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Configure Credential Manager:&lt;/strong&gt; This command tells Git to use your OS's built-in credential manager (like macOS Keychain or Windows Credential Manager).&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; credential.helper store
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;First Clone &amp;amp; Authentication:&lt;/strong&gt; The very first time you push or pull after running the above command, Git will prompt you. Enter your GitHub username and the &lt;strong&gt;PAT&lt;/strong&gt; you generated as the password. The credential manager saves it for future use.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example Clone Command:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/username/repo-name.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  B. SSH (The Secure Way)
&lt;/h3&gt;

&lt;p&gt;SSH (Secure Shell) uses a pair of cryptographic keys: a &lt;strong&gt;private key&lt;/strong&gt; stored securely on your machine and a &lt;strong&gt;public key&lt;/strong&gt; uploaded to GitHub. This method is the most secure and convenient once set up.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pros&lt;/th&gt;
&lt;th&gt;Cons&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Highly Secure:&lt;/strong&gt; Uses key pairs; your private key never leaves your machine.&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Initial Setup:&lt;/strong&gt; Requires key generation and configuration.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Convenient:&lt;/strong&gt; Once set up, it requires &lt;strong&gt;zero authentication&lt;/strong&gt; for pushes/pulls (if using an agent).&lt;/td&gt;
&lt;td&gt;Requires proper passphrase management.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;When to use it:&lt;/strong&gt; For your daily driver, primary development machine, or any sensitive codebase.&lt;/p&gt;

&lt;h3&gt;
  
  
  Detailed SSH Setup
&lt;/h3&gt;

&lt;p&gt;This process requires a few crucial steps to work seamlessly:&lt;/p&gt;

&lt;h3&gt;
  
  
  🔐 Step 1: Generate SSH Key
&lt;/h3&gt;

&lt;p&gt;Open your terminal and run the following command. The &lt;code&gt;-t ed25519&lt;/code&gt; flag uses the recommended secure algorithm.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; ed25519 &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s2"&gt;"your_email@example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File Prompt:&lt;/strong&gt; Press &lt;strong&gt;Enter&lt;/strong&gt; to accept the default file location (&lt;code&gt;~/.ssh/id_ed25519&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Passphrase Prompt:&lt;/strong&gt; Enter a strong, memorable &lt;strong&gt;passphrase&lt;/strong&gt;. This encrypts your private key file.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔑 Step 2: Add SSH Key to SSH Agent
&lt;/h3&gt;

&lt;p&gt;The SSH agent manages your private keys and keeps them in memory, allowing you to use the key without entering the passphrase for every Git operation.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Start the ssh-agent:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add your private key to the agent:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-add ~/.ssh/id_ed25519
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;(You will be prompted to enter the passphrase you created in Step 1.)&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  📋 Step 3: Copy Your Public Key
&lt;/h3&gt;

&lt;p&gt;Copy the contents of the public key file (&lt;code&gt;.pub&lt;/code&gt; extension) to your clipboard using a command like &lt;code&gt;cat&lt;/code&gt; (for macOS/Linux/Git Bash):&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;cat&lt;/span&gt; ~/.ssh/id_ed25519.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🌐 Step 4: Add SSH Key to GitHub
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Go to GitHub Settings:&lt;/strong&gt; Navigate to your GitHub Profile $\rightarrow$ &lt;strong&gt;Settings&lt;/strong&gt; $\rightarrow$ &lt;strong&gt;SSH and GPG keys&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Add New SSH Key:&lt;/strong&gt; Click the &lt;strong&gt;"New SSH key"&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Title:&lt;/strong&gt; Give it a descriptive name (e.g., "Home PC").&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Key:&lt;/strong&gt; Paste the public key you copied into the key field.&lt;/li&gt;
&lt;li&gt; Click &lt;strong&gt;"Add SSH key."&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  🧪 Step 5: Test SSH Connection
&lt;/h3&gt;

&lt;p&gt;Test the connection from your machine to GitHub to ensure authentication works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-T&lt;/span&gt; git@github.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should receive a confirmation message that includes your username.&lt;/p&gt;

&lt;h3&gt;
  
  
  📥 Step 6: Clone Repository Using SSH
&lt;/h3&gt;

&lt;p&gt;Now clone the repository using the SSH URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone git@github.com:username/repo-name.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. The Tool Choice: Terminal vs. GitHub Desktop 🛠️
&lt;/h2&gt;

&lt;p&gt;Once your chosen protocol is set up, you choose your interface for the &lt;code&gt;git clone&lt;/code&gt; command.&lt;/p&gt;

&lt;h3&gt;
  
  
  A. Terminal / Command Line (The Power User's Way)
&lt;/h3&gt;

&lt;p&gt;Using the terminal gives you the fastest, most granular control over Git operations and is the preferred method for most experienced developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt; Git must be installed, and your chosen protocol (HTTPS/SSH) must be configured.&lt;/p&gt;

&lt;h4&gt;
  
  
  Setup Example (Using HTTPS and Credential Manager):
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Navigate to your Development Folder:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/Projects/
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Clone the Repository:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;(Copy the HTTPS link from the GitHub repo page.)&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/your-user/your-repo.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Start Working:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;your-repo
&lt;span class="c"&gt;# Make changes...&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial setup"&lt;/span&gt;
git push  &lt;span class="c"&gt;# Should prompt for credentials only once, then use the credential manager&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  B. GitHub Desktop (The Visual Workflow)
&lt;/h3&gt;

&lt;p&gt;GitHub Desktop provides a simplified graphical interface (GUI) that abstracts away complex commands. It's excellent for beginners, visual learners, or for managing branches and commits quickly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt; You must have the GitHub Desktop application installed and be logged into your GitHub account within the app.&lt;/p&gt;

&lt;h4&gt;
  
  
  Setup Example (Visual Clone):
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Open GitHub Desktop.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt; Go to &lt;strong&gt;File&lt;/strong&gt; $\rightarrow$ &lt;strong&gt;Clone Repository&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; Select the &lt;strong&gt;GitHub.com&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt; Choose the repository you want from your list.&lt;/li&gt;
&lt;li&gt; Specify the &lt;strong&gt;Local Path&lt;/strong&gt; where the code should be stored.&lt;/li&gt;
&lt;li&gt; Click &lt;strong&gt;"Clone"&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The application automatically handles the &lt;code&gt;git clone&lt;/code&gt; command and uses the authentication it saved when you signed into the app. All subsequent pulls and pushes are done by clicking the &lt;strong&gt;Fetch&lt;/strong&gt; and &lt;strong&gt;Push&lt;/strong&gt; buttons.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Quick Reference Table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Interface&lt;/th&gt;
&lt;th&gt;Authentication&lt;/th&gt;
&lt;th&gt;Complexity&lt;/th&gt;
&lt;th&gt;Best For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;HTTPS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Terminal&lt;/td&gt;
&lt;td&gt;PAT + Credential Manager&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Quick tests, public repos, shared/temporary machines.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SSH&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Terminal&lt;/td&gt;
&lt;td&gt;SSH Key Pair + Agent&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Daily driver, maximum security, high-volume pushes/pulls.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;GitHub Desktop&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;GUI&lt;/td&gt;
&lt;td&gt;Saved Token / Credentials&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Beginners, visual management, non-technical collaborators.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>github</category>
      <category>ssh</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Hey Folks! Check out my new post.</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Wed, 08 Oct 2025 08:48:01 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/hey-folks-check-out-my-new-post-2cdb</link>
      <guid>https://dev.to/amrishkhan05/hey-folks-check-out-my-new-post-2cdb</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/amrishkhan05" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3548760%2F33e01ff1-6b04-4553-bfae-848443ff42b2.jpeg" alt="amrishkhan05"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/amrishkhan05/level-up-your-workflow-mastering-bulk-actions-in-postman-2489" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Level Up Your Workflow: Mastering Bulk Actions in Postman 🚀&lt;/h2&gt;
      &lt;h3&gt;Amrishkhan Sheik Abdullah ・ Oct 8&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Level Up Your Workflow: Mastering Bulk Actions in Postman 🚀</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Wed, 08 Oct 2025 08:45:23 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/level-up-your-workflow-mastering-bulk-actions-in-postman-2489</link>
      <guid>https://dev.to/amrishkhan05/level-up-your-workflow-mastering-bulk-actions-in-postman-2489</guid>
      <description>&lt;p&gt;Postman is much more than just a tool for sending single API requests; it’s a powerful environment for testing, documenting, and executing complex API workflows. When you need to perform the same operation hundreds of times—like creating a batch of users, testing various data inputs, or migrating configuration—you need &lt;strong&gt;bulk actions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The secret to bulk operations in Postman lies in combining &lt;strong&gt;Collections&lt;/strong&gt;, the &lt;strong&gt;Collection Runner&lt;/strong&gt;, &lt;strong&gt;Variables&lt;/strong&gt;, and external &lt;strong&gt;Data Files&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. The Core Tool: The Collection Runner
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Collection Runner&lt;/strong&gt; is Postman's built-in feature for executing an entire Collection (or a specific Folder within a Collection) multiple times in a predefined sequence. It's the central hub for all bulk operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features for Bulk Actions:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Iteration Count:&lt;/strong&gt; Tells the Runner how many times to execute the entire collection/folder.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Files:&lt;/strong&gt; Allows you to upload external CSV or JSON files to feed different data into each iteration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment Selection:&lt;/strong&gt; Ensures consistent bulk operations across development, staging, or production environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test Logging:&lt;/strong&gt; Logs the results (pass/fail) for every request across every iteration.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Technique 1: Data-Driven Testing (Bulk Input)
&lt;/h2&gt;

&lt;p&gt;This is the most common form of bulk action, used to test an API endpoint against a large set of varied inputs (e.g., testing valid/invalid usernames, bulk user creation, or mass data updates).&lt;/p&gt;

&lt;h3&gt;
  
  
  Step-by-Step Implementation:
&lt;/h3&gt;

&lt;h3&gt;
  
  
  A. Prepare the Data File 📊
&lt;/h3&gt;

&lt;p&gt;Create a &lt;strong&gt;CSV&lt;/strong&gt; or &lt;strong&gt;JSON&lt;/strong&gt; file containing all your input data. The column headers in your file will become the variable names Postman uses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example CSV (&lt;code&gt;user_data.csv&lt;/code&gt;):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;id,username,email,expected_status
1,alice_dev,alice@test.com,201
2,bob_tester,bob@test.com,201
3,,invalid_user.com,400
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  B. Parameterize the Request 🔗
&lt;/h3&gt;

&lt;p&gt;In your Postman request (e.g., a &lt;code&gt;POST /users&lt;/code&gt; request), replace the static values in the URL, headers, or body with &lt;strong&gt;dynamic variables&lt;/strong&gt; using the &lt;code&gt;{{variable_name}}&lt;/code&gt; syntax.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part of Request&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After (Parameterized)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Request Body&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"username": "static_user"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"username": "{{username}}"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tests/Assertions&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pm.expect(pm.response.code).to.eql(201);&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pm.expect(pm.response.code).to.eql(pm.iterationData.get("expected_status"));&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Postman will automatically map the column headers from your CSV/JSON file to these variables during the run.&lt;/p&gt;

&lt;h3&gt;
  
  
  C. Run the Collection
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; Click the &lt;strong&gt;"Run"&lt;/strong&gt; button next to your Collection.&lt;/li&gt;
&lt;li&gt; In the Collection Runner window, click &lt;strong&gt;"Select File"&lt;/strong&gt; under the &lt;strong&gt;Data&lt;/strong&gt; section and upload your &lt;code&gt;user_data.csv&lt;/code&gt; (or JSON).&lt;/li&gt;
&lt;li&gt; Postman will automatically update the &lt;strong&gt;Iterations&lt;/strong&gt; count to match the number of rows (data sets) in your file (3 in the example above).&lt;/li&gt;
&lt;li&gt; Click &lt;strong&gt;"Run [Collection Name]"&lt;/strong&gt; to start the bulk operation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Runner will execute the request three separate times, substituting the variables with the data from each row.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Technique 2: Chained Workflows (Sequential Bulk Operations)
&lt;/h2&gt;

&lt;p&gt;Sometimes you need a series of requests to run in bulk (e.g., Login $\rightarrow$ Create Order $\rightarrow$ Get Order Details). The Collection Runner automatically runs requests sequentially, and you can pass data between them using variables.&lt;/p&gt;

&lt;h3&gt;
  
  
  How it Works:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Request 1 (e.g., Login):&lt;/strong&gt; Use a &lt;strong&gt;Post-response Script&lt;/strong&gt; to capture a value (like an authentication token) from the response and save it as an &lt;strong&gt;Environment Variable&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Post-response Script for Login request&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;responseJson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;auth_token&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;responseJson&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Request 2 (e.g., Create Resource):&lt;/strong&gt; Use that variable in the next request's header.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Header Key&lt;/th&gt;
&lt;th&gt;Header Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Authorization&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Bearer {{auth_token}}&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you run the Collection Runner, it executes Request 1, sets the token, and then Request 2 uses that token, all within the same bulk iteration.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  4. Technique 3: Conditional Looping and Flow Control
&lt;/h2&gt;

&lt;p&gt;For advanced bulk actions like &lt;strong&gt;pagination&lt;/strong&gt; or &lt;strong&gt;dynamic flows&lt;/strong&gt;, you can use the &lt;code&gt;postman.setNextRequest()&lt;/code&gt; function in your request scripts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Case: Pagination (Processing all pages of results)
&lt;/h3&gt;

&lt;p&gt;If an API returns data in paginated format (e.g., only 100 records per call), you can't process the whole list in one go. You must loop until there are no more pages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Request:&lt;/strong&gt; &lt;code&gt;GET /data?page={{page_number}}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Pre-request Script:&lt;/strong&gt; Initialize or increment the page number.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Initialize page_number in environment or pre-request script&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;page_number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;page_number&lt;/span&gt;&lt;span class="dl"&gt;"&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Post-response Script (The Loop Logic):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;page_number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Check if there's a next page or total results count&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has_more_pages&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Increment the page number for the next iteration&lt;/span&gt;
    &lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;page_number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;currentPage&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Tell the runner to execute this SAME request again&lt;/span&gt;
    &lt;span class="nx"&gt;postman&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setNextRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requestName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// End the loop by setting the next request to null (or the next item in the collection)&lt;/span&gt;
    &lt;span class="nx"&gt;postman&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setNextRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&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;p&gt;By setting &lt;code&gt;postman.setNextRequest()&lt;/code&gt;, you override the default sequential flow and force the runner to perform a &lt;strong&gt;bulk, data-gathering loop&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  5. Taking Bulk Actions to CI/CD: Newman
&lt;/h2&gt;

&lt;p&gt;For true automation, Postman provides &lt;strong&gt;Newman&lt;/strong&gt;, its command-line collection runner. Newman allows you to run your bulk operations &lt;em&gt;outside&lt;/em&gt; the Postman desktop app, making it perfect for CI/CD pipelines, automated testing, or background tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Newman for Bulk Actions:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Execution:&lt;/strong&gt; Run collections and bulk data sets directly from a terminal or build server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Injection:&lt;/strong&gt; Supports the same data file inputs (&lt;code&gt;-d&lt;/code&gt; or &lt;code&gt;--data&lt;/code&gt;) as the desktop Collection Runner.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Command Example:&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Run a collection 5 times using a specific environment and data file&lt;/span&gt;
newman run my_bulk_collection.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; production_env.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; bulk_create_data.csv &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-n&lt;/span&gt; 5 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--reporters&lt;/span&gt; cli,htmlextra
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Newman is the professional standard for scaling Postman bulk actions into a fully automated process.&lt;/p&gt;

</description>
      <category>api</category>
      <category>tutorial</category>
      <category>tooling</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Unraveling the JavaScript Event Loop: A Deep Dive for Developers</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Tue, 07 Oct 2025 05:24:08 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/unraveling-the-javascript-event-loop-a-deep-dive-for-developers-50fg</link>
      <guid>https://dev.to/amrishkhan05/unraveling-the-javascript-event-loop-a-deep-dive-for-developers-50fg</guid>
      <description>&lt;p&gt;JavaScript is often described as a &lt;strong&gt;single-threaded language&lt;/strong&gt;, meaning it can only execute one task at a time. This raises a fundamental question: how does it handle long-running operations like network requests, timers, or file I/O without "freezing" the entire application? The answer lies in the &lt;strong&gt;Event Loop&lt;/strong&gt; – a clever mechanism that allows JavaScript to perform non-blocking asynchronous operations, giving the illusion of concurrency.&lt;/p&gt;

&lt;p&gt;Understanding the Event Loop is key to writing efficient, responsive, and predictable JavaScript code, whether you're building a frontend UI or a Node.js backend.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Core Components: What's Involved?
&lt;/h2&gt;

&lt;p&gt;Before we dive into the loop itself, let's understand the main players:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Call Stack (Execution Stack):&lt;/strong&gt; This is where JavaScript keeps track of functions being executed. When a function is called, it's pushed onto the stack. When it returns, it's popped off. It operates on a LIFO (Last-In, First-Out) principle.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmarjxcr6fikelx9dc9zn.png" alt="Call stack execution" width="800" height="800"&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Web APIs (Browser) / C++ APIs (Node.js):&lt;/strong&gt; These are capabilities provided by the browser (like &lt;code&gt;setTimeout&lt;/code&gt;, &lt;code&gt;DOM events&lt;/code&gt;, &lt;code&gt;fetch&lt;/code&gt;) or Node.js runtime (like &lt;code&gt;fs.readFile&lt;/code&gt;, &lt;code&gt;http.request&lt;/code&gt;). They are &lt;em&gt;not&lt;/em&gt; part of the JavaScript engine itself but allow JS to &lt;strong&gt;offload&lt;/strong&gt; time-consuming tasks.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06fr3t4c3t77ck1fsf0o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06fr3t4c3t77ck1fsf0o.png" alt="Web APIs (Browser) / C++ APIs (Node.js)" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Callback Queue (Task Queue / Macrotask Queue):&lt;/strong&gt; When an asynchronous operation (e.g., a &lt;code&gt;setTimeout&lt;/code&gt; callback, a &lt;code&gt;click&lt;/code&gt; event handler, or a &lt;code&gt;fetch&lt;/code&gt; response handler) completes, its callback function is moved to this queue. It's a FIFO (First-In, First-Out) queue.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2tbo84qrnulbaj0sch2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2tbo84qrnulbaj0sch2.png" alt="Callback Queue (Task Queue / Macrotask Queue)" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Job Queue (Microtask Queue):&lt;/strong&gt; Introduced with Promises, this queue has &lt;strong&gt;higher priority&lt;/strong&gt; than the Callback Queue. Callbacks from Promises (&lt;code&gt;.then()&lt;/code&gt;, &lt;code&gt;.catch()&lt;/code&gt;, &lt;code&gt;.finally()&lt;/code&gt;), &lt;code&gt;queueMicrotask()&lt;/code&gt;, and &lt;code&gt;MutationObserver&lt;/code&gt; are placed here.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fliu7hh8zkpwkf44wf53g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fliu7hh8zkpwkf44wf53g.png" alt="Job Queue (Microtask Queue)" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Event Loop Itself:&lt;/strong&gt; This is the tireless arbiter. Its sole job is to constantly monitor if the &lt;strong&gt;Call Stack is empty&lt;/strong&gt;. If the Call Stack &lt;em&gt;is&lt;/em&gt; empty, it first checks the &lt;strong&gt;Job Queue&lt;/strong&gt;. If there are jobs, it moves them, one by one, to the Call Stack for execution until the Job Queue is empty. Only &lt;em&gt;then&lt;/em&gt; does it check the &lt;strong&gt;Callback Queue&lt;/strong&gt;. If there are callbacks, it moves the first one to the Call Stack for execution. This process repeats indefinitely.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ny2l2mv9etzqw5zxycn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ny2l2mv9etzqw5zxycn.png" alt="he Event Loop Itself" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Event Loop in Action: Step-by-Step Flow
&lt;/h2&gt;

&lt;p&gt;Let's illustrate the entire process with a common scenario involving &lt;code&gt;setTimeout&lt;/code&gt; and Promises.&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;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;Start&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1&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="s1"&gt;setTimeout callback&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 4&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Scheduled with Web API&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="s1"&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="c1"&gt;// 3&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;End&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Phase 1: Initial Execution (Synchronous Code)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;code&gt;console.log('Start');&lt;/code&gt; is pushed to the Call Stack, executed, and popped. Output: &lt;code&gt;Start&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;setTimeout&lt;/code&gt; is encountered. Its callback is passed to the Web API (Timer). The &lt;code&gt;setTimeout&lt;/code&gt; function itself is popped.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;Promise.resolve().then(...)&lt;/code&gt; is encountered. The promise resolves instantly. Its callback is placed into the &lt;strong&gt;Job Queue&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;console.log('End');&lt;/code&gt; is pushed to the Call Stack, executed, and popped. Output: &lt;code&gt;End&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; At this point, the Call Stack is now &lt;strong&gt;empty&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;h3&gt;
  
  
  Phase 2: Event Loop Kicks In - Prioritizing Microtasks
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; The Event Loop sees the Call Stack is empty.&lt;/li&gt;
&lt;li&gt; It checks the &lt;strong&gt;Job Queue&lt;/strong&gt; and finds the &lt;code&gt;Promise.resolve().then(...)&lt;/code&gt; callback.&lt;/li&gt;
&lt;li&gt; This callback is moved from the Job Queue to the Call Stack.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;console.log('Promise microtask');&lt;/code&gt; is executed and popped. Output: &lt;code&gt;Promise microtask&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; The Call Stack is empty again. The Event Loop re-checks the Job Queue; it's empty.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;h3&gt;
  
  
  Phase 3: Processing Macrotasks
&lt;/h3&gt;

&lt;p&gt;The Event Loop's job isn't done until all pending tasks are cleared. After the Job Queue is empty, the Event Loop can finally turn its attention to the Macrotask Queue.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; While the above was happening, the &lt;code&gt;setTimeout&lt;/code&gt;'s 0ms delay has expired in the Web API. Its callback (&lt;code&gt;() =&amp;gt; { console.log('setTimeout callback'); }&lt;/code&gt;) is now moved to the &lt;strong&gt;Callback Queue&lt;/strong&gt; (the Macrotask queue).&lt;/li&gt;
&lt;li&gt; The Event Loop sees the Job Queue is empty.&lt;/li&gt;
&lt;li&gt; It checks the &lt;strong&gt;Callback Queue&lt;/strong&gt; and finds the &lt;code&gt;setTimeout&lt;/code&gt; callback.&lt;/li&gt;
&lt;li&gt; This callback is moved from the Callback Queue to the Call Stack.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;console.log('setTimeout callback');&lt;/code&gt; is executed and popped. Output: &lt;code&gt;setTimeout callback&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Final Output Order:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;code&gt;Start&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; &lt;code&gt;End&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; &lt;code&gt;Promise microtask&lt;/code&gt; (&lt;strong&gt;Microtasks&lt;/strong&gt; execute entirely before Macrotasks)&lt;/li&gt;
&lt;li&gt; &lt;code&gt;setTimeout callback&lt;/code&gt; (&lt;strong&gt;Macrotasks&lt;/strong&gt; are run one per loop cycle)&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Why Microtasks Have Priority: Starvation
&lt;/h2&gt;

&lt;p&gt;The core takeaway is that the &lt;strong&gt;Job Queue (Microtasks) is processed entirely before the Event Loop moves to the Callback Queue (Macrotasks)&lt;/strong&gt;. This is crucial for &lt;strong&gt;predictability and data consistency&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you use a &lt;strong&gt;Promise&lt;/strong&gt; (&lt;code&gt;.then()&lt;/code&gt;) to handle data loaded from a network request, you want that handler to run as soon as possible, ideally before the browser can render, paint, or process a user interaction (which are often Macrotasks). This ensures the application state is updated with high priority.&lt;/p&gt;

&lt;p&gt;However, this priority can lead to &lt;strong&gt;starvation&lt;/strong&gt;. If a developer puts an infinite loop of microtasks (e.g., a recursive Promise chain) into the Job Queue, the Event Loop will be stuck serving the Job Queue and will &lt;em&gt;never&lt;/em&gt; get to the Callback Queue, effectively blocking all I/O, rendering, and user input.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Queue Type&lt;/th&gt;
&lt;th&gt;Priority&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Microtask&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Job Queue&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;High&lt;/strong&gt; (cleared completely)&lt;/td&gt;
&lt;td&gt;Promises (&lt;code&gt;.then&lt;/code&gt;, &lt;code&gt;.catch&lt;/code&gt;), &lt;code&gt;queueMicrotask&lt;/code&gt;, &lt;code&gt;MutationObserver&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Macrotask&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Callback Queue&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Low&lt;/strong&gt; (one per loop cycle)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;setTimeout&lt;/code&gt;, &lt;code&gt;setInterval&lt;/code&gt;, &lt;code&gt;fetch&lt;/code&gt; callbacks, DOM events (&lt;code&gt;click&lt;/code&gt;, &lt;code&gt;load&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Conclusion: Mastering Asynchronous JS
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Event Loop&lt;/strong&gt; is what transforms single-threaded JavaScript into a powerful, non-blocking language. By offloading time-consuming operations to the Web APIs and orchestrating the execution order through the &lt;strong&gt;Call Stack&lt;/strong&gt;, &lt;strong&gt;Job Queue&lt;/strong&gt;, and &lt;strong&gt;Callback Queue&lt;/strong&gt;, the browser maintains a fluid, responsive user experience.&lt;/p&gt;

&lt;p&gt;As developers, keeping the Call Stack empty and respecting the Macrotask/Microtask priority system is the secret to writing clean, high-performance asynchronous JavaScript.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>javascript</category>
      <category>performance</category>
    </item>
    <item>
      <title>A Developer's Guide to API Types: Architectures, Use Cases, and Code Examples</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Mon, 06 Oct 2025 11:56:29 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/a-developers-guide-to-api-types-architectures-use-cases-and-code-examples-3kbm</link>
      <guid>https://dev.to/amrishkhan05/a-developers-guide-to-api-types-architectures-use-cases-and-code-examples-3kbm</guid>
      <description>&lt;p&gt;Selecting the right API architectural style is a fundamental decision that determines a project's performance, scalability, and complexity. This guide provides a detailed breakdown of the major API styles, their ideal use cases, and practical code examples.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. REST (Representational State Transfer)
&lt;/h2&gt;

&lt;p&gt;REST is the most popular architectural style for web services, utilizing standard HTTP methods to perform CRUD (Create, Read, Update, Delete) operations on &lt;strong&gt;resources&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Detail&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Protocol&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;HTTP/HTTPS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Format&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;JSON (most common), XML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Philosophy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Stateless, resource-oriented (everything is an entity, e.g., a "user" or "order").&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best For&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Public-facing APIs, simple mobile/web apps, and basic CRUD operations.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  🔍 Example: Fetching a User Profile
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt; A client wants to retrieve information for User ID &lt;code&gt;101&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Request&lt;/th&gt;
&lt;th&gt;Response (JSON)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Read&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;GET /api/v1/users/101&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;json\n{\n  "id": 101,\n  "name": "Alice Developer",\n  "email": "alice@example.com",\n  "status": "Active"\n}\n&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 |&lt;br&gt;
| &lt;strong&gt;Create&lt;/strong&gt; | &lt;code&gt;POST /api/v1/users&lt;/code&gt; (with JSON body) | &lt;strong&gt;Status:&lt;/strong&gt; &lt;code&gt;201 Created&lt;/code&gt; |&lt;br&gt;
| &lt;strong&gt;Update&lt;/strong&gt; | &lt;code&gt;PUT /api/v1/users/101&lt;/code&gt; (with new data) | &lt;strong&gt;Status:&lt;/strong&gt; &lt;code&gt;200 OK&lt;/code&gt; |&lt;br&gt;
| &lt;strong&gt;Delete&lt;/strong&gt; | &lt;code&gt;DELETE /api/v1/users/101&lt;/code&gt; | &lt;strong&gt;Status:&lt;/strong&gt; &lt;code&gt;204 No Content&lt;/code&gt; |&lt;/p&gt;




&lt;h2&gt;
  
  
  2. GraphQL (Graph Query Language)
&lt;/h2&gt;

&lt;p&gt;GraphQL is a data query and manipulation language for APIs that allows clients to specify &lt;strong&gt;exactly the data they need&lt;/strong&gt;. This prevents the problem of &lt;strong&gt;over-fetching&lt;/strong&gt; (receiving unwanted data) common in REST.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Detail&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Protocol&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;HTTP (usually via a single endpoint)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Format&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;JSON&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Philosophy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Client-driven data fetching; single endpoint, flexible queries based on a strong type schema.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best For&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Mobile apps, complex dashboard UIs, and projects where data consumption needs to be highly optimized.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  🔍 Example: Optimized Data Fetching
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt; A client needs a user's name, email, and only the title of their last two blog posts.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Request (Query)&lt;/th&gt;
&lt;th&gt;Response (JSON)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;graphql\nquery UserProfile {\n  user(id: "101") {\n    name\n    email\n    posts(limit: 2) {\n      title\n    }\n  }\n}\n&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 |&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;json\n{\n  "data": {\n    "user": {\n      "name": "Alice Developer",\n      "email": "alice@example.com",\n      "posts": [\n        { "title": "Intro to GraphQL" },\n        { "title": "Why I chose gRPC" }\n      ]\n    }\n  }\n}\n&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 |&lt;br&gt;
| &lt;strong&gt;Mutation&lt;/strong&gt; | &lt;code&gt;mutation UpdateUser(...)&lt;/code&gt; | Similar to a &lt;code&gt;POST&lt;/code&gt; or &lt;code&gt;PUT&lt;/code&gt; in REST, used for data modification. |&lt;/p&gt;




&lt;h2&gt;
  
  
  3. gRPC (Google Remote Procedure Call)
&lt;/h2&gt;

&lt;p&gt;gRPC is a high-performance framework based on the Remote Procedure Call (RPC) model. It uses &lt;strong&gt;Protocol Buffers (Protobuf)&lt;/strong&gt; for data serialization and &lt;strong&gt;HTTP/2&lt;/strong&gt; for transport, making it exceptionally fast for machine-to-machine communication.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Detail&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Protocol&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;HTTP/2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Format&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Protocol Buffers (a binary format)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Philosophy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Contract-first (defined by Protobuf schema); focused on calling a function/method on a remote server.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best For&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Microservices, inter-service communication, real-time data ingestion, and any performance-critical system.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  🔍 Example: Inter-Service Communication
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt; An Order Processing service calls a remote Inventory service to check stock.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Protobuf Contract (Service Definition)&lt;/th&gt;
&lt;th&gt;Client Call (Code Representation)&lt;/th&gt;
&lt;th&gt;Server Response (Code Representation)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;protobuf\nservice InventoryService {\n  rpc CheckStock (StockRequest) returns (StockResponse);\n}\nmessage StockRequest {\n  string product_id = 1;\n}\nmessage StockResponse {\n  int32 quantity = 1;\n  bool in_stock = 2;\n}\n&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 | &lt;code&gt;inventoryClient.CheckStock({product_id: "P456"})&lt;/code&gt; | &lt;code&gt;StockResponse { quantity: 50, in_stock: true }&lt;/code&gt; |&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The actual data transfer is a compacted binary message, not readable JSON, which is key to its speed.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. SOAP (Simple Object Access Protocol)
&lt;/h2&gt;

&lt;p&gt;SOAP is a formal, standardized &lt;strong&gt;protocol&lt;/strong&gt; that relies on XML for structured messaging. It is contract-first, meaning the available operations are rigidly defined in a &lt;strong&gt;WSDL (Web Services Description Language)&lt;/strong&gt; file.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Detail&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Protocol&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;HTTP, SMTP, or others&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Format&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;XML (enveloped messaging)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Philosophy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Strict contracts, high security, and built-in error handling via SOAP faults.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best For&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Legacy systems, highly regulated industries (banking, healthcare), and environments requiring formal contracts and enterprise-grade security.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  🔍 Example: Financial Transaction
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt; Submitting a secure payment for Order ID &lt;code&gt;ORD789&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Request (XML)&lt;/th&gt;
&lt;th&gt;Response (XML)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Invoke&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
 &lt;code&gt;xml\n&amp;lt;soap:Envelope&amp;gt;\n  &amp;lt;soap:Body&amp;gt;\n    &amp;lt;SubmitPayment&amp;gt;\n      &amp;lt;OrderId&amp;gt;ORD789&amp;lt;/OrderId&amp;gt;\n      &amp;lt;Amount&amp;gt;99.99&amp;lt;/Amount&amp;gt;\n    &amp;lt;/SubmitPayment&amp;gt;\n  &amp;lt;/soap:Body&amp;gt;\n&amp;lt;/soap:Envelope&amp;gt;\n&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 |&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;xml\n&amp;lt;soap:Envelope&amp;gt;\n  &amp;lt;soap:Body&amp;gt;\n    &amp;lt;SubmitPaymentResponse&amp;gt;\n      &amp;lt;Status&amp;gt;Success&amp;lt;/Status&amp;gt;\n      &amp;lt;TransactionId&amp;gt;TXN12345&amp;lt;/TransactionId&amp;gt;\n    &amp;lt;/SubmitPaymentResponse&amp;gt;\n  &amp;lt;/soap:Body&amp;gt;\n&amp;lt;/soap:Envelope&amp;gt;\n&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 |&lt;/p&gt;




&lt;h2&gt;
  
  
  5. WebSocket
&lt;/h2&gt;

&lt;p&gt;WebSocket is a communication protocol that provides a &lt;strong&gt;persistent, two-way (full-duplex) channel&lt;/strong&gt; over a single TCP connection. It is not request/response-based like the others; it's stream-based.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Detail&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Protocol&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;WebSocket (starts as HTTP upgrade)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Format&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Any (usually JSON or Protobuf)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Philosophy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Real-time, event-driven, low-latency, and continuous data push.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best For&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Live chat, multiplayer games, real-time dashboards, and instant notifications.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  🔍 Example: Live Stock Ticker
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt; A user opens a stock trading app and subscribes to real-time updates for a stock symbol.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Client $\leftrightarrow$ Server&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Initial Handshake&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;HTTP Upgrade Request $\rightarrow$ HTTP Switch Protocol Response&lt;/td&gt;
&lt;td&gt;Establishes the persistent WebSocket connection.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Client Action&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;send('{"action": "subscribe", "symbol": "GOOG"}')&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The client tells the server what data it wants.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Server Response (Real-Time Push)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;push('{"symbol": "GOOG", "price": 175.40, "time": 1678886400}')&lt;/code&gt; (Pushed by server)&lt;/td&gt;
&lt;td&gt;The server instantly sends data frames to the client whenever the price changes.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
    </item>
    <item>
      <title>npm vs. Yarn vs. pnpm: A Developer's Guide to Choosing the Right Package Manager</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Mon, 06 Oct 2025 11:47:30 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/npm-vs-yarn-vs-pnpm-a-developers-guide-to-choosing-the-right-package-manager-285f</link>
      <guid>https://dev.to/amrishkhan05/npm-vs-yarn-vs-pnpm-a-developers-guide-to-choosing-the-right-package-manager-285f</guid>
      <description>&lt;p&gt;In the fast-paced world of JavaScript development, the tools we use can significantly impact our productivity, project performance, and even our sanity. At the heart of this tooling ecosystem lies the package manager, the unsung hero that wrangles our project's dependencies. For years, npm was the undisputed king. Then came Yarn, promising speed and reliability. Now, pnpm has entered the fray, championing efficiency.&lt;/p&gt;

&lt;p&gt;So, which one is the best? The answer, as is often the case in tech, is: &lt;strong&gt;it depends&lt;/strong&gt;. Let's break down the architecture, pros, and cons of each to help you make an informed decision for your next project. 👨‍💻&lt;/p&gt;




&lt;h2&gt;
  
  
  npm: The Original Gangster
&lt;/h2&gt;

&lt;p&gt;npm (Node Package Manager) is the default package manager that comes bundled with every Node.js installation. It's the original, the most widely known, and has the largest registry of packages in the world.&lt;/p&gt;

&lt;h3&gt;
  
  
  How It Works: Nested &amp;amp; Flat Dependencies
&lt;/h3&gt;

&lt;p&gt;Initially, npm used a &lt;strong&gt;nested dependency structure&lt;/strong&gt;. If you had two packages, &lt;code&gt;A&lt;/code&gt; and &lt;code&gt;B&lt;/code&gt;, that both depended on &lt;code&gt;lodash&lt;/code&gt;, you would get two copies of &lt;code&gt;lodash&lt;/code&gt; in your &lt;code&gt;node_modules&lt;/code&gt; folder. This caused the infamous "node_modules black hole" problem, leading to deeply nested directories and massive folder sizes.&lt;/p&gt;

&lt;p&gt;Since npm v3, it has adopted a &lt;strong&gt;flat dependency structure&lt;/strong&gt;. It hoists all dependencies to the top level of &lt;code&gt;node_modules&lt;/code&gt; to avoid duplication. If different packages require different versions of the same dependency, npm will only hoist the compatible version and nest the others where needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-World Example
&lt;/h3&gt;

&lt;p&gt;Let's install &lt;code&gt;express&lt;/code&gt;, a popular web framework that has its own set of dependencies.&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;# Initialize a project and install express&lt;/span&gt;
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your &lt;code&gt;node_modules&lt;/code&gt; will look something like this (simplified):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_modules/
├── accepts
├── array-flatten
├── body-parser
├── content-disposition
├── cookie
├── cookie-signature
├── debug
├── ...
└── express  &amp;lt;-- Your direct dependency
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Verdict:&lt;/strong&gt; npm is reliable, easy to use, and deeply integrated into the Node.js ecosystem. Its performance has improved dramatically over the years, making it a perfectly viable and simple choice for most projects, especially for beginners.&lt;/p&gt;




&lt;h2&gt;
  
  
  Yarn: The Challenger for Speed and Reliability
&lt;/h2&gt;

&lt;p&gt;Yarn was created by Facebook (now Meta) in 2016 to address npm's shortcomings at the time, primarily focusing on performance and security. It introduced a lockfile (&lt;code&gt;yarn.lock&lt;/code&gt;) to ensure deterministic installations, meaning every developer on a team gets the exact same dependency tree.&lt;/p&gt;

&lt;h3&gt;
  
  
  How It Works: Flat Dependencies &amp;amp; More
&lt;/h3&gt;

&lt;p&gt;Like modern npm, Yarn uses a &lt;strong&gt;flat dependency structure&lt;/strong&gt;. However, its installation algorithm was initially much faster and more efficient. Yarn also introduced powerful features like &lt;strong&gt;Workspaces&lt;/strong&gt; for managing monorepos and an offline cache.&lt;/p&gt;

&lt;p&gt;Its most innovative feature is &lt;strong&gt;Plug'n'Play (PnP)&lt;/strong&gt;, an alternative installation strategy that gets rid of the &lt;code&gt;node_modules&lt;/code&gt; folder entirely. Instead of resolving modules by traversing a massive folder, Yarn PnP generates a single &lt;code&gt;.pnp.cjs&lt;/code&gt; file that maps package names and versions to their locations on the disk. This results in near-instantaneous startup times and a much cleaner project structure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-World Example
&lt;/h3&gt;

&lt;p&gt;Using Yarn Workspaces in a monorepo is a game-changer. Imagine a project with a shared &lt;code&gt;ui-library&lt;/code&gt; and two applications (&lt;code&gt;webapp&lt;/code&gt; and &lt;code&gt;mobileapp&lt;/code&gt;) that use it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;project&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;root&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"private"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"workspaces"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"packages/*"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, when you run &lt;code&gt;yarn install&lt;/code&gt; in the root, Yarn will install all dependencies for all packages and link them together. If you update &lt;code&gt;ui-library&lt;/code&gt;, both &lt;code&gt;webapp&lt;/code&gt; and &lt;code&gt;mobileapp&lt;/code&gt; will get the changes instantly without needing to be published to a registry. This dramatically speeds up development in large, interconnected codebases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verdict:&lt;/strong&gt; Yarn is an excellent choice for complex projects, especially &lt;strong&gt;monorepos&lt;/strong&gt;, where features like Workspaces provide immense value. While its speed advantage over npm has narrowed, its robust feature set keeps it a top contender for professional development teams. 🚀&lt;/p&gt;




&lt;h2&gt;
  
  
  pnpm: The Efficiency Expert
&lt;/h2&gt;

&lt;p&gt;pnpm stands for "performant npm." Its primary goal is to solve two major problems with &lt;code&gt;node_modules&lt;/code&gt;: disk space usage and installation speed. It achieves this with a brilliant and unique architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  How It Works: Content-Addressable Storage &amp;amp; Symlinks
&lt;/h3&gt;

&lt;p&gt;pnpm doesn't just flatten your dependency tree; it completely reimagines &lt;code&gt;node_modules&lt;/code&gt;. Here’s the magic:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Global Store:&lt;/strong&gt; When you install a package, pnpm downloads it into a single, content-addressable store on your machine (usually &lt;code&gt;~/.pnpm-store&lt;/code&gt;). It's "content-addressable," meaning a package's content is stored only once, indexed by its hash.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Symlinking:&lt;/strong&gt; In your project's &lt;code&gt;node_modules&lt;/code&gt; folder, pnpm doesn't copy files. Instead, it creates &lt;strong&gt;symbolic links (symlinks)&lt;/strong&gt; to the packages in the global store.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This means if 10 of your projects use &lt;code&gt;lodash@4.17.21&lt;/code&gt;, that version of &lt;code&gt;lodash&lt;/code&gt; is only physically stored on your disk &lt;strong&gt;once&lt;/strong&gt;. Every project just points to it. This leads to massive savings in disk space and lightning-fast installations, as dependencies are often just linked instead of being copied.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-World Example
&lt;/h3&gt;

&lt;p&gt;Let's run the same &lt;code&gt;express&lt;/code&gt; installation with pnpm.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;install &lt;/span&gt;express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your &lt;code&gt;node_modules&lt;/code&gt; folder will look very different and much cleaner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_modules/
├── .pnpm/  &amp;lt;-- Where the magic happens (symlinks to the real files)
└── express -&amp;gt; .pnpm/express@4.18.2/node_modules/express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only &lt;code&gt;express&lt;/code&gt; is directly accessible in the root of &lt;code&gt;node_modules&lt;/code&gt;. Its own dependencies are nested within the &lt;code&gt;.pnpm&lt;/code&gt; folder, preventing your code from accessing packages that aren't explicitly declared in your &lt;code&gt;package.json&lt;/code&gt;—a common source of bugs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verdict:&lt;/strong&gt; For developers concerned with &lt;strong&gt;disk space and performance&lt;/strong&gt;, pnpm is the undisputed champion. Its strict dependency resolution also prevents a class of "phantom dependency" bugs. It's an ideal choice for CI/CD environments, monorepos, and anyone working on multiple projects. 🥇&lt;/p&gt;




&lt;h2&gt;
  
  
  The Final Showdown: Which is Best for You?
&lt;/h2&gt;

&lt;p&gt;To make your decision easier, here's a concise comparison:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;npm&lt;/th&gt;
&lt;th&gt;Yarn&lt;/th&gt;
&lt;th&gt;pnpm&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Performance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Good&lt;/td&gt;
&lt;td&gt;Very Good&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Excellent ⚡️&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Disk Space&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Okay (flat &lt;code&gt;node_modules&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Okay (similar to npm)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Excellent (shared global store) 💾&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Dependency Model&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Flat&lt;/td&gt;
&lt;td&gt;Flat (with optional PnP)&lt;/td&gt;
&lt;td&gt;Symlinked from a global store&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Key Feature&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Bundled with Node.js, simplicity&lt;/td&gt;
&lt;td&gt;Workspaces, Plug'n'Play (PnP)&lt;/td&gt;
&lt;td&gt;Unmatched efficiency, strictness&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best For&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Beginners, small-to-medium projects&lt;/td&gt;
&lt;td&gt;Large monorepos, professional teams&lt;/td&gt;
&lt;td&gt;Performance-critical projects, CI/CD, limited disk&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Choosing Your Champion:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Go with npm&lt;/strong&gt; if you value simplicity, are new to JavaScript development, or are working on smaller projects where the default is perfectly adequate. It's the most common and has the largest community support.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Opt for Yarn&lt;/strong&gt; if you're managing complex monorepos, need robust workspace features, or are interested in cutting-edge features like Plug'n'Play for highly optimized cold starts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embrace pnpm&lt;/strong&gt; if performance and disk efficiency are paramount. For CI/CD pipelines, machines with limited disk space, or projects where every millisecond counts, pnpm offers a truly superior experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No matter your choice, each of these package managers has evolved significantly, offering robust and reliable ways to handle your project's dependencies. Experiment with them, understand their strengths, and pick the tool that empowers you to build the best software possible.&lt;/p&gt;

</description>
      <category>npm</category>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>The Postman Alternative Guide: Which API Client is Right for You in 2025?</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Mon, 06 Oct 2025 11:44:59 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/the-postman-alternative-guide-which-api-client-is-right-for-you-in-2025-2p0b</link>
      <guid>https://dev.to/amrishkhan05/the-postman-alternative-guide-which-api-client-is-right-for-you-in-2025-2p0b</guid>
      <description>&lt;p&gt;For years, Postman has reigned as the undisputed champion of API clients. Its robust feature set for designing, testing, and documenting APIs has made it an essential tool for millions of developers. But the world of software development is not one-size-fits-all.&lt;/p&gt;

&lt;p&gt;As workflows evolve, developers are increasingly seeking tools that are more lightweight, open-source, better integrated with version control, or specialized for protocols like GraphQL and gRPC. If you find yourself wondering what else is out there, you're in the right place.&lt;/p&gt;

&lt;p&gt;This guide will walk you through the best Postman alternatives on the market today, helping you find the perfect tool for your specific needs.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  The All-Rounder GUI Clients
&lt;/h2&gt;

&lt;p&gt;These are the most direct competitors to Postman, offering a rich, graphical interface for a comprehensive API testing experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Insomnia
&lt;/h3&gt;

&lt;p&gt;Often hailed as Postman's biggest rival, &lt;strong&gt;Insomnia&lt;/strong&gt; offers a sleek, modern, and highly performant user interface. It excels in its clean design and first-class support for modern API protocols.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Key Features:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Native support for REST, GraphQL, SOAP, and gRPC.&lt;/li&gt;
&lt;li&gt;Powerful environment and sub-environment management.&lt;/li&gt;
&lt;li&gt;Plugin system to extend functionality (e.g., custom themes, AWS authentication).&lt;/li&gt;
&lt;li&gt;Advanced code generation for over 30 languages and libraries.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Best for:&lt;/strong&gt; Developers who work heavily with GraphQL or gRPC and appreciate a fast, clean interface.&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Hoppscotch (formerly Postwoman)
&lt;/h3&gt;

&lt;p&gt;Born from a need for a fast, open-source, and web-based alternative, &lt;strong&gt;Hoppscotch&lt;/strong&gt; has grown into a mature and feature-rich platform. Its ability to run directly in the browser makes it incredibly accessible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Key Features:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Completely free and open-source.&lt;/li&gt;
&lt;li&gt;Web-based, installable as a PWA (Progressive Web App).&lt;/li&gt;
&lt;li&gt;Real-time collaboration features with support for teams and shared collections.&lt;/li&gt;
&lt;li&gt;Excellent support for REST, GraphQL, and real-time protocols like WebSocket and MQTT.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Best for:&lt;/strong&gt; Teams looking for a free, collaborative, and easily accessible solution without requiring a desktop installation.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Version Control Champions
&lt;/h2&gt;

&lt;p&gt;For developers who believe API tests are code and should be treated as such, these tools offer seamless integration with Git.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bruno
&lt;/h3&gt;

&lt;p&gt;A rising star in the API client world, &lt;strong&gt;Bruno&lt;/strong&gt; is built with a "Git-friendly" philosophy at its core. It stores all your API collections directly on your local filesystem in plain text files, making version control a breeze.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Key Features:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Offline-first and completely local storage (no cloud sync unless you use Git).&lt;/li&gt;
&lt;li&gt;Collections are stored in a simple, human-readable markup language (&lt;code&gt;Bru&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Easy to collaborate on API tests via pull requests.&lt;/li&gt;
&lt;li&gt;Built-in support for scripting and assertions using JavaScript.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Best for:&lt;/strong&gt; Developers and DevOps engineers who want to manage their API collections and tests within their existing Git workflow.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Lightweight &amp;amp; In-Editor Heroes
&lt;/h2&gt;

&lt;p&gt;Why leave your code editor? These extensions bring API testing directly into your development environment, streamlining your workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Thunder Client
&lt;/h3&gt;

&lt;p&gt;If you live inside Visual Studio Code, &lt;strong&gt;Thunder Client&lt;/strong&gt; is a game-changer. It’s a lightweight and rest-client extension that provides a clean, Postman-like interface without ever needing to switch windows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Key Features:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Fully integrated within VS Code's UI.&lt;/li&gt;
&lt;li&gt;Supports collections, environment variables, and GraphQL.&lt;/li&gt;
&lt;li&gt;Simple interface for testing and viewing responses.&lt;/li&gt;
&lt;li&gt;Git-friendly, as collections can be saved as a JSON file in your project.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Best for:&lt;/strong&gt; VS Code users who need a fast and convenient way to run API requests without the overhead of a separate application.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Command-Line Champions
&lt;/h2&gt;

&lt;p&gt;For those who prefer the speed and scriptability of the terminal, these CLI tools are unmatched in power and flexibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. cURL
&lt;/h3&gt;

&lt;p&gt;The original. &lt;strong&gt;cURL&lt;/strong&gt; is the Swiss Army knife of data transfer and is pre-installed on virtually every Linux and macOS system. While it has a steep learning curve, its power for scripting and automation is unparalleled.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Key Features:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Ubiquitous and incredibly versatile.&lt;/li&gt;
&lt;li&gt;Highly scriptable for use in shell scripts, CI/CD pipelines, and automated tasks.&lt;/li&gt;
&lt;li&gt;Supports a massive range of protocols.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Best for:&lt;/strong&gt; Automation, scripting, and quick, one-off requests directly from the terminal.&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. HTTPie
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;HTTPie&lt;/strong&gt; is designed to be a "cURL for humans." It offers the power of a CLI tool but with a much more intuitive syntax, sensible defaults, and beautiful, colorized output.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Key Features:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Simple, expressive command syntax (e.g., &lt;code&gt;http GET example.org q=='search term'&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;JSON is the default, making it perfect for modern APIs.&lt;/li&gt;
&lt;li&gt;Formatted and colorized terminal output for easy reading.&lt;/li&gt;
&lt;li&gt;Persistent sessions and plugin support.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Best for:&lt;/strong&gt; Developers who love the command line but want a more user-friendly experience than cURL.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  So, Which Tool Should You Choose?
&lt;/h2&gt;

&lt;p&gt;The best API client depends entirely on your workflow. Ask yourself these questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Do I need team collaboration?&lt;/strong&gt; Look at &lt;strong&gt;Hoppscotch&lt;/strong&gt; or the team plans for &lt;strong&gt;Insomnia&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is version control a top priority?&lt;/strong&gt; &lt;strong&gt;Bruno&lt;/strong&gt; is built from the ground up for this. &lt;strong&gt;Thunder Client&lt;/strong&gt; also works well with Git.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do I work mostly inside my IDE?&lt;/strong&gt; &lt;strong&gt;Thunder Client&lt;/strong&gt; for VS Code is your best bet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Is open-source a must-have?&lt;/strong&gt; &lt;strong&gt;Hoppscotch&lt;/strong&gt; and &lt;strong&gt;Bruno&lt;/strong&gt; are excellent, fully open-source choices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do I need to automate tests in a CI/CD pipeline?&lt;/strong&gt; &lt;strong&gt;cURL&lt;/strong&gt;, &lt;strong&gt;HTTPie&lt;/strong&gt;, or a dedicated framework like &lt;strong&gt;Karate&lt;/strong&gt; are ideal.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The days of a one-tool-fits-all approach are over. The modern API ecosystem offers a fantastic array of clients, each with unique strengths. Don't be afraid to step outside your comfort zone and try a new tool—you might just find the perfect fit to supercharge your development process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's your go-to API client? Share your favorites in the comments below!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>api</category>
      <category>tooling</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
