<?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>Promise.all() Is Not Parallelism — And It Can Break Your System</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Sat, 09 May 2026 06:56:00 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/promiseall-is-not-parallelism-and-it-can-break-your-system-43ec</link>
      <guid>https://dev.to/amrishkhan05/promiseall-is-not-parallelism-and-it-can-break-your-system-43ec</guid>
      <description>&lt;p&gt;&lt;code&gt;Promise.all()&lt;/code&gt; looks innocent.&lt;/p&gt;

&lt;p&gt;It is one of those JavaScript features most developers learn early and start using everywhere.&lt;/p&gt;

&lt;p&gt;Fetch multiple APIs? Use &lt;code&gt;Promise.all()&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
Insert multiple rows? Use &lt;code&gt;Promise.all()&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
Upload multiple files? Use &lt;code&gt;Promise.all()&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
Call GitHub API for many blobs? Use &lt;code&gt;Promise.all()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;At first, it feels clean.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;processItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One line. Beautiful. Fast. Modern.&lt;/p&gt;

&lt;p&gt;But here is the uncomfortable truth:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;Promise.all()&lt;/code&gt; is not a performance strategy. It is a concurrency trigger.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And if you use it blindly, it can quietly break your system.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem Is Not Promise.all() Itself
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Promise.all()&lt;/code&gt; is not bad.&lt;/p&gt;

&lt;p&gt;It is useful, powerful, and perfectly fine when the number of promises is small and controlled.&lt;/p&gt;

&lt;p&gt;The problem starts when developers use it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&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;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;sendEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looks harmless.&lt;/p&gt;

&lt;p&gt;But what if &lt;code&gt;users.length&lt;/code&gt; is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;000&lt;/span&gt;
&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the same line behaves very differently.&lt;/p&gt;

&lt;p&gt;That one line can suddenly create:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1,000 API requests&lt;/li&gt;
&lt;li&gt;1,000 database queries&lt;/li&gt;
&lt;li&gt;1,000 file operations&lt;/li&gt;
&lt;li&gt;1,000 network connections&lt;/li&gt;
&lt;li&gt;1,000 memory allocations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All at once.&lt;/p&gt;

&lt;p&gt;That is where systems start to fail.&lt;/p&gt;




&lt;h2&gt;
  
  
  Promise.all() Does Not Mean “Run Safely in Parallel”
&lt;/h2&gt;

&lt;p&gt;This is the biggest misunderstanding.&lt;/p&gt;

&lt;p&gt;A lot of developers think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Promise.all() runs things in parallel.”&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;JavaScript does not magically create safe parallel execution for your workload.&lt;/p&gt;

&lt;p&gt;What actually happens is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;all async operations are started immediately&lt;/li&gt;
&lt;li&gt;JavaScript keeps references to all promises&lt;/li&gt;
&lt;li&gt;the runtime waits until all resolve&lt;/li&gt;
&lt;li&gt;if one rejects, &lt;code&gt;Promise.all()&lt;/code&gt; rejects immediately&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That means &lt;code&gt;Promise.all()&lt;/code&gt; does not control load.&lt;/p&gt;

&lt;p&gt;It does not limit concurrency.&lt;/p&gt;

&lt;p&gt;It does not respect API rate limits.&lt;/p&gt;

&lt;p&gt;It does not care about your database pool.&lt;/p&gt;

&lt;p&gt;It does not protect your server memory.&lt;/p&gt;

&lt;p&gt;It simply starts everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hidden Cost of Starting Everything at Once
&lt;/h2&gt;

&lt;p&gt;Let’s say you are processing 5,000 records.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;records&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;record&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;processRecord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;record&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This may look efficient.&lt;/p&gt;

&lt;p&gt;But internally, you might be doing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;processRecord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;record&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;RecordItem&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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findUnique&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;record&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&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;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;externalApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;auditLog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;data&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now multiply that by 5,000.&lt;/p&gt;

&lt;p&gt;Suddenly you are not just running 5,000 promises.&lt;/p&gt;

&lt;p&gt;You may be creating:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;5,000 DB reads&lt;/li&gt;
&lt;li&gt;5,000 external API calls&lt;/li&gt;
&lt;li&gt;5,000 audit log writes&lt;/li&gt;
&lt;li&gt;thousands of objects in memory&lt;/li&gt;
&lt;li&gt;thousands of open sockets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not optimization.&lt;/p&gt;

&lt;p&gt;This is a traffic accident.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Concurrency Explosions
&lt;/h2&gt;

&lt;p&gt;A concurrency explosion happens when your code starts more async work than the system can safely handle.&lt;/p&gt;

&lt;p&gt;The dangerous part is that the code often looks clean.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uploadFile&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But if there are 2,000 files, you just started 2,000 uploads.&lt;/p&gt;

&lt;p&gt;A better question is not:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Can JavaScript run this?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The better question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Can every system behind this operation handle it?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Because your code may depend on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;database pool limits&lt;/li&gt;
&lt;li&gt;third-party API limits&lt;/li&gt;
&lt;li&gt;CPU availability&lt;/li&gt;
&lt;li&gt;memory capacity&lt;/li&gt;
&lt;li&gt;disk I/O&lt;/li&gt;
&lt;li&gt;network stability&lt;/li&gt;
&lt;li&gt;cloud provider throttling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Promise.all()&lt;/code&gt; ignores all of that.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Rate Limiting Problems
&lt;/h2&gt;

&lt;p&gt;Third-party APIs usually do not like sudden request spikes.&lt;/p&gt;

&lt;p&gt;If you call an API 500 times at once, you may hit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;429 Too Many Requests&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;temporary bans&lt;/li&gt;
&lt;li&gt;request throttling&lt;/li&gt;
&lt;li&gt;degraded responses&lt;/li&gt;
&lt;li&gt;random timeouts&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&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;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;paymentProvider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This may work in development with 5 users.&lt;/p&gt;

&lt;p&gt;Then fail badly in production with 5,000 users.&lt;/p&gt;

&lt;p&gt;The code did not change.&lt;/p&gt;

&lt;p&gt;The data size did.&lt;/p&gt;

&lt;p&gt;That is why &lt;code&gt;Promise.all()&lt;/code&gt; bugs often appear only under real traffic.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Memory Spikes
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Promise.all()&lt;/code&gt; keeps track of all promises and their results.&lt;/p&gt;

&lt;p&gt;If each result is small, that is fine.&lt;/p&gt;

&lt;p&gt;But if each operation returns a large object, file buffer, API response, or parsed payload, memory usage can spike quickly.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;largeFiles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;readAndParseFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If each parsed file is 20 MB and you process 100 files, you may suddenly hold gigabytes of data in memory.&lt;/p&gt;

&lt;p&gt;That can lead to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;slow garbage collection&lt;/li&gt;
&lt;li&gt;process crashes&lt;/li&gt;
&lt;li&gt;container restarts&lt;/li&gt;
&lt;li&gt;server instability&lt;/li&gt;
&lt;li&gt;out-of-memory errors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sometimes the safer solution is to process data in batches or streams instead of loading everything together.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Database Connection Exhaustion
&lt;/h2&gt;

&lt;p&gt;This one is extremely common.&lt;/p&gt;

&lt;p&gt;Most databases use connection pools.&lt;/p&gt;

&lt;p&gt;For example, your app may have a pool limit of 10, 20, or 50 connections.&lt;/p&gt;

&lt;p&gt;Now imagine doing this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;orders.length&lt;/code&gt; is 1,000, your code tries to schedule 1,000 DB operations immediately.&lt;/p&gt;

&lt;p&gt;But your database pool may only support 20 active connections.&lt;/p&gt;

&lt;p&gt;The rest wait.&lt;/p&gt;

&lt;p&gt;Then things start piling up.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;connection timeout&lt;/li&gt;
&lt;li&gt;slow queries&lt;/li&gt;
&lt;li&gt;locked rows&lt;/li&gt;
&lt;li&gt;deadlocks&lt;/li&gt;
&lt;li&gt;pool exhaustion&lt;/li&gt;
&lt;li&gt;failed transactions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Again, &lt;code&gt;Promise.all()&lt;/code&gt; is not aware of your database limit.&lt;/p&gt;

&lt;p&gt;It will happily overload it.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. API Throttling and Socket Errors
&lt;/h2&gt;

&lt;p&gt;I faced a real version of this while working with GitHub APIs.&lt;/p&gt;

&lt;p&gt;Creating blobs through the GitHub API looked simple at first.&lt;/p&gt;

&lt;p&gt;The tempting version was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createBlob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clean, yes. Safe, no.&lt;/p&gt;

&lt;p&gt;With many files, this could trigger network instability, throttling, or random failures such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;socket hang up&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;write EPIPE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ECONNRESET&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;request timeout&lt;/li&gt;
&lt;li&gt;temporary GitHub API failures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The fix was not to “make Promise.all better.”&lt;/p&gt;

&lt;p&gt;The fix was to stop launching everything at once.&lt;/p&gt;

&lt;p&gt;Instead, the safer approach was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;limit concurrency&lt;/li&gt;
&lt;li&gt;process files in small batches&lt;/li&gt;
&lt;li&gt;retry only retryable failures&lt;/li&gt;
&lt;li&gt;fail fast for validation errors&lt;/li&gt;
&lt;li&gt;avoid retrying &lt;code&gt;400 Bad Request&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;use exponential backoff&lt;/li&gt;
&lt;li&gt;reduce concurrent blob creation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That changed the mindset completely.&lt;/p&gt;

&lt;p&gt;The goal was no longer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“How do I make this as parallel as possible?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The goal became:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“How do I make this fast enough without destroying reliability?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is the real engineering question.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Retries Can Make the Problem Worse
&lt;/h2&gt;

&lt;p&gt;Retries sound like a solution.&lt;/p&gt;

&lt;p&gt;But careless retries can multiply the damage.&lt;/p&gt;

&lt;p&gt;Imagine this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nf"&gt;retry&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;callApi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If 500 requests fail due to rate limiting, and each one retries 3 times, you may have created 1,500 more requests.&lt;/p&gt;

