<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Untitled Publication]]></title><description><![CDATA[Untitled Publication]]></description><link>https://blog.naveenaditya.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 20:40:54 GMT</lastBuildDate><atom:link href="https://blog.naveenaditya.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Unraveling the Mystery: Understanding Function Argument Evaluation Order in C++]]></title><description><![CDATA[Let's explore "Don’t depend on the order of evaluation of function arguments". You might be wondering what I'm talking about because many developers assume that function arguments are evaluated from left to right. That's incorrect! There are no guara...]]></description><link>https://blog.naveenaditya.dev/function-argument-evaluation-order-in-cpp</link><guid isPermaLink="true">https://blog.naveenaditya.dev/function-argument-evaluation-order-in-cpp</guid><category><![CDATA[Argument Evaluation]]></category><category><![CDATA[C++]]></category><dc:creator><![CDATA[Aditya Agarwal]]></dc:creator><pubDate>Sun, 15 Dec 2024 19:06:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1734289343830/fa52cb58-b3ca-4d26-ab57-80c3206ed7a7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let's explore <strong>"Don’t depend on the order of evaluation of function arguments"</strong>. You might be wondering what I'm talking about because many developers assume that function arguments are evaluated from left to right. That's incorrect! There are no guarantees!</p>
<p><strong>Reason:</strong> The order is unspecified.</p>
<p><strong>Note:</strong> C++17 has stricter rules for the order of evaluation, but the order of function argument evaluation is still unspecified.</p>
<p>Let's look at a simple example:</p>
<pre><code class="lang-c++"><span class="hljs-comment">//test.cpp</span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;iostream&gt;</span></span>

<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">foo</span><span class="hljs-params">(<span class="hljs-keyword">int</span> a, <span class="hljs-keyword">int</span> b)</span> </span>{
    <span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"a: "</span> &lt;&lt; a &lt;&lt; <span class="hljs-string">" "</span> &lt;&lt; <span class="hljs-string">"b: "</span> &lt;&lt; b &lt;&lt; <span class="hljs-built_in">std</span>::<span class="hljs-built_in">endl</span>;
}

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
    <span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>;
    foo(i++, i++); <span class="hljs-comment">// (1, 0) | (0, 1) | (0, 0)</span>

    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<p>If you understand what I'm saying, then you're on the right track. If not, let's move on to the explanation.</p>
<p>Here's my proof. The output from gcc and clang is different:</p>
<ul>
<li>gcc</li>
</ul>
<p><code>g++ -std=c++2a -O3 -Wall test.cpp -o test &amp;&amp; ./test</code></p>
<pre><code class="lang-bash">test.cpp: In <span class="hljs-keyword">function</span> ‘int main()’:
test.cpp:9:15: warning: operation on ‘i’ may be undefined [-Wsequence-point]
    9 |     foo(i++, i++); // (1, 0) | (0, 1) | (0, 0)
      |              ~^~
test.cpp:9:15: warning: operation on ‘i’ may be undefined [-Wsequence-point]
a: 1 b: 0
</code></pre>
<ul>
<li>clang</li>
</ul>
<p><code>clang++ -std=c++2a -O3 -Wall test.cpp -o test &amp;&amp; ./test</code></p>
<pre><code class="lang-bash">test.cpp:9:10: warning: multiple unsequenced modifications to <span class="hljs-string">'i'</span> [-Wunsequenced]
    foo(i++, i++); // (1, 0) | (0, 1) | (0, 0)
         ^    ~~
