<?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: Rakesh Chaubey</title>
    <description>The latest articles on DEV Community by Rakesh Chaubey (@rakesh_chaubey_ac4fa25823).</description>
    <link>https://dev.to/rakesh_chaubey_ac4fa25823</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%2F3209184%2Ff833fe41-13ff-4d2a-a5f4-c08728791fbc.png</url>
      <title>DEV Community: Rakesh Chaubey</title>
      <link>https://dev.to/rakesh_chaubey_ac4fa25823</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rakesh_chaubey_ac4fa25823"/>
    <language>en</language>
    <item>
      <title>Docker with ASP.NET</title>
      <dc:creator>Rakesh Chaubey</dc:creator>
      <pubDate>Mon, 23 Jun 2025 17:17:46 +0000</pubDate>
      <link>https://dev.to/rakesh_chaubey_ac4fa25823/docker-with-aspnet-21h0</link>
      <guid>https://dev.to/rakesh_chaubey_ac4fa25823/docker-with-aspnet-21h0</guid>
      <description>&lt;p&gt;📦 Docker Setup for .NET 8 Web API Project&lt;br&gt;
This document describes how to create a Docker image and run a container for a .NET 8 Web API using a multi-stage Dockerfile.&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%2Fguv3stwdn8xu977mavcq.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%2Fguv3stwdn8xu977mavcq.png" alt="Image description" width="800" height="531"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Docker Ignore&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%2F5i65jiwdo97xtal8g1hz.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%2F5i65jiwdo97xtal8g1hz.png" alt="Image description" width="800" height="437"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Docker file in visual studio proj&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker Image&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%2F17jgr7lgmyxrgd82zthd.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%2F17jgr7lgmyxrgd82zthd.png" alt="Image description" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker Container&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%2F5h1xnh3hrlqwfhfooya9.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%2F5h1xnh3hrlqwfhfooya9.png" alt="Image description" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;You can have as many container you want for an image&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠 Dockerfile Breakdown&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;# Stage 1: Build Environment
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
# 👉 Using .NET SDK 8.0 image for build

WORKDIR /App
# 👉 Set working directory inside container to /App

COPY . ./
# 👉 Copy all files from the current directory to /App inside container

RUN dotnet restore
# 👉 Restore all NuGet packages based on the .csproj file

RUN dotnet publish -c Release -o out
# 👉 Build and publish the app to the /App/out folder in Release mode

# Stage 2: Runtime Image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
# 👉 Use a lighter ASP.NET runtime image for running the app

WORKDIR /App
# 👉 Set working directory again to /App in the runtime image

COPY --from=build-env /App/out .
# 👉 Copy published output from the build stage

EXPOSE 8085
# 👉 Expose port 8085 in the container (used by the app)

ENTRYPOINT ["dotnet", "DemoAPi.dll"]
# 👉 Start the app using dotnet CLI

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🐳 Docker Commands&lt;br&gt;
🔧 Build the Docker Image&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;docker build -t demoimage .

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

&lt;/div&gt;



&lt;p&gt;-t demoimage: Tags the image with name demoimage.&lt;/p&gt;

&lt;p&gt;.: Refers to the current directory where Dockerfile exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🚀 Run the Docker Container&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;docker run -d --name demo-c -p 8080:8085 demoimage

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

&lt;/div&gt;



&lt;p&gt;-d: Detached mode (runs in background).&lt;/p&gt;

&lt;p&gt;--name demo-c: Container name is demo-c.&lt;/p&gt;

&lt;p&gt;-p 8080:8085: Maps port 8080 on host to port 8085 inside container.&lt;/p&gt;

&lt;p&gt;demoimage: Name of the image to use for the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🌐 Test the API&lt;/strong&gt;&lt;br&gt;
Open your browser or use a tool like Postman to test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8085/WeatherForecast/

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;📝 Summary&lt;/strong&gt;&lt;br&gt;
Multi-stage Dockerfile ensures smaller final image.&lt;/p&gt;