&lt;p&gt;Now your retry logic is attacking the same system that already asked you to slow down.&lt;/p&gt;

&lt;p&gt;Retries need discipline.&lt;/p&gt;

&lt;p&gt;Good retry logic should consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;which errors are retryable&lt;/li&gt;
&lt;li&gt;how many times to retry&lt;/li&gt;
&lt;li&gt;how long to wait&lt;/li&gt;
&lt;li&gt;whether to use exponential backoff&lt;/li&gt;
&lt;li&gt;whether to add jitter&lt;/li&gt;
&lt;li&gt;whether the API returned &lt;code&gt;429&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;whether the operation is idempotent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not every error deserves a retry.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;400&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="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Retrying bad requests only wastes time and increases load.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Partial Failures Are Harder Than They Look
&lt;/h2&gt;

&lt;p&gt;Another issue with &lt;code&gt;Promise.all()&lt;/code&gt; is failure behavior.&lt;/p&gt;

&lt;p&gt;If one promise rejects, &lt;code&gt;Promise.all()&lt;/code&gt; rejects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="nf"&gt;uploadFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nf"&gt;uploadFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nf"&gt;uploadFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;file2&lt;/code&gt; fails, the entire &lt;code&gt;Promise.all()&lt;/code&gt; rejects.&lt;/p&gt;

&lt;p&gt;But what about &lt;code&gt;file1&lt;/code&gt; and &lt;code&gt;file3&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;They may have already completed.&lt;/p&gt;

&lt;p&gt;Now your system is in a partial success state.&lt;/p&gt;

&lt;p&gt;This matters when you are doing things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;payment operations&lt;/li&gt;
&lt;li&gt;database writes&lt;/li&gt;
&lt;li&gt;file uploads&lt;/li&gt;
&lt;li&gt;email sending&lt;/li&gt;
&lt;li&gt;inventory updates&lt;/li&gt;
&lt;li&gt;GitHub commits&lt;/li&gt;
&lt;li&gt;external integrations&lt;/li&gt;
&lt;/ul&gt;

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

&lt;blockquote&gt;
&lt;p&gt;“If 7 out of 10 operations succeed, what should happen?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Should you rollback?&lt;/p&gt;

&lt;p&gt;Should you retry only failed items?&lt;/p&gt;

&lt;p&gt;Should you show partial success?&lt;/p&gt;

&lt;p&gt;Should you store failed records for later?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Promise.all()&lt;/code&gt; does not answer those questions.&lt;/p&gt;

&lt;p&gt;Your architecture has to.&lt;/p&gt;




&lt;h2&gt;
  
  
  Promise.allSettled() Is Better for Partial Results
&lt;/h2&gt;

&lt;p&gt;When you care about every result, use &lt;code&gt;Promise.allSettled()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&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;allSettled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;uploadFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then separate success and failure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;successful&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fulfilled&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;failed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rejected&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;This gives you a complete picture.&lt;/p&gt;

&lt;p&gt;But remember:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;Promise.allSettled()&lt;/code&gt; solves visibility. It does not solve concurrency.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It still starts everything at once.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Better Pattern: Limit Concurrency
&lt;/h2&gt;

&lt;p&gt;Instead of launching everything together, process with a concurrency limit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;processInBatches&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;R&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;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;
  &lt;span class="nx"&gt;batchSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;R&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;R&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;results&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;R&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&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="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;batchSize&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;batch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;batchSize&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;batchResults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nx"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;batchResults&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;results&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;processInBatches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;files&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="nx"&gt;uploadFile&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now instead of 1,000 uploads at once, you run 5 at a time.&lt;/p&gt;

&lt;p&gt;That is slower than unlimited concurrency.&lt;/p&gt;

&lt;p&gt;But it is much safer.&lt;/p&gt;

&lt;p&gt;And in production, safe usually wins.&lt;/p&gt;




&lt;h2&gt;
  
  
  Queue Patterns Are Even Better for Heavy Workloads
&lt;/h2&gt;

&lt;p&gt;For large or long-running workloads, batching may still not be enough.&lt;/p&gt;

&lt;p&gt;A queue-based approach is often better.&lt;/p&gt;

&lt;p&gt;A queue gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;controlled concurrency&lt;/li&gt;
&lt;li&gt;retry policies&lt;/li&gt;
&lt;li&gt;delayed jobs&lt;/li&gt;
&lt;li&gt;observability&lt;/li&gt;
&lt;li&gt;pause/resume behavior&lt;/li&gt;
&lt;li&gt;backpressure&lt;/li&gt;
&lt;li&gt;better recovery&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&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;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;processItem&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can push jobs into a queue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&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;item&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;process-item&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then workers process with controlled concurrency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;worker&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;Worker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;process-item&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;processItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;job&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="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;concurrency&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="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is a much healthier model for serious workloads.&lt;/p&gt;




&lt;h2&gt;
  
  
  When Promise.all() Is Actually Fine
&lt;/h2&gt;

&lt;p&gt;This article is not saying never use &lt;code&gt;Promise.all()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It is perfectly fine when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the number of items is small&lt;/li&gt;
&lt;li&gt;the workload is predictable&lt;/li&gt;
&lt;li&gt;there are no strict rate limits&lt;/li&gt;
&lt;li&gt;memory usage is low&lt;/li&gt;
&lt;li&gt;failures should fail the whole operation&lt;/li&gt;
&lt;li&gt;all operations are independent&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;permissions&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="k"&gt;await&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;all&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="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;getSettings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;getPermissions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a good use case.&lt;/p&gt;

&lt;p&gt;The danger starts when the number of promises is dynamic and unbounded.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Simple Rule I Follow Now
&lt;/h2&gt;

&lt;p&gt;Before using &lt;code&gt;Promise.all()&lt;/code&gt;, I ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“How many promises can this create in production?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If the answer is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fine.&lt;/p&gt;

&lt;p&gt;If the answer is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;unknown&lt;/span&gt;
&lt;span class="nx"&gt;hundreds&lt;/span&gt;
&lt;span class="nx"&gt;thousands&lt;/span&gt;
&lt;span class="nx"&gt;depends&lt;/span&gt; &lt;span class="nx"&gt;on&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;
&lt;span class="nx"&gt;depends&lt;/span&gt; &lt;span class="nx"&gt;on&lt;/span&gt; &lt;span class="nx"&gt;database&lt;/span&gt; &lt;span class="nx"&gt;size&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I stop and redesign.&lt;/p&gt;

&lt;p&gt;Because at that point, I do not need raw &lt;code&gt;Promise.all()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I need one of these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;batching&lt;/li&gt;
&lt;li&gt;concurrency limiting&lt;/li&gt;
&lt;li&gt;queue processing&lt;/li&gt;
&lt;li&gt;streaming&lt;/li&gt;
&lt;li&gt;pagination&lt;/li&gt;
&lt;li&gt;retry strategy&lt;/li&gt;
&lt;li&gt;backpressure handling&lt;/li&gt;
&lt;li&gt;partial failure tracking&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Real Lesson
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Promise.all()&lt;/code&gt; is not dangerous because it is broken.&lt;/p&gt;

&lt;p&gt;It is dangerous because it is too easy.&lt;/p&gt;

&lt;p&gt;It makes risky concurrency look elegant.&lt;/p&gt;

&lt;p&gt;It hides operational complexity behind a beautiful one-liner.&lt;/p&gt;

&lt;p&gt;But production systems do not care how clean your code looks.&lt;/p&gt;

&lt;p&gt;They care about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;load&lt;/li&gt;
&lt;li&gt;limits&lt;/li&gt;
&lt;li&gt;memory&lt;/li&gt;
&lt;li&gt;failure modes&lt;/li&gt;
&lt;li&gt;retries&lt;/li&gt;
&lt;li&gt;recovery&lt;/li&gt;
&lt;li&gt;reliability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The best engineers do not just ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Can I run these together?”&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;blockquote&gt;
&lt;p&gt;“How much concurrency can this system safely handle?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is the difference between writing async code and designing resilient systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thought
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Promise.all()&lt;/code&gt; is a tool.&lt;/p&gt;

&lt;p&gt;A very useful one.&lt;/p&gt;

&lt;p&gt;But it should not be your default answer for every async workload.&lt;/p&gt;

&lt;p&gt;Sometimes the fastest code is the code that finishes first in development.&lt;/p&gt;

&lt;p&gt;But the best code is the code that survives production.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;Promise.all()&lt;/code&gt; when the work is small and controlled.&lt;/p&gt;

&lt;p&gt;Use queues, batches, and concurrency limits when the system matters.&lt;/p&gt;

&lt;p&gt;Because &lt;code&gt;Promise.all()&lt;/code&gt; is not parallelism.&lt;/p&gt;

&lt;p&gt;It is pressure.&lt;/p&gt;

&lt;p&gt;And if you do not control that pressure, your system eventually will.&lt;/p&gt;

&lt;h1&gt;
  
  
  About the Author
&lt;/h1&gt;

&lt;p&gt;I’m &lt;a href="https://www.amrishkhan.dev" rel="noopener noreferrer"&gt;Amrish Khan&lt;/a&gt; — a full-stack engineer focused on building fast, privacy-conscious, developer-first applications.&lt;/p&gt;

&lt;p&gt;I’m currently exploring the future of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;local-first developer tooling&lt;/li&gt;
&lt;li&gt;browser-native processing&lt;/li&gt;
&lt;li&gt;AI-efficient workflows&lt;/li&gt;
&lt;li&gt;offline-capable applications&lt;/li&gt;
&lt;li&gt;privacy-focused architectures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m also building &lt;a href="https://www.aruvix.com" rel="noopener noreferrer"&gt;Aruvix&lt;/a&gt; — a growing ecosystem of local-first developer tools designed to process data directly in the browser without unnecessary uploads.&lt;/p&gt;