1 warning generated.
a: 0 b: 1
</code></pre>
<p>The function call could be evaluated as <code>foo(0, 1)</code> or <code>foo(1, 0)</code>, but the order is not guaranteed. Technically, the behavior is undefined. In C++17, this code doesn't have undefined behavior, but it still doesn't specify which argument is evaluated first.</p>
<p>I compile in C++20 or use the best error detection during compilation with optimization by using a compiler flag.</p>
<p>If you want to learn more about this, check out these links:</p>
<ul>
<li><p><a target="_blank" href="https://isocpp.org/blog/2016/08/quick-q-why-doesnt-cpp-have-a-specified-order-for-evaluating-function-argum">Why doesn't C++ have a specified order for evaluating function arguments?</a></p>
</li>
<li><p><a target="_blank" href="https://en.cppreference.com/w/cpp/language/eval_order">Evaluation order in C++</a></p>
</li>
<li><p><a target="_blank" href="https://stackoverflow.com/questions/621542/compilers-and-argument-order-of-evaluation-in-c">Compilers and argument order of evaluation in C++</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Flutter Version individual for every project - Flutter Version Manager]]></title><description><![CDATA[In this article, we will learn about Version Management In Flutter. In this, we will see how to set up and work on version management in a flutter. So let’s get started. 
Before, we understood what is Flutter Version Manager (FVM) and how to be used....]]></description><link>https://blog.naveenaditya.dev/flutter-version-individual-for-every-project-flutter-version-manager</link><guid isPermaLink="true">https://blog.naveenaditya.dev/flutter-version-individual-for-every-project-flutter-version-manager</guid><category><![CDATA[Flutter]]></category><category><![CDATA[version control]]></category><dc:creator><![CDATA[Aditya Agarwal]]></dc:creator><pubDate>Sat, 28 Aug 2021 18:23:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1629563898441/oDB-jrNMF.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this article, we will learn about Version Management In Flutter. In this, we will see how to set up and work on version management in a flutter. So let’s get started. </p>
<p>Before, we understood what is Flutter Version Manager (FVM) and how to be used. First, we need to understand, you really need this or not version management?</p>
<h2 id="why-do-we-need-version-management-in-flutter">Why do we need Version Management in Flutter?</h2>
<p>When working on Flutter projects, you may need to switch between different SDK versions to validate and test upcoming Flutter releases with your apps, which is very tedious and time-consuming. This is where Version Management comes to the rescue.</p>
<p>Which provides us with different types of Flutter versions for our machines. So that each time, Flutter can test the app against the updated Flutter release without waiting for installation and will be able to switch to the Flutter version accordingly.</p>
<h2 id="how-we-performed-version-management">How we performed version management</h2>
<p>Actually, there are two ways to do this,</p>
<ul>
<li>Naive Approach (via aliases)</li>
<li>Tool base (via FVM)</li>
</ul>
<h2 id="naive-approach">Naive Approach</h2>
<blockquote>
<p>It doesn't matter which operating system and which shells you are using, alias, all the same, some here and there technically.</p>
</blockquote>
<p>Suppose this is your base directory for Flutter SDKs.
<code>$HOME/dev/flutter_sdks</code></p>
<p>And here you download different channels to flutter SDK</p>
<pre><code>cd $HOME/dev/flutter_sdks
git <span class="hljs-keyword">clone</span> -b stable https:<span class="hljs-comment">//github.com/flutter/flutter.git flutter_stable</span>
git <span class="hljs-keyword">clone</span> -b beta https:<span class="hljs-comment">//github.com/flutter/flutter.git flutter_beta</span>
git <span class="hljs-keyword">clone</span> -b dev https:<span class="hljs-comment">//github.com/flutter/flutter.git flutter_dev</span>
git <span class="hljs-keyword">clone</span> -b master https:<span class="hljs-comment">//github.com/flutter/flutter.git flutter_master</span>
</code></pre><p>Now it's time to check everything present in your base directory.</p>
<pre><code> ╭─adityaa<span class="hljs-meta">@naveen</span> <span class="hljs-keyword">in</span> ~<span class="hljs-regexp">/dev/</span>flutter_sdks 
 ╰─λ ls