&lt;p&gt;App is built and published in one stage, and only output is copied to runtime image.&lt;/p&gt;

&lt;p&gt;Use port mapping to expose your app externally.&lt;/p&gt;

&lt;p&gt;You can create multiple containers from the same image anytime.&lt;/p&gt;

&lt;p&gt;---Rough note in hindi&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
# Bhai dotnet sdk 8.0 le aa
WORKDIR /App
# saare cheeze app folder main daalo

# Copy everything to app folder
COPY . ./
# Restore as distinct layers//Aab proj file se sab dll restore kar with exact version
RUN dotnet restore
# Build and publish a release---App folder ke andar outfolder hain usme dal to release code 
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
# sdk bana ke 
WORKDIR /App
# app folder main saara code alread hain upar command ne kiya tha  
COPY --from=build-env /App/out .
# ek port expose karna hoga jaise agar local host call hoga tab kaun se port pe call jayega woh
EXPOSE 8085
# JAB BHI LOCAL HOST SE CALL KAROGE 8085 PORT PE TAB YE APPLICATION RUN HOGA 
# first line wale build env se sab kuch app out main past e hoga 
ENTRYPOINT ["dotnet", "DemoAPi.dll"]
# Project name 


#docker build -t demoimage .
#eska matlab . represt in current directory docker file.
#run this in docker termial it will create image
# now you have created an image for a project . Aab chao to 1000000 container bana do es image ke. Jitne chahe utne 
# Now so as to create container we need to run docker run -d --name demo-c -p 8080:8085 demo-image
# here you are saying docker please run  dettach mode container name (any) which port you want run(localmhost) 
#and also docker host configured in project  and also name of the image you created above
# Now container in ready.
#So as to test run in terminal start "http://localhost:8080/WeatherForecast/"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Time &amp; Space Complexity</title>
      <dc:creator>Rakesh Chaubey</dc:creator>
      <pubDate>Mon, 26 May 2025 10:05:09 +0000</pubDate>
      <link>https://dev.to/rakesh_chaubey_ac4fa25823/time-space-complexity-2k0f</link>
      <guid>https://dev.to/rakesh_chaubey_ac4fa25823/time-space-complexity-2k0f</guid>
      <description>&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;br&gt;
You have a list of packages arriving at a warehouse. Each package has a tracking number. Your task is to find duplicate packages based on their tracking number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Different Approaches to Solve This Problem&lt;/strong&gt;&lt;br&gt;
Approach 1: Naive — Compare every package with every other package&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bool HasDuplicates_Naive(List&amp;lt;string&amp;gt; trackingNumbers)
{
    int n = trackingNumbers.Count;

    for (int i = 0; i &amp;lt; n; i++)
    {
        for (int j = i + 1; j &amp;lt; n; j++)
        {
            if (trackingNumbers[i] == trackingNumbers[j])
                return true; // duplicate found
        }
    }
    return false; // no duplicates
}

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

&lt;/div&gt;