&lt;p&gt;You can follow my work and thoughts here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Portfolio: &lt;a href="https://www.amrishkhan.dev" rel="noopener noreferrer"&gt;amrishkhan.dev&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/amrishkhan/" rel="noopener noreferrer"&gt;linkedin.com/in/amrishkhan&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>performance</category>
      <category>softwareengineering</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why I’m Building Local-First Developer Tools</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Fri, 08 May 2026 15:26:21 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/why-im-building-local-first-developer-tools-5a8l</link>
      <guid>https://dev.to/amrishkhan05/why-im-building-local-first-developer-tools-5a8l</guid>
      <description>&lt;h2&gt;
  
  
  The Industry Is Quietly Rebalancing Toward Local-First Applications
&lt;/h2&gt;

&lt;p&gt;There’s a strange irony happening in software right now.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Industry Is Quietly Rebalancing Toward Local-First Applications
&lt;/h2&gt;

&lt;p&gt;There’s a strange irony happening in software right now.&lt;/p&gt;

&lt;p&gt;For years, the industry pushed everything toward the cloud.&lt;/p&gt;

&lt;p&gt;Cloud IDEs. Cloud databases. Cloud storage. Cloud AI. Cloud editors. Cloud collaboration. Cloud “smart” everything.&lt;/p&gt;

&lt;p&gt;Somewhere along the way, we normalized sending enormous amounts of personal, sensitive, and often unnecessary data across the internet for even the smallest tasks.&lt;/p&gt;

&lt;p&gt;Need to format JSON? Upload it.&lt;/p&gt;

&lt;p&gt;Need to compare two files? Upload them.&lt;/p&gt;

&lt;p&gt;Need to test an API? Upload the request history.&lt;/p&gt;

&lt;p&gt;Need AI help? Send your codebase.&lt;/p&gt;

&lt;p&gt;Need productivity? Give another app permanent access to your life.&lt;/p&gt;

&lt;p&gt;And most developers accepted this because, honestly, we got used to convenience.&lt;/p&gt;

&lt;p&gt;But over the last few years, I started noticing something: the more “cloud-native” our tools became, the slower, heavier, more invasive, and more expensive they started feeling.&lt;/p&gt;

&lt;p&gt;That realization is one of the biggest reasons I started building local-first developer tools. Not because it sounds trendy, but because I genuinely think the industry is starting to realize that cloud-everything might not actually be the ideal future we imagined.&lt;/p&gt;




&lt;h2&gt;
  
  
  What “Local-First” Actually Means
&lt;/h2&gt;

&lt;p&gt;A lot of people misunderstand local-first architecture.&lt;/p&gt;

&lt;p&gt;It does &lt;strong&gt;not&lt;/strong&gt; mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;no internet&lt;/li&gt;
&lt;li&gt;outdated desktop software&lt;/li&gt;
&lt;li&gt;isolated systems&lt;/li&gt;
&lt;li&gt;anti-cloud ideology&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Local-first simply means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Your device becomes the primary place where computation happens.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The browser. Your machine. Your storage. Your CPU. Your memory.&lt;/p&gt;

&lt;p&gt;The cloud becomes optional infrastructure, not the center of your entire digital existence. That changes everything.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Browser Became Far More Powerful Than Most People Realize
&lt;/h2&gt;

&lt;p&gt;Modern browsers are ridiculously capable now.&lt;/p&gt;

&lt;p&gt;Today, browsers can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;process massive JSON files&lt;/li&gt;
&lt;li&gt;run databases&lt;/li&gt;
&lt;li&gt;execute AI models&lt;/li&gt;
&lt;li&gt;compress files&lt;/li&gt;
&lt;li&gt;render large editors&lt;/li&gt;
&lt;li&gt;stream data&lt;/li&gt;
&lt;li&gt;run WASM applications&lt;/li&gt;
&lt;li&gt;perform encryption&lt;/li&gt;
&lt;li&gt;manipulate media&lt;/li&gt;
&lt;li&gt;cache huge datasets&lt;/li&gt;
&lt;li&gt;work offline&lt;/li&gt;
&lt;li&gt;run local transformations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In many cases, browsers are now powerful enough to replace entire categories of backend-heavy applications.&lt;/p&gt;

&lt;p&gt;But many tools still behave like it’s 2014. Every button triggers a network request. Every feature requires an API. Every interaction depends on a server somewhere.&lt;/p&gt;

&lt;p&gt;And that creates problems developers are finally starting to feel.&lt;/p&gt;




&lt;h2&gt;
  
  
  Cloud-Everything Has a Cost Nobody Talks About
&lt;/h2&gt;

&lt;p&gt;Cloud architecture solved many important problems, but it also introduced a completely different set of problems we rarely discuss openly.&lt;/p&gt;

&lt;p&gt;Many modern systems genuinely require:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;distributed infrastructure&lt;/li&gt;
&lt;li&gt;observability&lt;/li&gt;
&lt;li&gt;collaboration&lt;/li&gt;
&lt;li&gt;auditability&lt;/li&gt;
&lt;li&gt;synchronization&lt;/li&gt;
&lt;li&gt;enterprise orchestration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But we’ve also normalized using cloud infrastructure for workflows that often don’t benefit from it at all. That distinction matters.&lt;/p&gt;




&lt;h2&gt;
  
  
  Privacy Became an Afterthought
&lt;/h2&gt;

&lt;p&gt;This is one of the biggest issues.&lt;/p&gt;

&lt;p&gt;Developers routinely paste:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;production payloads&lt;/li&gt;
&lt;li&gt;API keys&lt;/li&gt;
&lt;li&gt;customer data&lt;/li&gt;
&lt;li&gt;logs&lt;/li&gt;
&lt;li&gt;authentication tokens&lt;/li&gt;
&lt;li&gt;internal configs&lt;/li&gt;
&lt;li&gt;business documents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...into random online tools.&lt;/p&gt;

&lt;p&gt;Not because they’re careless. Because the industry normalized it.&lt;/p&gt;

&lt;p&gt;But once your data leaves your machine, you lose a level of control over it. Even if a service claims:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“We do not store your data”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The data was still transmitted. That matters.&lt;/p&gt;

&lt;p&gt;Especially for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;enterprise systems&lt;/li&gt;
&lt;li&gt;healthcare&lt;/li&gt;
&lt;li&gt;finance&lt;/li&gt;
&lt;li&gt;aviation&lt;/li&gt;
&lt;li&gt;internal tooling&lt;/li&gt;
&lt;li&gt;government systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the core ideas behind local-first tooling is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Many developer tasks never needed the cloud in the first place.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Formatting JSON should not require uploading private payloads. Diffing files should not require transmission. Testing APIs should not require syncing your entire workspace to a remote account.&lt;/p&gt;

&lt;p&gt;Local-first applications do not automatically make software “secure,” but they &lt;em&gt;do&lt;/em&gt; minimize unnecessary exposure surfaces. In many workflows, that’s a meaningful improvement.&lt;/p&gt;




&lt;h2&gt;
  
  
  Performance Is Quietly Getting Worse
&lt;/h2&gt;

&lt;p&gt;Many modern applications feel slower than older software despite massive hardware improvements.&lt;/p&gt;

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

&lt;p&gt;Because modern apps often depend on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;authentication layers&lt;/li&gt;
&lt;li&gt;analytics tracking&lt;/li&gt;
&lt;li&gt;remote synchronization&lt;/li&gt;
&lt;li&gt;telemetry&lt;/li&gt;
&lt;li&gt;server-side processing&lt;/li&gt;
&lt;li&gt;feature flags&lt;/li&gt;
&lt;li&gt;subscriptions&lt;/li&gt;
&lt;li&gt;multiple API chains&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sometimes a simple interaction travels halfway across the world before returning to your screen. That creates avoidable latency.&lt;/p&gt;

&lt;p&gt;For many single-user workflows, local-first applications eliminate that overhead completely. No upload step. No waiting for server processing. No unnecessary round trips.&lt;/p&gt;

&lt;p&gt;The difference becomes especially obvious with developer tooling. A large JSON formatter is a perfect example: uploading massive payloads to a server just to reformat text is often slower than processing directly in the browser. The browser already has the data. Why move it?&lt;/p&gt;




&lt;h2&gt;
  
  
  Offline Capability Is Massively Underrated
&lt;/h2&gt;

&lt;p&gt;We built an industry where software often stops functioning the moment connectivity drops. That’s a surprisingly fragile model.&lt;/p&gt;

&lt;p&gt;Developers work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;on flights&lt;/li&gt;
&lt;li&gt;in trains&lt;/li&gt;
&lt;li&gt;inside unstable networks&lt;/li&gt;
&lt;li&gt;in VPN-heavy environments&lt;/li&gt;
&lt;li&gt;during outages&lt;/li&gt;
&lt;li&gt;inside restricted enterprise systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Yet many modern applications become unusable offline.&lt;/p&gt;

&lt;p&gt;Local-first apps flip that model. The application works first. Connectivity enhances it. That distinction matters.&lt;/p&gt;

&lt;p&gt;Offline capability is not just about convenience. It’s about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;resilience&lt;/li&gt;
&lt;li&gt;continuity&lt;/li&gt;
&lt;li&gt;graceful degradation&lt;/li&gt;
&lt;li&gt;reliability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The best tools should not collapse entirely because a server became unavailable.&lt;/p&gt;




&lt;h2&gt;
  
  
  AI Is Quietly Making Local Processing More Important
&lt;/h2&gt;

&lt;p&gt;This is the part I think most people are underestimating.&lt;/p&gt;

&lt;p&gt;AI changes the economics of software dramatically.&lt;/p&gt;

&lt;p&gt;Every unnecessary cloud operation now has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;compute cost&lt;/li&gt;
&lt;li&gt;token cost&lt;/li&gt;
&lt;li&gt;latency cost&lt;/li&gt;
&lt;li&gt;inference cost&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And developers are starting to notice it.&lt;/p&gt;

&lt;p&gt;Many AI workflows today are incredibly wasteful. Huge payloads get sent to LLMs when only tiny transformations were actually needed.&lt;/p&gt;