flutter_stable
flutter_beta
flutter_dev
flutter_master
</code></pre><p>Now it's time to aliases, open your <code>.bashrc</code>, <code>.zshrc</code>, <code>config.fish</code>, or whatever.</p>
<p><code>vim ~/.bashrc</code></p>
<pre><code class="lang-bash"><span class="hljs-comment"># flutter sdks alias</span>
 <span class="hljs-built_in">alias</span> flutter=<span class="hljs-string">"<span class="hljs-variable">$HOME</span>/dev/flutter_sdks/flutter_stable"</span>
 <span class="hljs-built_in">alias</span> flutterb=<span class="hljs-string">"<span class="hljs-variable">$HOME</span>/dev/flutter_sdks/flutter_beta"</span>
 <span class="hljs-built_in">alias</span> flutterd=<span class="hljs-string">"<span class="hljs-variable">$HOME</span>/dev/flutter_sdks/flutter_dev"</span>
 <span class="hljs-built_in">alias</span> flutterm=<span class="hljs-string">"<span class="hljs-variable">$HOME</span>/dev/flutter_sdks/flutter_master"</span>
</code></pre>
<p>Now you can use the naive version through aliases</p>
<blockquote>
<p>Note! You can not only clone branches but also clone versions via a tag.</p>
</blockquote>
<h2 id="tool-based">Tool based</h2>
<p>Flutter Version Manager is a very important and easiest way to manage multiple Flutter SDK versions and channels without going into the complete installation setup whenever we need to access some other version for our projects.</p>
<blockquote>
<p>FVM follows the same principle as our aliasing approach but the only difference is that FVM global Config and default directory use a symbolic link to a particular Flutter version.</p>
</blockquote>
<h2 id="steps-for-installation-of-flutter-version-manager">Steps For Installation Of Flutter Version Manager</h2>
<ul>
<li><p>First step is to check that Flutter, is installed or not on our system, to work on FVM. Run the following command on your terminal-</p>
<pre><code>flutter
</code></pre><p>If the Flutter, is already installed on your system, it will show us some common commands used in Flutter. </p>
<p>In addition to this, if you want to know your Flutter version, you can run the command.</p>
<pre><code>flutter <span class="hljs-comment">--version</span>
</code></pre><p>This command will return the exact version of Flutter and Dart installed on our system.</p>
</li>
</ul>
<ul>
<li><p>Now, in the next step we will have to activate FVM on our system, for that we will have to run the command</p>
<pre><code>pub <span class="hljs-keyword">global</span> activate fvm
</code></pre><blockquote>
<p>⚠️ Do not activate FVM using flutter pub global activate if you plan on using the --global flag. Only activate FVM using pub global activate fvm. </p>
<blockquote>
<p><a target="_blank" href="https://dart.dev/tools/pub/cmd/pub-global#running-a-script">Read dart.dev docs for more</a>  info on how to run global dart scripts.</p>
</blockquote>
</blockquote>
</li>
<li><p>We will now see that some warnings are given at the end of the installation process, so we need to add the fvm path to the shell configuration file (.bashrc, bash_profile, etc.) before taking the next step</p>
<pre><code><span class="hljs-built_in">export</span> PATH=<span class="hljs-string">"<span class="hljs-variable">$PATH</span>:`pwd`/flutter/bin"</span>
<span class="hljs-built_in">export</span> PATH=<span class="hljs-string">"<span class="hljs-variable">$PATH</span>:`pwd`/.pub-cache/bin"</span>
</code></pre><p>Now, the warning will be removed. For verifying that FVM is now completely activated, we will run the <code>$echo PATH</code> command, which will give us the path for the same.</p>
</li>
</ul>
<h3 id="sdk-version-install">SDK Version Install:</h3>
<p>FVM allows us to install multiple types of Flutter releases or channels. </p>
<ul>
<li><code>version</code> - use <code>stable</code> to install the Stable channel and <code>v1.8.0</code> or <code>1.17.0-dev.3.1</code> to install the release.</li>
<li><code>--skip-setup</code> - will skip Flutter setup after install</li>
</ul>
<pre><code>fvm <span class="hljs-keyword">install</span> &lt;<span class="hljs-keyword">version</span>&gt;
</code></pre><h3 id="project-config-sdk-version">Project Config SDK Version:</h3>
<p>After that, we will see whether the project is configured to use a specific version or not. If not, we will install it on the appropriate version without arguments.</p>
<pre><code><span class="hljs-attribute">fvm</span> install
</code></pre><h3 id="use-an-sdk-version">Use an SDK Version</h3>
<p>You can use different Flutter SDK versions per project. To do that, you have to go into the root of the project and:</p>
<pre><code>fvm <span class="hljs-keyword">use</span> &lt;<span class="hljs-keyword">version</span>&gt;
</code></pre><p>If you want to use a specific version by default in your machine, you can specify the flag <code>--global</code> to the use command. A symbolic link to the Flutter version will be created in the <code>fvm</code>home folder, which you could then add to your PATH environment variable as follows: <code>FVM_HOME/default/bin</code>. Use <code>fvm use --help</code>, this will give you the exact path you need to configure.</p>
<h3 id="flutter-installed-versions-list">Flutter Installed Versions List:</h3>
<p>Now by typing in the following command, we can list the installed version on our machine by using the below command. FVM will store the SDK version.</p>
<pre><code>fvm <span class="hljs-keyword">list</span>
</code></pre><h3 id="upgrade-sdk-version">Upgrade SDK Version:</h3>
<p>Using the upgrade SDK version command, when we need to upgrade our current SDK version, so you have to call the command of your flutter SDK as in normal flutter installation.</p>
<pre><code><span class="hljs-attribute">fvm</span> flutter upgrade
</code></pre><h3 id="set-up-ide">Set Up IDE:</h3>
<p>Now we will see how to configure IDE. Below, we have shown how to configure the Android Studio and VS Code. Let's see it now.</p>
<p>  <strong>⇒ Android Studio:</strong></p>
<p>In your root project directory, copy the absolute path of the fvm symbolic link.<br />Example: <code>/absolute/path-to-your-project/.fvm/flutter_sdk</code></p>
<p>After that, we will open <code>Languages and Frameworks</code> in the menu of Android Studio → Now, search for flutter and change the path to flutter SDK path. Now you can run it with selected versions of Flutter and debug it. </p>
<p>  <strong>⇒ VS Code:</strong></p>
<p>Now we will configure VS Code, here we will see how to complete the VS Code process.</p>
<p>Add the following to your <code>settings.json</code>. This will list all Flutter SDKs installed when using VSCode when using <code>Flutter: Change SDK</code>.</p>
<p>Use <code>fvm list</code> to show you the path to the versions.</p>
<p>List all versions installed by FVM.</p>
<pre><code class="lang-JSON">{
  <span class="hljs-attr">"dart.flutterSdkPaths"</span>: [<span class="hljs-string">"/Users/usr/fvm/versions"</span>]
}
</code></pre>
<p>You can also add the version symlink for dynamic switch
``` JSON
{
  "dart.flutterSdkPaths": [".fvm/flutter_sdk"]
}</p>
<h3 id="use-fvm-in-your-project">Use FVM in Your Project</h3>
<p>The goal is to apply a specific Flutter version to your project by using FVM.</p>
<ul>
<li><p>Create a Flutter project in your development folder by executing <code>flutter create project_name</code>:
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1630170363466/sE0cBT6B8.png" alt="flutter create.png" /></p>
</li>
<li><p>Switch to your project directory and execute <code>fvm use &lt;version_you_want&gt;</code>:
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1630170442206/iDuI8qD4K.png" alt="fvm use.png" /></p>
</li>
<li><p>If you run <code>fvm list</code> once again, you can see a tick mark  or <code>active</code> by the version you are using in the project:
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1630170757465/SuqfahNjs.png" alt="fvm list.png" /></p>
</li>
</ul>
<p>If you want more information and configuration of the fvm, see the official <a target="_blank" href="https://fvm.app">docs</a>.</p>
<p><strong><em>If I make any kind of mistake, let me know in the comment box and correct me. And I hope that you like and are helpful to you this article.</em></strong></p>
]]></content:encoded></item><item><title><![CDATA[How to Auto-Mount Drives in Linux]]></title><description><![CDATA[Today I’m going to show you how to automatically mount a drive at boot time in Linux. In most Linux distributions non-boot drives are not mounted when you boot into the system. They do mount when you open them, but it is helpful in many cases to alre...]]></description><link>https://blog.naveenaditya.dev/how-to-auto-mount-drives-in-linux</link><guid isPermaLink="true">https://blog.naveenaditya.dev/how-to-auto-mount-drives-in-linux</guid><category><![CDATA[Linux]]></category><category><![CDATA[storage]]></category><dc:creator><![CDATA[Aditya Agarwal]]></dc:creator><pubDate>Sat, 13 Mar 2021 16:49:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1615218969080/GGVbANqQR.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Today I’m going to show you how to automatically mount a drive at boot time in Linux. In most Linux distributions non-boot drives are not mounted when you boot into the system. They do mount when you open them, but it is helpful in many cases to already have the drive mounted when you first boot up your machine.</p>
<p>For example, I have my Backup on one partition and content in another.</p>
<blockquote>
<p><strong>!Warning</strong>: Doing this requires editing the fstab file in the /etc/ be careful while doing this. Mistakes may cause boot or other issues.</p>
<p>Note: I don't have another drive, So I show in same drive and in different partition. </p>
</blockquote>
<h3 id="identifying-the-disk">Identifying the Disk</h3>
<p>There are two ways to do this. The first is through a GUI disk manager on your system or through the terminal. I recommend using the terminal, but it’s always good to double-check on a disk manager such as Disks, KDE Partition Manager, or GParted.</p>
<p>To do this though a program you can open the ‘Disks’ utility and identify the drive. You’re going to want to find the Device, UUID, and the type of file system. For my example, I will be mounting my Backup drive.</p>
<blockquote>
<p>Removable Media: Mounting removable storage such as USB’s, SD cards, etc, in fstab will result in an un-bootable system if the removable storage isn’t present and connected at boot time.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1615647119101/tk8TiWlqp.png" alt="Disks.png" /></p>
<p>Finding the device information though the terminal is very easy and in most cases preferred to using software.</p>
<p>Find the <code>fdisk</code> list command to see all drives and their partitions.</p>
<pre><code><span class="hljs-attribute">sudo</span> fdisk -l
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1615648421156/D1rONkNTC.png" alt="Fdisk.png" /></p>
<p>The <code>blkid</code> command allows you to display information about available block devices. This will allow you to view the file system type, UUID, labels, and more.</p>
<pre><code><span class="hljs-attribute">sudo</span> blkid
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1615648596568/IxQ0YLH80.png" alt="Blkid.png" /></p>
<p>Note down the UUID of the partitions that you want to mount at startup.</p>
<h3 id="make-a-mount-point">Make a Mount Point</h3>
<p>Now that you know your disk UUID we will create the mounting directory. You can make this almost anywhere, but it is common practice to do this in the /media folder. Type the following command replacing “Backup” with whatever you want it to be called.</p>
<pre><code>sudo <span class="hljs-keyword">mkdir</span> /media/Backup
</code></pre><h3 id="edit-etcfstab-file">Edit /etc/fstab File</h3>
<p>We will edit our fstab file. First we need to open the file in nano or whatever editor you want with superuser privileges.</p>
<pre><code><span class="hljs-attribute">sudo</span> nano /etc/fstab
</code></pre><p>Now we will input the information of the disk, so it will mount on boot. You need to pay attention to how it is typed. Instead of typing a space make sure you hit tab. I start with a note (anything with a # will be ignored by the system) so it's easy to tell what drive is what. For my example I will type:</p>
<pre><code><span class="hljs-comment"># Backup (dev/sda6)</span>
</code></pre><p>Now the input will look something like this. Be sure to replace the UUID, mount point, and file system type to match your drive. See the image below.</p>
<pre><code><span class="hljs-attribute">UUID</span>=<span class="hljs-number">9</span>a<span class="hljs-number">86</span>ee<span class="hljs-number">6</span>c-caf<span class="hljs-number">0</span>-<span class="hljs-number">4</span>c<span class="hljs-number">35</span>-<span class="hljs-number">8</span>aa<span class="hljs-number">9</span>-<span class="hljs-number">117949</span>c<span class="hljs-number">1</span>ee<span class="hljs-number">09</span>       /media/Backup    ext<span class="hljs-number">4</span>     defaults      <span class="hljs-number">0</span>      <span class="hljs-number">0</span>
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1615649766230/kwckUBOyF.png" alt="Fstab.png" /></p>
<p>Breaking that line down, we have:</p>
<ul>
<li>UUID=9a86ee6c-caf0-4c35-8aa9-117949c1ee09 - is the UUID of the drive. You don't have to use the UUID here. You could just use /dev/sda6, but it's always safer to use the UUID as that will never change.</li>
<li>/media/Backup - is the mount point for the device.</li>
<li>ext4 - is the filesystem type.</li>
<li>defaults - is the default mount settings.</li>
<li>0 - determines which filesystem need to be dumped (0 is the default).</li>
<li>0 - determine the order in which filesystem checks are done at boot time (0 is the default).</li>
</ul>
<p>Now we will CTRL-O, and it ENTER to save the file. Reboot your system and it should be mounted!</p>
<p>For our purposes defaults 0 0 will work fine.</p>
<p><a target="_blank" href="https://wiki.archlinux.org/index.php/fstab">Learn more about fstab settings here!</a> </p>
<h3 id="test-fstab">Test fstab</h3>
<p>After you edit fstab, enter this command that will mount all drives set to auto-mount. If this gives you any errors ensure you’ve entered everything correctly.</p>
<pre><code><span class="hljs-attribute">sudo</span> mount -a
</code></pre><p>If nothing is returned (e.g. no errors) then you should be good to go.</p>
<p>There you go. You should see all the drives you have configured to automatically mount in your system!</p>
<p>For more information follow this link,</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.howtogeek.com/444814/how-to-write-an-fstab-file-on-linux/">https://www.howtogeek.com/444814/how-to-write-an-fstab-file-on-linux/</a></div>
]]></content:encoded></item><item><title><![CDATA[Why Idempotent is very critical in Backend Applications]]></title><description><![CDATA[Today, I am here discussing "Exactly-once delivery". Now you puzzled by that sentence what I am trying to say that thing is one of the hard problems in the Distributed System and her solution is Idempotency.
Idempotency is something you might not see...]]></description><link>https://blog.naveenaditya.dev/why-idempotent-is-very-critical-in-backend-applications</link><guid isPermaLink="true">https://blog.naveenaditya.dev/why-idempotent-is-very-critical-in-backend-applications</guid><category><![CDATA[backend]]></category><category><![CDATA[Developer]]></category><dc:creator><![CDATA[Aditya Agarwal]]></dc:creator><pubDate>Tue, 19 May 2020 17:55:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1589910920694/dE62JBbv_.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Today, I am here discussing <strong>&quot;Exactly-once delivery&quot;</strong>. Now you puzzled by that sentence what I am trying to say that thing is one of the hard problems in the Distributed System and her solution is Idempotency.</p>
<p>Idempotency is something you might not see every day, but it is an important concept, especially when you are making payments.</p>
<p>As a developer, you are always wanting things to go smoothly, but in the world of REST APIs, that isn’t always the case. Client failures, networking errors, or just poorly written code can all spell trouble for an API call (and your end-user experience). Luckily, idempotency is here to help! It can be a little confusing at first, but once you have a handle on it, you’ll see that it is an important aspect of designing and using mission-critical systems.</p>
<p>Idempotency is an often-used term in computer science. It&#39;s meaning to some might not be known, to others, it&#39;s very well known. The explanation for idempotency is:</p>
<blockquote>
<p>The property of some operations such that no matter how many times you execute then, you achieve the same result.</p>
</blockquote>
<p>In the context of a developer working with REST APIs, your application is sending requests and getting back responses with some other service on the internet. When that API is an idempotent guarantee that when you send an identical request you will always get an identical response. What do I mean by identical? The headers, body, authorization, everything needs to be exactly the same.</p>
<p>Not all REST APIs use idempotency, most of the time it is only necessary for requests that influence the state of something, or you really don’t want to accidentally run twice. For many APIs, this is limited to POST or PUT requests, whereas most “state neutral” requests do not add the complexity to their interfaces.</p>
<p>Let&#39;s understand that with a simple example:</p>
<p>When Client/End-User wants some information usually the <code>GET</code> method is used. Way change user mistakenly requests 10 times or even millions of times then that information doesn&#39;t change in meanwhile. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1589905254944/eJWy4gPcm.png" alt="get_resquest.png"></p>
<p>But, When the user used <code>POST</code> request quite several times, then might that identical requests is stored multiple times in the database. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1589907414665/vwO8EphSS.png" alt="post_request.png"></p>
<p>Originally we as a Developer does not want that going on, which lead to a fatal mistake accidentally. So in my point of view, there is two way we can avoid that error:</p>
<ol>
<li><p>Suppose we are going to make order in amazon site to buy hard drive in that case amazon put some <code>param</code> in API of order like: </p>
<p> <code>POST /order/:userId/:productId/</code></p>
<p> In that case, the server only checks product and user already make an order or not if not make entries in the database. If the next request is the same then the server regret request and then not make two orders of the same product.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1589908923078/CYXeT8dMQ.png" alt="post_param.png"></p>
<ol>
<li>Some of the developers using hashing. They hash the <code>body</code> of requests and check hash are present in the database or not, if not then feed in the database.</li>
</ol>
<blockquote>
<p>In my point of understanding view, these are an easy approach to deal with that kind mistake, and maybe more solutions are available than these two.  </p>
</blockquote>
<p>Essentially, idempotency is the mathematical way of saying “one can apply a certain operation on something many times, without changing the result of the operation after the first time the operation is applied”.</p>
<p>If you want to learn more about this then follows these link:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" data-card-width="600px" data-card-key="2e4d628b39a64b99917c73956a16b477" href="https://developers.google.com/standard-payments/reference/idempotent-behavior-examples" data-card-controls="0" data-card-theme="light">https://developers.google.com/standard-payments/reference/idempotent-behavior-examples</a></div>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" data-card-width="600px" data-card-key="2e4d628b39a64b99917c73956a16b477" href="https://blog.pragmaticengineer.com/distributed-architecture-concepts-i-have-learned-while-building-payments-systems/" data-card-controls="0" data-card-theme="light">https://blog.pragmaticengineer.com/distributed-architecture-concepts-i-have-learned-while-building-payments-systems/</a></div>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" data-card-width="600px" data-card-key="2e4d628b39a64b99917c73956a16b477" href="https://medium.com/airbnb-engineering/avoiding-double-payments-in-a-distributed-payments-system-2981f6b070bb" data-card-controls="0" data-card-theme="light">https://medium.com/airbnb-engineering/avoiding-double-payments-in-a-distributed-payments-system-2981f6b070bb</a></div>
]]></content:encoded></item></channel></rss>