&lt;p&gt;Time Complexity Analysis:&lt;br&gt;
Ou&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ter loop runs n times.&lt;/li&gt;
&lt;li&gt;Inner loop runs about n - 1, then n - 2, ..., 1 times.&lt;/li&gt;
&lt;li&gt;Total comparisons ≈ n * (n - 1) / 2 ≈ O(n²) (quadratic).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As the number of packages grows, this approach becomes very slow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Space Complexity Analysis:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We only use a few variables.&lt;/li&gt;
&lt;li&gt;Space complexity is O(1) (constant space).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Approach 2: Using a HashSet (better approach)&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;bool HasDuplicates_HashSet(List&amp;lt;string&amp;gt; trackingNumbers)
{
    HashSet&amp;lt;string&amp;gt; seen = new HashSet&amp;lt;string&amp;gt;();

    foreach (var number in trackingNumbers)
    {
        if (seen.Contains(number))
            return true; // duplicate found

        seen.Add(number);
    }
    return false; // no duplicates
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Time Complexity Analysis:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Loop runs n times.&lt;/li&gt;
&lt;li&gt;Each lookup and add in HashSet is average O(1).&lt;/li&gt;
&lt;li&gt;So total time is O(n) (linear).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Space Complexity Analysis:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We use extra space for the HashSet.&lt;/li&gt;
&lt;li&gt;In the worst case (no duplicates), the HashSet stores all n tracking numbers.&lt;/li&gt;
&lt;li&gt;So space complexity is O(n).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Explanation in Human Terms (Logistics Domain)&lt;/strong&gt;&lt;br&gt;
Naive Approach: Like checking every package manually against every other package to find duplicates — this takes a lot of time as packages grow.&lt;/p&gt;

&lt;p&gt;HashSet Approach: Like having a quick scanning system that remembers every package’s tracking number as you scan, instantly checking if a package is already scanned.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Time Complexity&lt;/th&gt;
&lt;th&gt;Space Complexity&lt;/th&gt;
&lt;th&gt;Real-World Analogy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Naive Comparison&lt;/td&gt;
&lt;td&gt;O(n²)&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;Manually checking every package against others&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HashSet&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;Scanning and recording each package for fast duplicate detection&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Run this in local to see the result&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;using System;
using System.Collections.Generic;
using System.Diagnostics;

class Program
{
    static bool HasDuplicates_Naive(List&amp;lt;string&amp;gt; trackingNumbers)
    {
        int n = trackingNumbers.Count;

        for (int i = 0; i &amp;lt; n; i++)
        {
            for (int j = i + 1; j &amp;lt; n; j++)
            {
                if (trackingNumbers[i] == trackingNumbers[j])
                    return true;
            }
        }
        return false;
    }

    static bool HasDuplicates_HashSet(List&amp;lt;string&amp;gt; trackingNumbers)
    {
        HashSet&amp;lt;string&amp;gt; seen = new HashSet&amp;lt;string&amp;gt;();

        foreach (var number in trackingNumbers)
        {
            if (seen.Contains(number))
                return true;

            seen.Add(number);
        }
        return false;
    }

    static void Main()
    {
        int n = 10000;
        var packages = new List&amp;lt;string&amp;gt;();

        for (int i = 0; i &amp;lt; n; i++)
            packages.Add($"PKG{i}");

        // Add a duplicate at the end
        packages.Add("PKG1234");

        var sw = Stopwatch.StartNew();
        Console.WriteLine("Naive: " + HasDuplicates_Naive(packages));
        sw.Stop();
        Console.WriteLine($"Naive time: {sw.ElapsedMilliseconds} ms");

        sw.Restart();
        Console.WriteLine("HashSet: " + HasDuplicates_HashSet(packages));
        sw.Stop();
        Console.WriteLine($"HashSet time: {sw.ElapsedMilliseconds} ms");
    }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final Takeaway for You as a .NET Logistics Developer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time Complexity is about how fast your code runs when the number of packages grows.&lt;/li&gt;
&lt;li&gt;Space Complexity is about how much extra memory your code needs.&lt;/li&gt;
&lt;li&gt;When designing microservices or APIs for logistics, choose algorithms that balance speed and memory wisely.&lt;/li&gt;
&lt;li&gt;Using collections like HashSet or Dictionary often improves time complexity at the cost of space.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Let me give a very easy example:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;br&gt;
Imagine you work in a logistics warehouse that receives thousands of packages daily. Each package has a unique tracking number.&lt;/p&gt;

&lt;p&gt;Your job is to detect if there are duplicate packages — meaning if the same tracking number appears more than once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Is This Important?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detecting duplicates helps avoid shipping mistakes, incorrect billing, or inventory errors.&lt;/li&gt;
&lt;li&gt;The solution must be efficient — warehouses handle millions of packages in real-time.&lt;/li&gt;
&lt;li&gt;Inefficient algorithms can cause delays or crash systems due to slow processing or memory issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The First (Naive) Approach: What Was Wrong?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compare every package with every other package to find duplicates.&lt;/li&gt;
&lt;li&gt;For example, if you have 10 packages:&lt;/li&gt;
&lt;li&gt;Compare package 1 with package 2, 3, 4...&lt;/li&gt;
&lt;li&gt;Then compare package 2 with package 3, 4, 5... and so on.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int i = 0; i &amp;lt; n; i++)
{
    for (int j = i + 1; j &amp;lt; n; j++)
    {
        if (trackingNumbers[i] == trackingNumbers[j])
            return true;
    }
}
return false;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What’s Wrong Here?&lt;/strong&gt;&lt;br&gt;
Time Complexity: This approach takes O(n²) time because for n packages, it does roughly n * (n-1) / 2 comparisons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does that mean?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you double the number of packages, the work done more than quadruples.&lt;br&gt;
Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10 packages → 45 comparisons&lt;/li&gt;
&lt;li&gt;100 packages → 4,950 comparisons&lt;/li&gt;
&lt;li&gt;1,000 packages → 499,500 comparisons&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;: The algorithm gets very slow and impractical as the number of packages grows large (which is typical in logistics).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Better Approach: Using a HashSet&lt;br&gt;
Concept in Logistics Terms&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Imagine a scanner that checks each package’s tracking number as it arrives.&lt;/li&gt;
&lt;li&gt;The scanner keeps a list (a “memory”) of all scanned tracking numbers.&lt;/li&gt;
&lt;li&gt;When a new package arrives, the scanner quickly checks if this number is already in the list.&lt;/li&gt;
&lt;li&gt;If yes → duplicate found!&lt;/li&gt;
&lt;li&gt;If no → add it to the list and continue scanning.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HashSet&amp;lt;string&amp;gt; seen = new HashSet&amp;lt;string&amp;gt;();

foreach (var number in trackingNumbers)
{
    if (seen.Contains(number))
        return true; // duplicate found

    seen.Add(number);
}
return false; // no duplicates

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What Has Changed?&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Time Complexity:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Checking if a number is in the HashSet is O(1) on average (constant time).&lt;/li&gt;
&lt;li&gt;You only loop once over all packages → O(n) total time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Space Complexity:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You use extra memory to store the tracking numbers in the HashSet → O(n) space.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tradeoff:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You spend some memory to drastically reduce the processing time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Is the HashSet Approach Much Better?&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;Scenario&lt;/th&gt;
&lt;th&gt;Naive Approach&lt;/th&gt;
&lt;th&gt;HashSet Approach&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Number of Packages (n)&lt;/td&gt;
&lt;td&gt;1,000&lt;/td&gt;
&lt;td&gt;1,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Number of Comparisons&lt;/td&gt;
&lt;td&gt;~499,500&lt;/td&gt;
&lt;td&gt;1,000 lookups (plus add ops)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Time to Detect Duplicates&lt;/td&gt;
&lt;td&gt;Very slow&lt;/td&gt;
&lt;td&gt;Very fast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory Usage&lt;/td&gt;
&lt;td&gt;Very low (constant)&lt;/td&gt;
&lt;td&gt;Moderate (proportional to n)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Real-World Analogy&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Naive&lt;/strong&gt;: Like an employee who manually compares each package against every other one — gets tired and slow as packages pile up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HashSet&lt;/strong&gt;: Like a smart scanning machine that instantly checks each package against a database of scanned packages — fast even if the number of packages is huge.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>XML</title>
      <dc:creator>Rakesh Chaubey</dc:creator>
      <pubDate>Mon, 26 May 2025 09:42:52 +0000</pubDate>
      <link>https://dev.to/rakesh_chaubey_ac4fa25823/xml-2llm</link>
      <guid>https://dev.to/rakesh_chaubey_ac4fa25823/xml-2llm</guid>
      <description>&lt;p&gt;Today, JSON rules the world. But before that — and still in many large enterprises — XML was (and is) the silent workhorse. And in the logistics industry, you'll still find a lot of XML powering core systems like shipment tracking, ERP sync, customs data, and invoicing.&lt;/p&gt;

&lt;p&gt;In this post, we’ll cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What XML is (with a real-world example)&lt;/li&gt;
&lt;li&gt;Where it’s still used in logistics&lt;/li&gt;
&lt;li&gt;Why some systems prefer it over JSON&lt;/li&gt;
&lt;li&gt;Tips to handle XML well&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🧠 &lt;strong&gt;What is XML?&lt;/strong&gt;&lt;br&gt;
XML (eXtensible Markup Language) is a text-based format used to store and exchange structured data. Think of it like HTML, but for data — and it’s both human-readable and machine-readable.&lt;br&gt;
It uses opening and closing tags to define each field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s a simple logistics-related XML:&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;&amp;lt;Shipment&amp;gt;
  &amp;lt;ShipmentId&amp;gt;SHIP-98765&amp;lt;/ShipmentId&amp;gt;
  &amp;lt;Origin&amp;gt;Mumbai&amp;lt;/Origin&amp;gt;
  &amp;lt;Destination&amp;gt;Hyderabad&amp;lt;/Destination&amp;gt;
  &amp;lt;Status&amp;gt;Out for Delivery&amp;lt;/Status&amp;gt;
  &amp;lt;Items&amp;gt;
    &amp;lt;Item&amp;gt;
      &amp;lt;SKU&amp;gt;T-SHIRT&amp;lt;/SKU&amp;gt;
      &amp;lt;Quantity&amp;gt;2&amp;lt;/Quantity&amp;gt;
    &amp;lt;/Item&amp;gt;
  &amp;lt;/Items&amp;gt;
&amp;lt;/Shipment&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pretty neat, right? This looks very similar to what you'd send or receive in a SOAP API or through an enterprise file-based integration.&lt;/p&gt;

&lt;p&gt;🚚 &lt;strong&gt;Where XML is Still Used in Logistics&lt;/strong&gt;&lt;br&gt;
Even today, major Indian logistics companies and their backend systems — whether in supply chains, freight networks, or ERP systems — still exchange XML data regularly.&lt;/p&gt;

&lt;p&gt;🔄 &lt;strong&gt;Here are a few real-life examples:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🧾 Invoices and billing exchanged via EDI/XML&lt;/li&gt;
&lt;li&gt;📤 Shipment updates between warehouse management systems&lt;/li&gt;
&lt;li&gt;✈️ Customs declaration documents for international shipments&lt;/li&gt;
&lt;li&gt;🏦 Payment or reconciliation files from banks in XML format&lt;/li&gt;
&lt;li&gt;🔁 Legacy SOAP APIs (still common in big orgs)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Why XML is Still Preferred in Some Cases&lt;/strong&gt;&lt;br&gt;
Feature Why It Matters in Logistics&lt;br&gt;
Strict structure    Ensures every document follows a defined format (using XSD schemas)&lt;br&gt;
Validation-ready    You can catch errors before processing&lt;br&gt;
Namespaces  Helpful in large B2B integrations to avoid field conflicts&lt;br&gt;
Mature ecosystem    Works well with legacy tools like BizTalk, SAP, Oracle, etc.&lt;br&gt;
SOAP Support    Some logistics APIs still expose SOAP endpoints (which use XML)&lt;/p&gt;

&lt;p&gt;Also, &lt;strong&gt;XML is verbose&lt;/strong&gt;(&lt;strong&gt;verbose&lt;/strong&gt;:XML uses a lot of repeating tags and extra characters (like angle brackets) to describe data.), but that’s not always a bad thing. When clarity and data reliability are more important than size (like in customs or compliance), XML shines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;verbose&lt;/strong&gt;: XML uses a lot of repeating tags and extra characters (like angle brackets) to describe data. This leads to larger file sizes and more bandwidth usage&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Status&amp;gt;Delivered&amp;lt;/Status&amp;gt;
&amp;lt;Location&amp;gt;Mumbai&amp;lt;/Location&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In XML, each piece of data requires:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An opening tag ()&lt;/li&gt;
&lt;li&gt;A closing tag ()&lt;/li&gt;
&lt;li&gt;And if nested, even more structure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔧 &lt;strong&gt;Best Practices When Working with XML&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Use XSD for Validation&lt;/strong&gt;: Is explained at bottom&lt;br&gt;
Don’t accept XML blindly — validate it using an XML Schema Definition (XSD) to make sure it’s safe and structured properly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Avoid Deep Nesting&lt;/strong&gt;&lt;br&gt;
Logistics data often involves nested items — keep your hierarchy simple to avoid parser issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prefer Elements Over Attributes (Usually)&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;&amp;lt;Item&amp;gt;
  &amp;lt;SKU&amp;gt;T-SHIRT&amp;lt;/SKU&amp;gt;
  &amp;lt;Quantity&amp;gt;2&amp;lt;/Quantity&amp;gt;
&amp;lt;/Item&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This is more readable than packing everything into attributes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch Your Encodings&lt;/strong&gt;&lt;br&gt;
Always declare your encoding at the top:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Convert XML to JSON for Modern Systems&lt;br&gt;
If your .NET or Node.js service receives XML from a legacy vendor, use conversion libraries to bridge the gap with your JSON-based APIs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🆚 JSON vs XML — Quick Thoughts
Feature JSON    XML
Readability Cleaner Verbose
Validation  Less strict (optional)  Strong with XSD
Data Format Lightweight Heavier
Tooling Modern APIs &amp;amp; UIs   Enterprise tools, SOAP
Use Case    Mobile, APIs, Kafka ERP, finance, SOAP systems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In modern logistics platforms, we often find both JSON and XML living side by side.&lt;/p&gt;

&lt;p&gt;Logistics tech in India — from Delhivery, BlueDart, DTDC, to Indian Railways freight, and even eInvoice systems under GST — often requires XML formats for backend integration.&lt;/p&gt;

&lt;p&gt;So even if you're building the latest microservice in .NET 8 or using Kafka, don’t be surprised if you have to consume an XML feed from a legacy SAP system.&lt;/p&gt;

&lt;p&gt;🧵 Wrapping Up&lt;br&gt;
If you're a backend or integration engineer working in logistics, XML isn't going anywhere just yet. It might not be trendy, but it’s stable, secure, and well-suited for B2B and enterprise workflows.&lt;/p&gt;

&lt;p&gt;When you receive XML data — say from a courier partner, ERP system, or customs gateway — how do you know it’s correct? That’s where XSD comes in.&lt;/p&gt;

&lt;p&gt;✅ XSD stands for XML Schema Definition.&lt;br&gt;
It acts like a contract that defines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What elements and attributes are allowed&lt;/li&gt;
&lt;li&gt;Data types (string, date, int, etc.)&lt;/li&gt;
&lt;li&gt;Required vs optional fields&lt;/li&gt;
&lt;li&gt;Structure, nesting, and cardinality&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📦 &lt;strong&gt;Example: Shipment XML&lt;/strong&gt;&lt;br&gt;
XML file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Shipment&amp;gt;
  &amp;lt;ShipmentId&amp;gt;SHIP-12345&amp;lt;/ShipmentId&amp;gt;
  &amp;lt;Status&amp;gt;Dispatched&amp;lt;/Status&amp;gt;
  &amp;lt;Weight&amp;gt;12.5&amp;lt;/Weight&amp;gt;
&amp;lt;/Shipment&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Corresponding XSD:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0"?&amp;gt;
&amp;lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&amp;gt;
  &amp;lt;xs:element name="Shipment"&amp;gt;
    &amp;lt;xs:complexType&amp;gt;
      &amp;lt;xs:sequence&amp;gt;
        &amp;lt;xs:element name="ShipmentId" type="xs:string"/&amp;gt;
        &amp;lt;xs:element name="Status" type="xs:string"/&amp;gt;
        &amp;lt;xs:element name="Weight" type="xs:decimal"/&amp;gt;
      &amp;lt;/xs:sequence&amp;gt;
    &amp;lt;/xs:complexType&amp;gt;
  &amp;lt;/xs:element&amp;gt;
&amp;lt;/xs:schema&amp;gt;

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

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;ShipmentId is a string ✅&lt;/li&gt;
&lt;li&gt;Weight must be a decimal ✅&lt;/li&gt;
&lt;li&gt;No extra or missing tags allowed ❌&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🛠 &lt;strong&gt;Why Use XSD in Logistics?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Validates XML structure before processing&lt;/li&gt;
&lt;li&gt;🚫 Prevents corrupt or incomplete shipment/invoice data&lt;/li&gt;
&lt;li&gt;🔐 Adds security by rejecting unexpected inputs&lt;/li&gt;
&lt;li&gt;🏗 Helps generate documentation and UI forms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In .NET, Java, or Python, you can easily load the XSD and validate incoming XML against it using built-in libraries.&lt;/p&gt;

&lt;p&gt;🔧 .NET Example (C#):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var schemaSet = new XmlSchemaSet();
schemaSet.Add("", "Shipment.xsd");

var settings = new XmlReaderSettings();
settings.Schemas = schemaSet;
settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler += (s, e) =&amp;gt;
{
    Console.WriteLine("Validation Error: " + e.Message);
};

using var reader = XmlReader.Create("Shipment.xml", settings);
while (reader.Read()) { }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🧵 &lt;strong&gt;Bottom Line:&lt;/strong&gt;&lt;br&gt;
Always ask your partners for an XSD when consuming XML.&lt;br&gt;
It’s the safety net that saves you from bad data and runtime bugs — especially in critical logistics pipelines.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>JSON: How JSON Powers Modern Logistics Systems — With Real-World Use Cases</title>
      <dc:creator>Rakesh Chaubey</dc:creator>
      <pubDate>Mon, 26 May 2025 09:09:09 +0000</pubDate>
      <link>https://dev.to/rakesh_chaubey_ac4fa25823/json-4dng</link>
      <guid>https://dev.to/rakesh_chaubey_ac4fa25823/json-4dng</guid>
      <description>&lt;p&gt;Hey everyone! 👋&lt;br&gt;
I'm Rakesh Chaubey, a backend developer from India with 13+ years of experience working in logistics tech. If you’ve ever built or maintained APIs, data pipelines, or microservices, you already know how crucial structured data is.&lt;/p&gt;

&lt;p&gt;In modern web development, JavaScript Object Notation (JSON) has become a go-to format for data interchange, especially in applications like logistics management. Its lightweight structure translates to efficient data handling between servers and clients.&lt;br&gt;
What is JSON?&lt;/p&gt;

&lt;p&gt;JSON is a text-based format that represents structured data using key/value pairs. Its simplicity and readability make it easy for both humans and machines to work with.&lt;/p&gt;

&lt;p&gt;One format that quietly powers most logistics platforms — from package tracking to warehouse sync — is JSON.&lt;/p&gt;

&lt;p&gt;In this post, I’ll walk through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What JSON really means in the context of logistics&lt;/li&gt;
&lt;li&gt;How it’s used behind the scenes in logistics platforms&lt;/li&gt;
&lt;li&gt;A real-world example from a shipment-tracking use case&lt;/li&gt;
&lt;li&gt;Why you should design and handle JSON carefully&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📦 &lt;strong&gt;Why JSON is a Big Deal in Logistics&lt;/strong&gt;&lt;br&gt;
Let’s imagine a courier service like Delhivery or India Post. Every time you send a parcel, the system needs to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store package details&lt;/li&gt;
&lt;li&gt;Share status with customers&lt;/li&gt;
&lt;li&gt;Update internal systems&lt;/li&gt;
&lt;li&gt;Integrate with third-party providers (e.g., Flipkart, Amazon)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these actions involves structured data exchange — and that’s where JSON becomes the de facto format.&lt;/p&gt;

&lt;p&gt;🔍 &lt;strong&gt;A Real JSON Payload From a Shipment System&lt;/strong&gt;&lt;br&gt;
Here’s a sample JSON response from a fictional logistics backend when you query for tracking info:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "shipmentId": "SHIP-98765",
  "origin": "Mumbai",
  "destination": "Hyderabad",
  "status": "Out for Delivery",
  "lastUpdated": "2025-05-26T07:30:00Z",
  "estimatedDelivery": "2025-05-26",
  "items": [
    {
      "sku": "BOOK-IND-001",
      "description": "Cracking the Coding Interview",
      "quantity": 1
    },
    {
      "sku": "T-SHIRT-L",
      "description": "Black Polo T-Shirt (Size L)",
      "quantity": 2
    }
  ],
  "events": [
    {
      "timestamp": "2025-05-24T13:40:00Z",
      "location": "Hub: Pune",
      "event": "Package arrived at hub"
    },
    {
      "timestamp": "2025-05-25T21:10:00Z",
      "location": "Delivery Center: Hyderabad",
      "event": "Out for delivery"
    }
  ]
}

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

&lt;/div&gt;



&lt;p&gt;Now imagine this JSON flowing through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Internal APIs&lt;/li&gt;
&lt;li&gt;Kafka event streams&lt;/li&gt;
&lt;li&gt;NoSQL document stores (like Cosmos DB or MongoDB)&lt;/li&gt;
&lt;li&gt;Mobile app and customer dashboards&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This structure is easy for machines and humans to work with, and flexible enough for new fields like insuranceAmount or fragileItem to be added without breaking downstream consumers.&lt;/p&gt;

&lt;p&gt;🧠 &lt;strong&gt;Why Developers Love JSON in Logistics&lt;/strong&gt;&lt;br&gt;
Feature Why It Helps in Logistics&lt;br&gt;
✅ Schema-less Great for evolving delivery systems — add new fields easily&lt;br&gt;
🌍 Language-agnostic  Works equally well in C#, Java, Node.js, Python, etc.&lt;br&gt;
⚡ Lightweight Perfect for mobile and low-latency APIs&lt;br&gt;
🧩 Integrates with everything APIs, Kafka, Cosmos DB, MongoDB, etc.&lt;br&gt;
🧪 Easy to test   JSON-based stubs and mocks simplify testing in microservices&lt;/p&gt;

&lt;p&gt;🧱 &lt;strong&gt;Best Practices When Working with JSON in Logistics&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Always Version Your APIs&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;GET /api/v1/shipments/SHIP-98765
Adding /v1/ helps when your logistics systems evolve and older clients are still using older formats.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use PascalCase or camelCase Consistently&lt;/strong&gt;&lt;br&gt;
Choose a naming convention and stick to it across services. In .NET, PascalCase is common, while in JavaScript or JSON payloads, camelCase is widely used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Include Metadata for Better Observability&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"sourceSystem": "OrderService",
"processedBy": "TrackingService",
"correlationId": "abc-123"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Metadata helps trace issues across distributed systems, especially in event-driven architectures.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Validate Your Payloads&lt;/strong&gt;
Always validate your incoming and outgoing JSON. Tools like FluentValidation in .NET or JSON Schema help avoid garbage data polluting downstream services.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;5.&lt;strong&gt;Secure It&lt;/strong&gt;&lt;br&gt;
Don’t expose internal structure or stack traces in error responses.&lt;/p&gt;

&lt;p&gt;Never log sensitive data like customer addresses or phone numbers without redaction.&lt;/p&gt;

</description>
      <category>json</category>
      <category>logistics</category>
      <category>webdev</category>
      <category>microservices</category>
    </item>
  </channel>
</rss>