&lt;p&gt;People are burning tokens on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;formatting data&lt;/li&gt;
&lt;li&gt;restructuring objects&lt;/li&gt;
&lt;li&gt;validating syntax&lt;/li&gt;
&lt;li&gt;converting formats&lt;/li&gt;
&lt;li&gt;cleaning logs&lt;/li&gt;
&lt;li&gt;filtering payloads&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...for operations that should often happen locally before AI is even involved.&lt;/p&gt;

&lt;p&gt;This is where local-first architecture becomes extremely powerful.&lt;/p&gt;

&lt;p&gt;Imagine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;local preprocessing&lt;/li&gt;
&lt;li&gt;local parsing&lt;/li&gt;
&lt;li&gt;local filtering&lt;/li&gt;
&lt;li&gt;local compression&lt;/li&gt;
&lt;li&gt;local semantic chunking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;before AI requests even happen.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;token usage&lt;/li&gt;
&lt;li&gt;API costs&lt;/li&gt;
&lt;li&gt;response times&lt;/li&gt;
&lt;li&gt;hallucination surfaces&lt;/li&gt;
&lt;li&gt;unnecessary context size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Local-first preprocessing does not replace cloud AI, but it dramatically improves how efficiently AI gets used. In the AI era, that becomes an economic advantage.&lt;/p&gt;




&lt;h2&gt;
  
  
  Browser-Native Processing Is the Future
&lt;/h2&gt;

&lt;p&gt;I genuinely believe we’re entering an era where the browser becomes the operating system for a huge class of applications.&lt;/p&gt;

&lt;p&gt;Not because servers disappear, but because browsers became capable enough to own far more responsibility.&lt;/p&gt;

&lt;p&gt;The old model was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Browser → Server → Processing → Response&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The emerging model is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Browser → Local Processing → Optional Cloud Enhancement&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That shift changes product architecture completely.&lt;/p&gt;

&lt;p&gt;Not every workload belongs in the browser, but far more workloads can now run there efficiently than most applications currently allow.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real Examples of Where Local-First Makes Sense
&lt;/h2&gt;

&lt;h3&gt;
  
  
  JSON Formatting
&lt;/h3&gt;

&lt;p&gt;Traditional flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;upload payload&lt;/li&gt;
&lt;li&gt;process on server&lt;/li&gt;
&lt;li&gt;return formatted response&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Local-first flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;process entirely in browser&lt;/li&gt;
&lt;li&gt;no upload&lt;/li&gt;
&lt;li&gt;instant feedback&lt;/li&gt;
&lt;li&gt;no privacy concerns&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  API Testing
&lt;/h3&gt;

&lt;p&gt;Instead of syncing everything to the cloud:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;request history can stay local&lt;/li&gt;
&lt;li&gt;collections can stay encrypted locally&lt;/li&gt;
&lt;li&gt;sync can become optional&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  AI Workflows
&lt;/h2&gt;

&lt;p&gt;Instead of sending raw noisy payloads directly to AI:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;preprocess locally&lt;/li&gt;
&lt;li&gt;filter irrelevant data&lt;/li&gt;
&lt;li&gt;compress context&lt;/li&gt;
&lt;li&gt;chunk intelligently&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then send only meaningful information to the model.&lt;/p&gt;

&lt;p&gt;That reduces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;token waste&lt;/li&gt;
&lt;li&gt;AI costs&lt;/li&gt;
&lt;li&gt;latency&lt;/li&gt;
&lt;li&gt;context overload&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Local-First Does NOT Mean Anti-Cloud
&lt;/h2&gt;

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

&lt;p&gt;I’m not anti-cloud.&lt;/p&gt;

&lt;p&gt;The cloud is incredible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;collaboration&lt;/li&gt;
&lt;li&gt;backups&lt;/li&gt;
&lt;li&gt;synchronization&lt;/li&gt;
&lt;li&gt;distributed systems&lt;/li&gt;
&lt;li&gt;scalable APIs&lt;/li&gt;
&lt;li&gt;team workflows&lt;/li&gt;
&lt;li&gt;shared state&lt;/li&gt;
&lt;li&gt;large-scale AI inference&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But not every operation deserves cloud involvement.&lt;/p&gt;

&lt;p&gt;The future probably isn’t fully cloud or fully local. It’s hybrid.&lt;/p&gt;

&lt;p&gt;Smart systems will decide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what should stay local&lt;/li&gt;
&lt;li&gt;what should sync&lt;/li&gt;
&lt;li&gt;what should process remotely&lt;/li&gt;
&lt;li&gt;what should never leave the device&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s where things get exciting.&lt;/p&gt;




&lt;h2&gt;
  
  
  Developers Are Starting to Care Again
&lt;/h2&gt;

&lt;p&gt;You can already see the shift happening.&lt;/p&gt;

&lt;p&gt;Developers increasingly care about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ownership&lt;/li&gt;
&lt;li&gt;privacy&lt;/li&gt;
&lt;li&gt;low-latency tooling&lt;/li&gt;
&lt;li&gt;offline workflows&lt;/li&gt;
&lt;li&gt;AI efficiency&lt;/li&gt;
&lt;li&gt;minimalism&lt;/li&gt;
&lt;li&gt;local control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;People are getting tired of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;unnecessary subscriptions&lt;/li&gt;
&lt;li&gt;forced accounts&lt;/li&gt;
&lt;li&gt;cloud lock-in&lt;/li&gt;
&lt;li&gt;telemetry overload&lt;/li&gt;
&lt;li&gt;bloated apps&lt;/li&gt;
&lt;li&gt;“AI-enhanced” features nobody asked for&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There’s a growing desire for tools that simply:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;open fast, work fast, respect privacy, and stay out of the way.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s not nostalgia. That’s good engineering.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Became My Direction
&lt;/h2&gt;

&lt;p&gt;When building tools like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON formatters&lt;/li&gt;
&lt;li&gt;API utilities&lt;/li&gt;
&lt;li&gt;diff tools&lt;/li&gt;
&lt;li&gt;transformers&lt;/li&gt;
&lt;li&gt;developer workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...I kept asking myself:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Does this operation truly need a server?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In many cases, the answer was no.&lt;/p&gt;

&lt;p&gt;That question slowly evolved into a philosophy. A local-first mindset.&lt;/p&gt;

&lt;p&gt;A belief that developer tools should:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;respect the user’s machine&lt;/li&gt;
&lt;li&gt;minimize unnecessary transmission&lt;/li&gt;
&lt;li&gt;reduce dependency chains&lt;/li&gt;
&lt;li&gt;process data where it already exists&lt;/li&gt;
&lt;li&gt;optimize for responsiveness&lt;/li&gt;
&lt;li&gt;preserve ownership&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That philosophy now shapes almost everything I build.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Industry Isn’t Moving Backward — It’s Rebalancing
&lt;/h2&gt;

&lt;p&gt;I don’t think the future is less connected. I think the future is becoming more intentional about connectivity.&lt;/p&gt;

&lt;p&gt;We spent years pushing computation away from users.&lt;/p&gt;

&lt;p&gt;Now we’re starting to realize: modern devices are incredibly powerful, modern browsers are incredibly capable, and users increasingly want more control back.&lt;/p&gt;

&lt;p&gt;Local-first applications are not a step backward. They’re the next correction.&lt;/p&gt;

&lt;p&gt;And honestly, I think we’re only at the beginning of that shift.&lt;/p&gt;




&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;I’m &lt;a href="https://www.amrishkhan.dev" rel="noopener noreferrer"&gt;Amrish Khan&lt;/a&gt; — a full-stack engineer focused on building fast, privacy-conscious, developer-first applications.&lt;/p&gt;

&lt;p&gt;I’m currently exploring the future of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;local-first developer tooling&lt;/li&gt;
&lt;li&gt;browser-native processing&lt;/li&gt;
&lt;li&gt;AI-efficient workflows&lt;/li&gt;
&lt;li&gt;offline-capable applications&lt;/li&gt;
&lt;li&gt;privacy-focused architectures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m also building &lt;a href="https://www.aruvix.com" rel="noopener noreferrer"&gt;Aruvix&lt;/a&gt; — a growing ecosystem of local-first developer tools designed to process data directly in the browser without unnecessary uploads.&lt;/p&gt;

&lt;p&gt;Here's a detailed blog on Aruvix: &lt;a href="https://www.amrishkhan.dev/blog/aruvix-the-ultimate-offline-first-developer-toolkit-e0i" rel="noopener noreferrer"&gt;Read More&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can follow my work and thoughts here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Portfolio: &lt;a href="https://www.amrishkhan.dev" rel="noopener noreferrer"&gt;amrishkhan.dev&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/amrishkhan/" rel="noopener noreferrer"&gt;linkedin.com/in/amrishkhan&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;The future isn’t cloud-only. The future is intentional computing.&lt;/p&gt;

&lt;p&gt;Faster where possible. Local where meaningful. Cloud where necessary.&lt;/p&gt;

</description>
      <category>offline</category>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>The Most Underestimated Function in JavaScript: `reduce()`</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Fri, 08 May 2026 06:01:54 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/the-most-underestimated-function-in-javascript-reduce-2o8e</link>
      <guid>https://dev.to/amrishkhan05/the-most-underestimated-function-in-javascript-reduce-2o8e</guid>
      <description>&lt;h1&gt;
  
  
  Most Developers Meet &lt;code&gt;reduce()&lt;/code&gt; at the Wrong Time
&lt;/h1&gt;

&lt;p&gt;Usually, it happens through some terrifying one-liner like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&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;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the immediate reaction is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Why not just use a loop?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Fair question.&lt;/p&gt;

&lt;p&gt;Because honestly, most tutorials completely fail to explain what &lt;code&gt;reduce()&lt;/code&gt; actually is.&lt;/p&gt;

&lt;p&gt;They usually teach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;sum of array values&lt;/li&gt;
&lt;li&gt;average calculation&lt;/li&gt;
&lt;li&gt;maybe grouping&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But they never explain the real thing.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt; is not a math utility.&lt;/p&gt;

&lt;p&gt;It is one of the most powerful state transformation primitives in JavaScript.&lt;/p&gt;

&lt;p&gt;Once you truly understand it, you start seeing it everywhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Redux reducers&lt;/li&gt;
&lt;li&gt;React state management&lt;/li&gt;
&lt;li&gt;parsers&lt;/li&gt;
&lt;li&gt;compilers&lt;/li&gt;
&lt;li&gt;async pipelines&lt;/li&gt;
&lt;li&gt;aggregation systems&lt;/li&gt;
&lt;li&gt;permission engines&lt;/li&gt;
&lt;li&gt;data normalization&lt;/li&gt;
&lt;li&gt;event processing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article is not another "sum array values" tutorial.&lt;/p&gt;

&lt;p&gt;We are going deep into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how &lt;code&gt;reduce()&lt;/code&gt; actually works internally&lt;/li&gt;
&lt;li&gt;why developers struggle with it&lt;/li&gt;
&lt;li&gt;how it differs from &lt;code&gt;map()&lt;/code&gt;, &lt;code&gt;forEach()&lt;/code&gt;, and loops&lt;/li&gt;
&lt;li&gt;simple examples&lt;/li&gt;
&lt;li&gt;advanced real-world patterns&lt;/li&gt;
&lt;li&gt;performance considerations&lt;/li&gt;
&lt;li&gt;readability tradeoffs&lt;/li&gt;
&lt;li&gt;when not to use it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end, &lt;code&gt;reduce()&lt;/code&gt; will stop feeling magical and start feeling obvious.&lt;/p&gt;

&lt;h2&gt;
  
  
  What &lt;code&gt;reduce()&lt;/code&gt; Actually Means
&lt;/h2&gt;

&lt;p&gt;Forget syntax for a second.&lt;/p&gt;

&lt;p&gt;The real meaning is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Take many values and progressively transform them into one value.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That "one value" can be anything:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;object&lt;/li&gt;
&lt;li&gt;array&lt;/li&gt;
&lt;li&gt;tree&lt;/li&gt;
&lt;li&gt;promise chain&lt;/li&gt;
&lt;li&gt;lookup map&lt;/li&gt;
&lt;li&gt;grouped structure&lt;/li&gt;
&lt;li&gt;state machine&lt;/li&gt;
&lt;li&gt;cache&lt;/li&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;SQL query&lt;/li&gt;
&lt;li&gt;dependency graph&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The important part is this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt; evolves state step by step.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is the key mental model.&lt;/p&gt;

&lt;h2&gt;
  
  
  How &lt;code&gt;reduce()&lt;/code&gt; Actually Works
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;array&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;accumulator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;currentItem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;updatedAccumulator&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;initialValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s slow this down properly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Visualizing the Flow
&lt;/h3&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;numbers&lt;/span&gt; &lt;span class="o"&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbers&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;current&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;current&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Iteration flow:&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;// Initial state&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="c1"&gt;// Iteration 1&lt;/span&gt;
&lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;

&lt;span class="c1"&gt;// Iteration 2&lt;/span&gt;
&lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;

&lt;span class="c1"&gt;// Iteration 3&lt;/span&gt;
&lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="c1"&gt;// 6&lt;/span&gt;

&lt;span class="c1"&gt;// Iteration 4&lt;/span&gt;
&lt;span class="nx"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="c1"&gt;// 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Final result:&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="mi"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What Makes &lt;code&gt;reduce()&lt;/code&gt; Different?
&lt;/h2&gt;

&lt;p&gt;The accumulator survives between iterations.&lt;/p&gt;

&lt;p&gt;That is the entire magic.&lt;/p&gt;

&lt;p&gt;Unlike &lt;code&gt;map()&lt;/code&gt; or &lt;code&gt;forEach()&lt;/code&gt;, &lt;code&gt;reduce()&lt;/code&gt; carries evolving state forward.&lt;/p&gt;

&lt;p&gt;That makes it fundamentally more powerful.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;reduce()&lt;/code&gt; vs &lt;code&gt;map()&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;map()&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;map()&lt;/code&gt; transforms items independently.&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;doubled&lt;/span&gt; &lt;span class="o"&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;map&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;x&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="c1"&gt;// [2, 4, 6]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each item has no awareness of previous items.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;reduce()&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt; remembers previous iterations.&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;runningTotal&lt;/span&gt; &lt;span class="o"&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="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;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;x&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;// 6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result depends on previous state.&lt;/p&gt;

&lt;p&gt;That is a completely different concept.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;reduce()&lt;/code&gt; vs &lt;code&gt;forEach()&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;forEach()&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;forEach()&lt;/code&gt; is side-effect oriented.&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;result&lt;/span&gt; &lt;span class="o"&gt;=&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;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You mutate external state.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;reduce()&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt; keeps transformation self-contained.&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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&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;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;acc&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That becomes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;more composable&lt;/li&gt;
&lt;li&gt;more predictable&lt;/li&gt;
&lt;li&gt;easier to refactor&lt;/li&gt;
&lt;li&gt;easier to test&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Developers Fear &lt;code&gt;reduce()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Because most examples are terrible.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;arr&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;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;hard to read&lt;/li&gt;
&lt;li&gt;allocates objects repeatedly&lt;/li&gt;
&lt;li&gt;hides intent&lt;/li&gt;
&lt;li&gt;looks academic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So developers conclude:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"reduce is unreadable"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;No. Bad reducers are unreadable.&lt;/p&gt;

&lt;p&gt;Good reducers are incredibly expressive.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Golden Rule of &lt;code&gt;reduce()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The accumulator should represent evolving state clearly.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;usersById&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;Naming changes everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple Real-World Example: Grouping Data
&lt;/h2&gt;

&lt;p&gt;Suppose you have:&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="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;Sarah&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="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;Mike&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You want:&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="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;admin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="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;Mike&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="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;Sarah&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Traditional Loop
&lt;/h3&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;grouped&lt;/span&gt; &lt;span class="o"&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;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;users&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="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;grouped&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;grouped&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;grouped&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using &lt;code&gt;reduce()&lt;/code&gt;
&lt;/h3&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;grouped&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&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;groups&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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;groups&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The intent becomes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Transform users into a grouped structure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is much more declarative.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Scales Better Mentally
&lt;/h2&gt;

&lt;p&gt;In large applications, most code is not business logic.&lt;/p&gt;

&lt;p&gt;Most code is about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reshaping APIs&lt;/li&gt;
&lt;li&gt;transforming data&lt;/li&gt;
&lt;li&gt;aggregating state&lt;/li&gt;
&lt;li&gt;building structures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt; becomes extremely useful there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advanced Example: Permission Engine
&lt;/h2&gt;

&lt;p&gt;Imagine RBAC permissions.&lt;/p&gt;

&lt;p&gt;Input:&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;permissions&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;screen&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;view&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;screen&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;edit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;inventory&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;delete&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Desired output:&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="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;view&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;edit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nx"&gt;inventory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;reduce()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;permissionMap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;permissions&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;map&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;permission&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;permission&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;permission&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;permission&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;permission&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now permission checks become:&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;permissionMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;edit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;extremely fast&lt;/li&gt;
&lt;li&gt;scalable&lt;/li&gt;
&lt;li&gt;easy to cache&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where senior engineers start appreciating reducers deeply.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;reduce()&lt;/code&gt; Can Build Trees
&lt;/h2&gt;

&lt;p&gt;Example input:&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;categories&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;parent&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="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;Electronics&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Phones&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Laptops&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can reduce this into a hierarchical structure.&lt;/p&gt;

&lt;p&gt;This is how many CMS systems work internally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Async Power: Sequential Promise Execution
&lt;/h2&gt;

&lt;p&gt;One of the coolest &lt;code&gt;reduce()&lt;/code&gt; patterns:&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;tasks&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="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;previousTask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;currentTask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;previousTask&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;currentTask&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This forces tasks to execute sequentially.&lt;/p&gt;

&lt;p&gt;Useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rate-limited APIs&lt;/li&gt;
&lt;li&gt;database migrations&lt;/li&gt;
&lt;li&gt;ordered workflows&lt;/li&gt;
&lt;li&gt;queue systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most developers never realize &lt;code&gt;reduce()&lt;/code&gt; can do this.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Biggest Misconception
&lt;/h2&gt;

&lt;p&gt;People think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"reduce is just a shorter loop"&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;That is not the point.&lt;/p&gt;

&lt;p&gt;The point is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt; centralizes transformation logic into a predictable state evolution flow.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is a huge architectural difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance Discussion
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is &lt;code&gt;reduce()&lt;/code&gt; Faster?
&lt;/h3&gt;

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

&lt;p&gt;Sometimes a plain loop is faster.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// work&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can outperform:&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;arr&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in tight benchmarks.&lt;/p&gt;

&lt;p&gt;But real-world engineering is not usually microbenchmark-driven.&lt;/p&gt;

&lt;p&gt;The real advantages are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;composability&lt;/li&gt;
&lt;li&gt;maintainability&lt;/li&gt;
&lt;li&gt;predictability&lt;/li&gt;
&lt;li&gt;transformation clarity&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Where &lt;code&gt;reduce()&lt;/code&gt; Becomes Extremely Useful
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Single-pass transformations
&lt;/h4&gt;

&lt;p&gt;Instead of:&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;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(...).&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(...).&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can sometimes do:&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;arr&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in one pass.&lt;/p&gt;

&lt;p&gt;Less iteration. Less memory allocation.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Avoiding temporary arrays
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;map()&lt;/code&gt; creates arrays.&lt;br&gt;&lt;br&gt;
&lt;code&gt;filter()&lt;/code&gt; creates arrays.  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt; can avoid that.&lt;/p&gt;
&lt;h4&gt;
  
  
  3. Data normalization
&lt;/h4&gt;

&lt;p&gt;Huge backend and frontend systems constantly normalize data.&lt;/p&gt;

&lt;p&gt;Reducers are excellent for this.&lt;/p&gt;
&lt;h2&gt;
  
  
  But Don’t Abuse It
&lt;/h2&gt;

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

&lt;p&gt;Not everything should become a reducer.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&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;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;acc&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cleaner:&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;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the simplest tool possible.&lt;/p&gt;

&lt;p&gt;Senior developers do not worship &lt;code&gt;reduce()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;They respect where it fits.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Good Rule of Thumb
&lt;/h2&gt;

&lt;p&gt;Use &lt;code&gt;reduce()&lt;/code&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the output shape differs from the input&lt;/li&gt;
&lt;li&gt;the transformation depends on previous state&lt;/li&gt;
&lt;li&gt;you are building lookup structures&lt;/li&gt;
&lt;li&gt;you are aggregating data&lt;/li&gt;
&lt;li&gt;you are composing workflows&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;map()&lt;/code&gt; is clearer&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;filter()&lt;/code&gt; is clearer&lt;/li&gt;
&lt;li&gt;a loop is simpler&lt;/li&gt;
&lt;li&gt;readability suffers&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Senior Engineers Love It
&lt;/h2&gt;

&lt;p&gt;Because eventually you realize:&lt;/p&gt;

&lt;p&gt;Most software engineering is state transformation.&lt;/p&gt;

&lt;p&gt;And &lt;code&gt;reduce()&lt;/code&gt; is one of the cleanest abstractions for expressing state evolution.&lt;/p&gt;

&lt;p&gt;That is why reducers appear everywhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React reducers&lt;/li&gt;
&lt;li&gt;Redux&lt;/li&gt;
&lt;li&gt;compiler passes&lt;/li&gt;
&lt;li&gt;parsers&lt;/li&gt;
&lt;li&gt;stream processing&lt;/li&gt;
&lt;li&gt;aggregation engines&lt;/li&gt;
&lt;li&gt;event sourcing&lt;/li&gt;
&lt;li&gt;CQRS systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even databases conceptually perform reduction-like operations internally.&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt; is underestimated because developers are introduced to it too early and explained too poorly.&lt;/p&gt;

&lt;p&gt;People memorize syntax before understanding the idea.&lt;/p&gt;

&lt;p&gt;Once you understand this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt; evolves state across a sequence&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;You stop seeing it as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;confusing syntax&lt;/li&gt;
&lt;li&gt;functional programming gimmick&lt;/li&gt;
&lt;li&gt;"smart developer code"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and start seeing it for what it really is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A foundational data transformation primitive.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And honestly? Once it clicks, you begin noticing reducers everywhere in software architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;I’m &lt;a href="https://www.amrishkhan.dev?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Amrish Khan&lt;/a&gt; — a full-stack engineer focused on building fast, privacy-conscious, developer-first applications.&lt;/p&gt;

&lt;p&gt;I’m currently exploring the future of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;local-first developer tooling&lt;/li&gt;
&lt;li&gt;browser-native processing&lt;/li&gt;
&lt;li&gt;AI-efficient workflows&lt;/li&gt;
&lt;li&gt;offline-capable applications&lt;/li&gt;
&lt;li&gt;privacy-focused architectures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m also building &lt;a href="https://www.aruvix.com?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Aruvix&lt;/a&gt; — a growing ecosystem of local-first developer tools designed to process data directly in the browser without unnecessary uploads.&lt;/p&gt;

&lt;p&gt;Here's a detailed blog on Aruvix: &lt;a href="https://www.amrishkhan.dev/blog/aruvix-the-ultimate-offline-first-developer-toolkit-e0i" rel="noopener noreferrer"&gt;Read More&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can follow my work and thoughts here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Portfolio: &lt;a href="https://www.amrishkhan.dev" rel="noopener noreferrer"&gt;amrishkhan.dev&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/amrishkhan/" rel="noopener noreferrer"&gt;linkedin.com/in/amrishkhan&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Why I Built Aruvix — One Local-First Toolkit for Every Developer Workflow</title>
      <dc:creator>Amrishkhan Sheik Abdullah</dc:creator>
      <pubDate>Thu, 07 May 2026 07:08:08 +0000</pubDate>
      <link>https://dev.to/amrishkhan05/aruvix-the-ultimate-offline-first-developer-toolkit-e0i</link>
      <guid>https://dev.to/amrishkhan05/aruvix-the-ultimate-offline-first-developer-toolkit-e0i</guid>
      <description>&lt;p&gt;&lt;em&gt;A privacy-first, offline-first toolkit for JSON formatting, API testing, schema generation, frontend workflows, QA tooling, and developer productivity.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Official Website: &lt;a href="https://www.aruvix.com" rel="noopener noreferrer"&gt;https://www.aruvix.com&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://www.aruvix.com" rel="noopener noreferrer"&gt;Aruvix&lt;/a&gt; is a powerful, privacy-first, browser-based suite of developer tools designed to keep your workflows fast, secure, and entirely local. Built for developers who are tired of juggling dozens of disconnected online utilities, Aruvix brings everything into one unified workspace.&lt;/p&gt;

&lt;p&gt;Whether you are formatting complex JSON, testing APIs, comparing payloads, generating schemas, converting formats, or debugging responses, Aruvix helps you do it faster without sacrificing privacy or performance.&lt;/p&gt;

&lt;p&gt;And most importantly: &lt;strong&gt;don't waste your AI tokens for simple deterministic tasks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Formatting JSON, decoding JWTs, converting XML, testing regex, or generating schemas should not require sending payloads to expensive LLMs. Aruvix handles these operations instantly inside your browser with zero uploads and zero token consumption.&lt;/p&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why Aruvix? Better than the Alternatives&lt;/li&gt;
&lt;li&gt;JSON Formatter&lt;/li&gt;
&lt;li&gt;JSON Compare&lt;/li&gt;
&lt;li&gt;API Client&lt;/li&gt;
&lt;li&gt;Visualize&lt;/li&gt;
&lt;li&gt;Schema Generator&lt;/li&gt;
&lt;li&gt;Query (JSONPath)&lt;/li&gt;
&lt;li&gt;Code Translator&lt;/li&gt;
&lt;li&gt;Converter Tools&lt;/li&gt;
&lt;li&gt;Dev Tools&lt;/li&gt;
&lt;li&gt;Frontend &amp;amp; CSS Tools&lt;/li&gt;
&lt;li&gt;QA Tools&lt;/li&gt;
&lt;li&gt;Who Is Aruvix For?&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Aruvix? Better than the Alternatives
&lt;/h2&gt;

&lt;p&gt;Unlike many existing online tools — which often upload sensitive payloads to remote servers — or heavyweight desktop applications that consume massive resources for simple workflows, &lt;a href="https://www.aruvix.com" rel="noopener noreferrer"&gt;Aruvix&lt;/a&gt; follows an &lt;strong&gt;offline-first, browser-local architecture&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Modern developer workflows are fragmented.&lt;/p&gt;

&lt;p&gt;One tab for JSON formatting.&lt;br&gt;&lt;br&gt;
Another for API testing.&lt;br&gt;&lt;br&gt;
Another for JWT decoding.&lt;br&gt;&lt;br&gt;
Another for Base64.&lt;br&gt;&lt;br&gt;
Another for YAML conversion.&lt;br&gt;&lt;br&gt;
Another for regex testing.&lt;/p&gt;

&lt;p&gt;Eventually your browser becomes a collection of disconnected utilities with inconsistent UX, privacy concerns, ads, rate limits, and slow processing.&lt;/p&gt;

&lt;p&gt;Aruvix was built to solve exactly that problem:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One unified toolkit. One consistent workflow. Everything local-first.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What makes it better
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Absolute Privacy:&lt;/strong&gt; Your JSON, API responses, tokens, configs, schemas, and debugging payloads never leave your browser. No hidden uploads. No unnecessary backend processing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Speed &amp;amp; Efficiency:&lt;/strong&gt; Most tools execute instantly with zero server round trips. Large payloads are processed locally using optimized browser-native techniques for maximum responsiveness.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Unified Workspace:&lt;/strong&gt; No need to juggle 15 different websites for formatting, JWT decoding, Base64 encoding, API testing, schema generation, and conversions. Everything exists inside one cohesive environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost-Effective:&lt;/strong&gt; Save your AI tokens for actual problem solving instead of wasting them on deterministic formatting and conversion tasks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use AI where intelligence is actually needed.&lt;br&gt;&lt;br&gt;
Let tooling handle tooling.&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%2F1ies2acjn7wots2ktez0.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%2F1ies2acjn7wots2ktez0.png" alt=" " width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  JSON Formatter
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/json-formatter" rel="noopener noreferrer"&gt;https://www.aruvix.com/json-formatter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The JSON Formatter is the heart of Aruvix, designed to help developers clean, validate, repair, inspect, and minify JSON effortlessly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Beautify and format JSON&lt;/li&gt;
&lt;li&gt;Minify payloads&lt;/li&gt;
&lt;li&gt;Validate JSON syntax&lt;/li&gt;
&lt;li&gt;Repair malformed structures&lt;/li&gt;
&lt;li&gt;Syntax-highlighted editing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Options Available
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Tree View for nested exploration&lt;/li&gt;
&lt;li&gt;Table View for arrays&lt;/li&gt;
&lt;li&gt;Type View for inferred structures&lt;/li&gt;
&lt;li&gt;Raw text editing mode&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;Most online JSON formatters struggle with large payloads, freeze on malformed structures, or require uploading sensitive data to external servers.&lt;/p&gt;

&lt;p&gt;Aruvix focuses heavily on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Large payload usability&lt;/li&gt;
&lt;li&gt;Responsiveness&lt;/li&gt;
&lt;li&gt;Local execution&lt;/li&gt;
&lt;li&gt;Repair capabilities&lt;/li&gt;
&lt;li&gt;Smooth editing workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything happens directly inside your browser.&lt;/p&gt;

&lt;p&gt;Whether you are debugging API responses, inspecting production logs, validating webhook payloads, or cleaning third-party integrations, the formatter is designed to keep large JSON payloads readable and manageable without slowing down your browser.&lt;/p&gt;

&lt;p&gt;Malformed payloads are common when dealing with legacy systems or manually edited responses. Instead of failing immediately, Aruvix attempts to help developers recover and repair invalid structures quickly.&lt;/p&gt;

&lt;p&gt;Try the JSON Formatter here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/json-formatter" rel="noopener noreferrer"&gt;https://www.aruvix.com/json-formatter&lt;/a&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%2F7ns8t4vh5u8c5j3ly7y5.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%2F7ns8t4vh5u8c5j3ly7y5.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  JSON Compare
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/json-diff" rel="noopener noreferrer"&gt;https://www.aruvix.com/json-diff&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A side-by-side comparison workspace to quickly identify changed values, missing keys, nested differences, and structural mismatches between JSON objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Side-by-side editors&lt;/li&gt;
&lt;li&gt;Automatic structural comparison&lt;/li&gt;
&lt;li&gt;Path-level difference inspection&lt;/li&gt;
&lt;li&gt;Difference summaries&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Options Available
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Added/removed/changed node summaries&lt;/li&gt;
&lt;li&gt;Minified vs formatted comparison support&lt;/li&gt;
&lt;li&gt;Deep nested object comparison&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;Traditional text diff tools often highlight formatting changes instead of actual data changes.&lt;/p&gt;

&lt;p&gt;Aruvix parses JSON structurally and highlights semantic differences only, helping developers identify meaningful changes faster.&lt;/p&gt;

&lt;p&gt;This becomes especially useful when comparing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API responses across environments&lt;/li&gt;
&lt;li&gt;Before/after transformation outputs&lt;/li&gt;
&lt;li&gt;Webhook payload changes&lt;/li&gt;
&lt;li&gt;Configuration differences&lt;/li&gt;
&lt;li&gt;Regression testing snapshots&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of manually scanning thousands of lines, developers can focus directly on meaningful structural changes.&lt;/p&gt;

&lt;p&gt;Try the JSON Compare tool here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/json-diff" rel="noopener noreferrer"&gt;https://www.aruvix.com/json-diff&lt;/a&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%2Fznp7y4wc35zkv5sysuhw.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%2Fznp7y4wc35zkv5sysuhw.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyq79adf6ze1j4qx93w6k.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%2Fyq79adf6ze1j4qx93w6k.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  API Client
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/api-tester" rel="noopener noreferrer"&gt;https://www.aruvix.com/api-tester&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A lightweight yet powerful REST API client running entirely inside your browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Send HTTP requests&lt;/li&gt;
&lt;li&gt;Inspect headers, status, and responses&lt;/li&gt;
&lt;li&gt;Import cURL commands&lt;/li&gt;
&lt;li&gt;Generate OpenAPI documentation&lt;/li&gt;
&lt;li&gt;Pre-request and post-request scripting&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Options Available
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Environment variables&lt;/li&gt;
&lt;li&gt;Request collections&lt;/li&gt;
&lt;li&gt;Reusable variables&lt;/li&gt;
&lt;li&gt;Proxy support for local testing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;For quick API testing, developers often do not need a massive Electron-based application consuming huge amounts of memory.&lt;/p&gt;

&lt;p&gt;Aruvix provides a lightweight alternative focused on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Speed&lt;/li&gt;
&lt;li&gt;Simplicity&lt;/li&gt;
&lt;li&gt;Local workflows&lt;/li&gt;
&lt;li&gt;Minimal resource usage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Perfect for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Quick endpoint testing&lt;/li&gt;
&lt;li&gt;Internal API debugging&lt;/li&gt;
&lt;li&gt;Webhook validation&lt;/li&gt;
&lt;li&gt;Authentication testing&lt;/li&gt;
&lt;li&gt;Local development workflows&lt;/li&gt;
&lt;li&gt;Lightweight request inspection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is not to replace enterprise collaboration platforms, but to provide an extremely fast and focused API workflow for day-to-day engineering tasks.&lt;/p&gt;

&lt;p&gt;Aruvix also works great as a lightweight Postman alternative for developers who prefer fast local-first tooling over heavyweight desktop applications.&lt;/p&gt;

&lt;p&gt;Try the API Client here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/api-tester" rel="noopener noreferrer"&gt;https://www.aruvix.com/api-tester&lt;/a&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%2Fajm0h1o65ad5kytjexvd.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%2Fajm0h1o65ad5kytjexvd.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Visualize
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/visualize" rel="noopener noreferrer"&gt;https://www.aruvix.com/visualize&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Explore deeply nested JSON objects visually through interactive structures and graph-based inspection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Interactive node graph views&lt;/li&gt;
&lt;li&gt;Search across keys and values&lt;/li&gt;
&lt;li&gt;JSONPath inspection&lt;/li&gt;
&lt;li&gt;Zoom and pan navigation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Options Available
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Export/share visual views&lt;/li&gt;
&lt;li&gt;Path tracing&lt;/li&gt;
&lt;li&gt;Collapsible nested structures&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;Large nested payloads become difficult to understand in raw text form.&lt;/p&gt;

&lt;p&gt;The Visualizer transforms deeply nested hierarchies into intuitive visual structures that are significantly easier to inspect and debug.&lt;/p&gt;

&lt;p&gt;When payloads become deeply nested, traditional text editors force developers into endless collapsing, scrolling, and searching.&lt;/p&gt;

&lt;p&gt;Visualization makes relationships between nodes, arrays, and structures immediately understandable.&lt;/p&gt;

&lt;p&gt;Try the Visualizer here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/visualize" rel="noopener noreferrer"&gt;https://www.aruvix.com/visualize&lt;/a&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%2Fqeotr3slch1l9iekat5r.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%2Fqeotr3slch1l9iekat5r.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Schema Generator
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/schema" rel="noopener noreferrer"&gt;https://www.aruvix.com/schema&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Generate JSON Schema definitions directly from sample payloads.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Generate starter schemas&lt;/li&gt;
&lt;li&gt;Validate JSON against schemas&lt;/li&gt;
&lt;li&gt;Inspect validation failures&lt;/li&gt;
&lt;li&gt;Edit generated schemas&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Options Available
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Copy/download schemas&lt;/li&gt;
&lt;li&gt;Validation reports&lt;/li&gt;
&lt;li&gt;Rule customization&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;Instead of manually writing large schema definitions, developers can instantly generate standardized contracts from real payload data.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;API documentation&lt;/li&gt;
&lt;li&gt;Validation workflows&lt;/li&gt;
&lt;li&gt;Contract-first development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is especially useful when working with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frontend/backend contracts&lt;/li&gt;
&lt;li&gt;Validation middleware&lt;/li&gt;
&lt;li&gt;API documentation&lt;/li&gt;
&lt;li&gt;Mock servers&lt;/li&gt;
&lt;li&gt;Automated testing pipelines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developers can bootstrap schema definitions within seconds instead of manually building large validation structures from scratch.&lt;/p&gt;

&lt;p&gt;Try the Schema Generator here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/schema" rel="noopener noreferrer"&gt;https://www.aruvix.com/schema&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Query (JSONPath)
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/query" rel="noopener noreferrer"&gt;https://www.aruvix.com/query&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Search, filter, and extract values from deeply nested JSON structures using JSONPath expressions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Run JSONPath queries&lt;/li&gt;
&lt;li&gt;Filter arrays&lt;/li&gt;
&lt;li&gt;Extract nested values&lt;/li&gt;
&lt;li&gt;Inspect matched paths&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Options Available
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Live query testing&lt;/li&gt;
&lt;li&gt;Match highlighting&lt;/li&gt;
&lt;li&gt;Result previews&lt;/li&gt;
&lt;li&gt;One-click copy support&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;Developers can visually test JSONPath queries against real payloads before integrating them into production systems.&lt;/p&gt;

&lt;p&gt;This significantly reduces debugging time and query trial/error cycles.&lt;/p&gt;

&lt;p&gt;Useful for extracting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nested IDs&lt;/li&gt;
&lt;li&gt;Filtered arrays&lt;/li&gt;
&lt;li&gt;Deeply buried attributes&lt;/li&gt;
&lt;li&gt;Analytics fields&lt;/li&gt;
&lt;li&gt;Transformed API responses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Live query testing dramatically reduces iteration time when building backend transformations or frontend selectors.&lt;/p&gt;

&lt;p&gt;Try JSONPath Query here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/query" rel="noopener noreferrer"&gt;https://www.aruvix.com/query&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Translator
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/code-translator" rel="noopener noreferrer"&gt;https://www.aruvix.com/code-translator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Convert JavaScript into TypeScript starter code directly inside the browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JS → TS conversion&lt;/li&gt;
&lt;li&gt;Type inference&lt;/li&gt;
&lt;li&gt;Warning generation&lt;/li&gt;
&lt;li&gt;Starter migration assistance&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Options Available
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Auto-run translation&lt;/li&gt;
&lt;li&gt;Editable output&lt;/li&gt;
&lt;li&gt;Copy/download support&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;The entire conversion process happens locally, ensuring proprietary code never leaves your machine while still accelerating TypeScript migrations.&lt;/p&gt;

&lt;p&gt;The translator is designed as a migration accelerator rather than a perfect one-click replacement.&lt;/p&gt;

&lt;p&gt;It helps developers move faster during large JavaScript → TypeScript transitions by generating a reliable starting point for refinement.&lt;/p&gt;

&lt;p&gt;Try the Code Translator here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/code-translator" rel="noopener noreferrer"&gt;https://www.aruvix.com/code-translator&lt;/a&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%2Fcgzshx0vrxdgq2hg6yu5.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%2Fcgzshx0vrxdgq2hg6yu5.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Converter Tools
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/json-to-csv" rel="noopener noreferrer"&gt;https://www.aruvix.com/json-to-csv&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A comprehensive suite for converting between multiple developer-friendly data formats.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JSON ↔ XML&lt;/li&gt;
&lt;li&gt;JSON ↔ YAML&lt;/li&gt;
&lt;li&gt;CSV conversion&lt;/li&gt;
&lt;li&gt;JSONL conversion&lt;/li&gt;
&lt;li&gt;Dart conversion&lt;/li&gt;
&lt;li&gt;TOON conversion&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Options Available
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Auto-convert on paste&lt;/li&gt;
&lt;li&gt;Source validation&lt;/li&gt;
&lt;li&gt;Download output&lt;/li&gt;
&lt;li&gt;Copy to clipboard&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;Instead of opening multiple ad-heavy converter websites, developers can handle all transformations locally inside a single workflow.&lt;/p&gt;

&lt;p&gt;Fast. Consistent. Private.&lt;/p&gt;

&lt;p&gt;Developers frequently work with multiple formats across APIs, databases, integrations, logs, and export systems.&lt;/p&gt;

&lt;p&gt;Aruvix simplifies these transitions without requiring separate conversion platforms for every format.&lt;/p&gt;

&lt;p&gt;Explore Converter Tools here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/json-to-csv" rel="noopener noreferrer"&gt;https://www.aruvix.com/json-to-csv&lt;/a&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%2Fn6evrmy7pykwxwupnbk7.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%2Fn6evrmy7pykwxwupnbk7.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dev Tools
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/dev-tools" rel="noopener noreferrer"&gt;https://www.aruvix.com/dev-tools&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A dedicated collection of utilities for debugging, inspection, and payload analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  Included Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JWT Decoder&lt;/li&gt;
&lt;li&gt;Base64 Encoder/Decoder&lt;/li&gt;
&lt;li&gt;URL Encoder/Decoder&lt;/li&gt;
&lt;li&gt;Regex Tester&lt;/li&gt;
&lt;li&gt;Duplicate Key Finder&lt;/li&gt;
&lt;li&gt;Timestamp Scanner&lt;/li&gt;
&lt;li&gt;JSON Merge&lt;/li&gt;
&lt;li&gt;JSON Patch&lt;/li&gt;
&lt;li&gt;Structure Analyzer&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;Instead of opening random utilities across the web, Aruvix centralizes the entire debugging workflow into a single consistent interface.&lt;/p&gt;

&lt;p&gt;Decode tokens, test regex patterns, inspect payload structures, and analyze responses without leaving the ecosystem.&lt;/p&gt;

&lt;p&gt;Small debugging operations consume surprising amounts of developer time throughout the day.&lt;/p&gt;

&lt;p&gt;Aruvix centralizes these repetitive micro-workflows into a single environment so engineers can stay focused instead of context switching across tabs.&lt;/p&gt;

&lt;p&gt;Explore Developer Utilities here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/dev-tools" rel="noopener noreferrer"&gt;https://www.aruvix.com/dev-tools&lt;/a&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%2Fezc6d8wiqc0faj0r15js.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%2Fezc6d8wiqc0faj0r15js.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Frontend &amp;amp; CSS Tools
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/color-picker" rel="noopener noreferrer"&gt;https://www.aruvix.com/color-picker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything frontend developers need to accelerate UI workflows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Included Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Color Picker&lt;/li&gt;
&lt;li&gt;CSS to Tailwind Converter&lt;/li&gt;
&lt;li&gt;Design Token Generator&lt;/li&gt;
&lt;li&gt;HTML/SVG to JSX Converter&lt;/li&gt;
&lt;li&gt;CSS Formatter&lt;/li&gt;
&lt;li&gt;CSS Specificity Calculator&lt;/li&gt;
&lt;li&gt;Box Shadow Generator&lt;/li&gt;
&lt;li&gt;Gradient Generator&lt;/li&gt;
&lt;li&gt;Flexbox/Grid Generators&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;Frontend developers constantly rely on fragmented generators and conversion websites during daily workflows.&lt;/p&gt;

&lt;p&gt;Aruvix consolidates those repetitive utilities into a single streamlined experience with consistent UX and local execution.&lt;/p&gt;

&lt;p&gt;Frontend development often involves repetitive experimentation with layouts, spacing, gradients, color systems, and utility conversions.&lt;/p&gt;

&lt;p&gt;Aruvix helps speed up these workflows while keeping everything accessible from one consistent workspace.&lt;/p&gt;

&lt;p&gt;Instead of searching for isolated CSS generators, frontend engineers can iterate directly within the same ecosystem used for APIs, payloads, and debugging.&lt;/p&gt;

&lt;p&gt;Explore Frontend &amp;amp; CSS Tools here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/color-picker" rel="noopener noreferrer"&gt;https://www.aruvix.com/color-picker&lt;/a&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%2F0sraluxjdhqayptlj7vh.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%2F0sraluxjdhqayptlj7vh.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  QA Tools
&lt;/h2&gt;

&lt;p&gt;🔗 Tool Link: &lt;a href="https://www.aruvix.com/test-data-generator" rel="noopener noreferrer"&gt;https://www.aruvix.com/test-data-generator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A dedicated toolkit for QA engineers and testers to validate faster and generate better reports.&lt;/p&gt;

&lt;h3&gt;
  
  
  Included Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Test Data Generator&lt;/li&gt;
&lt;li&gt;Bug Report Generator&lt;/li&gt;
&lt;li&gt;API Assertion Generator&lt;/li&gt;
&lt;li&gt;HAR Viewer&lt;/li&gt;
&lt;li&gt;UUID Generator&lt;/li&gt;
&lt;li&gt;Fake User/Data Generator&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Options Available
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;CSV/SQL/JSON export&lt;/li&gt;
&lt;li&gt;Configurable row counts&lt;/li&gt;
&lt;li&gt;Jira/GitHub markdown formatting&lt;/li&gt;
&lt;li&gt;Structured regression reporting&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Aruvix Advantage
&lt;/h3&gt;

&lt;p&gt;QA teams should not need separate utilities for generating test data, formatting reports, validating APIs, and inspecting payloads.&lt;/p&gt;

&lt;p&gt;Aruvix centralizes these workflows while keeping all generated data local and private.&lt;/p&gt;

&lt;p&gt;QA engineers frequently need to generate large amounts of realistic test data while maintaining privacy and consistency across environments.&lt;/p&gt;

&lt;p&gt;Aruvix enables rapid dataset generation directly inside the browser without external dependencies.&lt;/p&gt;

&lt;p&gt;This becomes particularly useful during regression testing, staging validation, and automated test preparation.&lt;/p&gt;

&lt;p&gt;Explore QA Tools here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://www.aruvix.com/test-data-generator" rel="noopener noreferrer"&gt;https://www.aruvix.com/test-data-generator&lt;/a&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%2Fqegmirnph25gging8qvg.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%2Fqegmirnph25gging8qvg.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Who Is Aruvix For?
&lt;/h2&gt;

&lt;p&gt;Aruvix is designed for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backend developers&lt;/li&gt;
&lt;li&gt;Frontend engineers&lt;/li&gt;
&lt;li&gt;QA teams&lt;/li&gt;
&lt;li&gt;API developers&lt;/li&gt;
&lt;li&gt;DevOps engineers&lt;/li&gt;
&lt;li&gt;Full-stack developers&lt;/li&gt;
&lt;li&gt;Developers working with large JSON payloads&lt;/li&gt;
&lt;li&gt;Teams looking for privacy-first workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whether you are debugging APIs, formatting JSON, generating schemas, testing regex, converting formats, or building frontend workflows — Aruvix keeps everything fast, local-first, and privacy-focused.&lt;/p&gt;




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

&lt;p&gt;&lt;a href="https://www.aruvix.com" rel="noopener noreferrer"&gt;Aruvix&lt;/a&gt; is built around a simple philosophy:&lt;/p&gt;

&lt;p&gt;Developer tools should feel fast.&lt;br&gt;
Your data should remain yours.&lt;br&gt;
Simple tasks should not consume AI tokens.&lt;br&gt;
And workflows should stay unified instead of fragmented across dozens of disconnected tools.&lt;/p&gt;

&lt;p&gt;One toolkit.&lt;br&gt;
One workflow.&lt;br&gt;
Everything local-first.&lt;/p&gt;

&lt;p&gt;Build faster.&lt;br&gt;
Debug smarter.&lt;br&gt;
Waste fewer tokens.&lt;/p&gt;




&lt;h2&gt;
  
  
  Explore Aruvix
&lt;/h2&gt;

&lt;p&gt;🌐 Official Website: &lt;a href="https://www.aruvix.com" rel="noopener noreferrer"&gt;https://www.aruvix.com&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON Formatter → &lt;a href="https://www.aruvix.com/json-formatter" rel="noopener noreferrer"&gt;https://www.aruvix.com/json-formatter&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;JSON Compare → &lt;a href="https://www.aruvix.com/json-diff" rel="noopener noreferrer"&gt;https://www.aruvix.com/json-diff&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;API Client → &lt;a href="https://www.aruvix.com/api-tester" rel="noopener noreferrer"&gt;https://www.aruvix.com/api-tester&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Schema Generator → &lt;a href="https://www.aruvix.com/schema" rel="noopener noreferrer"&gt;https://www.aruvix.com/schema&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Visualizer → &lt;a href="https://www.aruvix.com/visualize" rel="noopener noreferrer"&gt;https://www.aruvix.com/visualize&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Build faster.&lt;br&gt;
Debug smarter.&lt;br&gt;
Waste fewer tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;I’m &lt;a href="https://www.amrishkhan.dev?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Amrish Khan&lt;/a&gt; — a full-stack engineer focused on building fast, privacy-conscious, developer-first applications.&lt;/p&gt;

&lt;p&gt;I’m currently exploring the future of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;local-first developer tooling&lt;/li&gt;
&lt;li&gt;browser-native processing&lt;/li&gt;
&lt;li&gt;AI-efficient workflows&lt;/li&gt;
&lt;li&gt;offline-capable applications&lt;/li&gt;
&lt;li&gt;privacy-focused architectures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can follow my work and thoughts here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Portfolio: &lt;a href="https://www.amrishkhan.dev" rel="noopener noreferrer"&gt;amrishkhan.dev&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/amrishkhan/" rel="noopener noreferrer"&gt;linkedin.com/in/amrishkhan&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>privacy</category>
      <category>productivity</category>
      <category>showdev</category>
      <category>tooling</category>
    </item>
    <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="592"&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="690"&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="685"&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="557"&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="576"&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="480"&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>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>
