<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jaya Sandeep Ketha on Medium]]></title>
        <description><![CDATA[Stories by Jaya Sandeep Ketha on Medium]]></description>
        <link>https://medium.com/@kethajayasandeep1254?source=rss-6ff0c775091d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c7dyGXBtXksct_0Qgmaovw.jpeg</url>
            <title>Stories by Jaya Sandeep Ketha on Medium</title>
            <link>https://medium.com/@kethajayasandeep1254?source=rss-6ff0c775091d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:33:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kethajayasandeep1254/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I Got Hands-On Access to a Real InfiniBand HPC Environment with NVIDIA/Mellanox Networking]]></title>
            <link>https://medium.com/@kethajayasandeep1254/hands-on-infiniband-hpc-lab-nvidia-mellanox-a5d1c7e00cf4?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5d1c7e00cf4</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[nvidia]]></category>
            <category><![CDATA[infiniband]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Sun, 20 Sep 2026 00:41:23 GMT</pubDate>
            <atom:updated>2026-09-20T00:41:23.595Z</atom:updated>
            <content:encoded><![CDATA[<p>I wanted hands-on access to a real HPC environment, particularly to learn more about Linux-based HPC systems, high-speed networking, and InfiniBand without installing an unfamiliar remote-access client directly on my personal laptop.</p><p>That led me to <a href="https://www.sabalcore.com/">Sabalcore</a>.</p><p>Sabalcore provides bare-metal HPC cloud environments aimed at engineering, scientific, and tightly coupled workloads. Its infrastructure includes NVIDIA Quantum InfiniBand networking, which made it particularly interesting for this kind of hands-on exploration.</p><p>Instead of installing the Sabalcore Secure Client (ssClient) directly on my laptop, I decided to create a temporary Ubuntu machine in AWS and use that as an isolated workstation.</p><p>This article documents the <strong>entire process</strong>, including how I requested Sabalcore access, received the account information, created the AWS environment, installed the client, and handled the errors I encountered along the way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tuLxgi4lk7axeoSzao2low.png" /></figure><h3>Part 1 — Getting Access to Sabalcore</h3><h4>1. Finding Sabalcore</h4><p>I started from the official Sabalcore website.</p><p>One thing that also stood out was the emphasis on direct human support and onboarding rather than relying entirely on an automated cloud interface. Sabalcore says it provides onboarding assistance from HPC engineers.</p><h4>2. Requesting an Account</h4><p>From the Sabalcore website, I went through their <strong>sign-up process</strong>.</p><p>I filled out the registration/request form with the information they requested and submitted it.</p><p>Unlike creating an AWS or Azure account, I didn’t immediately receive a cloud console where I could start creating machines.</p><p>Instead, I waited for Sabalcore to process the request. Mine took around 2 days.</p><h4>3. Receiving the Sabalcore Email</h4><p>After submitting the form, I received an email from Sabalcore containing the information required to access their environment.</p><p>The email included things such as:</p><pre>Sabalcore account/login information<br>Connection instructions<br>Instructions for installing the Sabalcore Secure Client (ssClient)<br>Sabalcore server information<br>Support contact information</pre><p>I am intentionally not including my actual username, password, or account-specific information here.</p><p>The important part was that Sabalcore provided the onboarding instructions needed to establish the connection.</p><p>Their instructions required installing the <strong>Sabalcore Secure Client</strong>, or: ssClient</p><p>The Linux/macOS package I was given was version: ssclient 4.2.2.6</p><p>and the instructions specified <strong>Java 11</strong> for running the Linux/macOS client.</p><p>The basic workflow supplied by Sabalcore was:</p><pre>Download ssClient<br>       ↓<br>Install / extract ssClient<br>       ↓<br>Run the Java client<br>       ↓<br>Enter Sabalcore server<br>       ↓<br>login.sabalcore.com<br>       ↓<br>Accept host<br>       ↓<br>Authenticate<br>       ↓<br>Access Sabalcore resources</pre><p>At this point I could have installed the client directly on my laptop.</p><p>I chose not to.</p><h4>4. Why I Used AWS Instead of My Laptop</h4><p>ssClient is a remote-access application that establishes connectivity between my machine and the Sabalcore environment.</p><p>Even when software comes from a legitimate service, I generally prefer not to install additional remote-access software on my primary computer when I can easily isolate it.</p><p>So I decided to create a <strong>disposable Linux workstation in AWS</strong>.</p><p>The idea was simple:</p><pre>My Laptop<br>     |<br>     | RDP<br>     v<br>Temporary AWS EC2 Instance<br>     |<br>     | ssClient<br>     v<br>Sabalcore</pre><p>This gives me another isolation boundary.</p><p>My laptop doesn’t need:</p><pre>Java 11<br>Sabalcore ssClient<br>Sabalcore client libraries<br>Sabalcore host configuration</pre><p>Those components live inside the temporary EC2 instance instead.</p><p>This doesn’t prove that any software is safe. It simply limits what I install directly on my primary computer and gives me an environment I can destroy afterward.</p><h3>Part 2 — Building the Temporary AWS Workstation</h3><h4>5. Create the EC2 Instance</h4><p>From the AWS EC2 console, I selected:</p><pre>Launch instance</pre><p>I used approximately the following configuration:</p><pre>Name:<br>sabalcore-temp<br><br>Operating System:<br>Ubuntu Server 24.04 LTS<br><br>Architecture:<br>x86_64<br><br>Instance type:<br>t3.small<br><br>Storage:<br>15–20 GB gp3</pre><p>I had no issues running this setup on a t3.small, but if you encounter resource constraints, you can use a t3.medium instead.</p><p>I also created/downloaded an EC2 SSH key:</p><pre>sabalcore-temp.pem</pre><p>Initially, my security group allowed only:</p><pre>SSH<br>TCP 22<br>Source: My IP</pre><p>Then I launched the instance.</p><h4>6. Connect Through SSH</h4><p>Once the instance was running, I obtained its public IPv4 address.<br>On my local machine:</p><pre>chmod 400 sabalcore-temp.pem</pre><p>Then:</p><pre>ssh -i sabalcore-temp.pem ubuntu@&lt;EC2-PUBLIC-IP&gt;</pre><p>After connecting successfully, my prompt looked similar to:</p><pre>ubuntu@ip-172-31-xx-xxx:~$</pre><h4>7. Verify Ubuntu</h4><p>Before continuing, I checked the operating system:</p><pre>cat /etc/os-release</pre><p>My instance returned:</p><pre>PRETTY_NAME=&quot;Ubuntu 24.04.4 LTS&quot;<br>VERSION_ID=&quot;24.04&quot;<br>VERSION=&quot;24.04.4 LTS (Noble Numbat)&quot;<br>VERSION_CODENAME=noble</pre><p>So the environment used for this setup was:</p><p><strong>Ubuntu 24.04.4 LTS - Noble Numbat</strong></p><h4>8. Update APT</h4><p>I refreshed the package information:</p><pre>sudo apt update</pre><p>Optionally:</p><pre>sudo apt upgrade -y</pre><h3>Part 3 — Adding a Desktop to Ubuntu</h3><p>A standard Ubuntu EC2 server is normally headless.</p><p>That becomes important because Sabalcore’s ssClient isn’t simply a command-line SSH client. It presents a graphical interface and interactive prompts.</p><p>So I needed a desktop environment.</p><p>I chose <strong>XFCE</strong> because it’s considerably lighter than installing a complete GNOME desktop just for this purpose.</p><h4>9. Install XFCE</h4><p>Initially I tried:</p><pre>sudo apt install xfce4 xfce4-goodies -y</pre><p>And immediately hit my first problem.</p><h4>Error #1 — Unable to Locate XFCE</h4><p>The output was:</p><pre>E: Unable to locate package xfce4<br>E: Unable to locate package xfce4-goodies</pre><p>This wasn’t an XFCE problem.</p><p>APT couldn’t see the required packages through the currently available repositories/indexes.</p><p>I checked the configured repositories:</p><pre>grep -v &#39;^#&#39; /etc/apt/sources.list.d/ubuntu.sources</pre><p>XFCE is available through Ubuntu’s repositories, so I made sure universe was enabled.</p><pre>sudo add-apt-repository universe</pre><p>If add-apt-repository isn&#39;t available:</p><pre>sudo apt update<br>sudo apt install software-properties-common -y</pre><p>Then:</p><pre>sudo add-apt-repository universe</pre><p>I refreshed APT again:</p><pre>sudo apt clean<br>sudo apt update</pre><p>Then checked:</p><pre>apt-cache policy xfce4</pre><p>Once APT showed a valid candidate package, I ran:</p><pre>sudo apt install xfce4 xfce4-goodies -y</pre><p>If prompted for a display manager, I selected:</p><pre>lightdm</pre><h4>10. Install XRDP</h4><p>Now I needed a way to remotely access the XFCE desktop.</p><p>I installed XRDP:</p><pre>sudo apt install xrdp -y</pre><p>Then enabled it:</p><pre>sudo systemctl enable --now xrdp</pre><p>I checked:</p><pre>sudo systemctl status xrdp</pre><p>The important result was:</p><pre>Active: active (running)</pre><p>I pressed:</p><pre>q</pre><p>to exit the status screen.</p><h4>11. Configure XFCE for XRDP</h4><p>I configured the session:</p><pre>echo &quot;xfce4-session&quot; &gt; ~/.xsession</pre><p>Then restarted XRDP:</p><pre>sudo systemctl restart xrdp</pre><h4>12. Create a Temporary Desktop Password</h4><p>My normal EC2 SSH authentication used the .pem key.</p><p>XRDP, however, needed a Linux username/password.</p><p>So I created a temporary password:</p><pre>sudo passwd ubuntu</pre><p>My RDP credentials were therefore:</p><pre>Username: ubuntu<br>Password: &lt;temporary password&gt;</pre><p>I used a unique temporary password rather than reusing an existing password.</p><h4>13. Open RDP Securely</h4><p>In the EC2 security group I added:</p><pre>Type: RDP<br>Protocol: TCP<br>Port: 3389<br>Source: My IP</pre><p>So my important inbound rules looked approximately like:</p><pre>SSH     TCP 22       My IP<br>RDP     TCP 3389     My IP</pre><p>I specifically avoided:</p><pre>RDP 3389 -&gt; 0.0.0.0/0</pre><p>because there was no reason to expose the RDP service to the entire Internet.</p><h4>14. Connect to the Ubuntu Desktop</h4><p>From my local computer I used an RDP client and connected to:</p><pre>&lt;EC2 Public IPv4 Address&gt;</pre><p>At the XRDP screen:</p><pre>Session: Xorg<br>Username: ubuntu<br>Password: &lt;temporary password&gt;</pre><p>I now had a complete graphical Linux desktop running remotely inside AWS.</p><p>The architecture had become:</p><pre>Laptop<br>   |<br>   | RDP<br>   v<br>AWS EC2<br>   |<br>   +-- Ubuntu 24.04<br>   |<br>   +-- XFCE<br>   |<br>   +-- XRDP</pre><p>Now I could install Sabalcore without installing it locally.</p><h3>Part 4 — Installing Java and Sabalcore</h3><h4>15. Install Java 11</h4><p>The Sabalcore instructions specified Java 11.</p><p>I installed:</p><pre>sudo apt update<br>sudo apt install openjdk-11-jre -y</pre><p>Then verified:</p><pre>java -version</pre><p>The important thing was seeing Java major version:</p><pre>11</pre><h4>16. Download ssClient</h4><p>I created a dedicated directory:</p><pre>mkdir -p ~/sabalcore</pre><p>I then downloaded the Sabalcore Linux client archive provided through the onboarding instructions.</p><p>The expected filename was:</p><pre>ssclient_4.2.2.6-bin.zip</pre><p>I also made sure unzip was installed:</p><pre>sudo apt install unzip -y</pre><p>Ubuntu reported:</p><pre>unzip is already the newest version</pre><p>So I moved on to extraction.</p><h4>17. Extract ssClient</h4><p>Now extraction worked:</p><pre>unzip ssclient_4.2.2.6-bin.zip -d ~/sabalcore</pre><p>I moved into the directory:</p><pre>cd ~/sabalcore</pre><p>My next assumption caused the second problem.</p><h4>Error #2 — Unable to Access JAR File</h4><p>I tried:</p><pre>java -jar ssclient-4.2.2.6.jar</pre><p>Java responded:</p><pre>Error: Unable to access jarfile ssclient-4.2.2.6.jar</pre><p>At first this might look like a Java permissions problem.</p><p>It wasn’t.</p><p>I was simply in the wrong directory.</p><p>Instead of guessing where the application had been extracted, I searched for every JAR:</p><pre>find ~/sabalcore -type f -name &quot;*.jar&quot;</pre><p>That revealed the actual application:</p><pre>/home/ubuntu/sabalcore/ssclient-4.2.2.6/ssclient-4.2.2.6.jar</pre><p>There were also many dependency JARs:</p><pre>~/sabalcore/ssclient-4.2.2.6/lib/...</pre><p>Those weren’t the files I needed to launch manually.</p><p>The main application was:</p><pre>~/sabalcore/ssclient-4.2.2.6/ssclient-4.2.2.6.jar</pre><p>So the correct directory was:</p><pre>cd ~/sabalcore/ssclient-4.2.2.6</pre><p>I verified:</p><pre>ls -lh ssclient-4.2.2.6.jar</pre><h3>Part 5 — Running Sabalcore ssClient</h3><p>There is one very important detail here.</p><p>Because ssClient is graphical, I didn’t want to launch it from the ordinary SSH session.</p><p>Instead I:</p><pre>Connected to EC2 using RDP<br>        ↓<br>Opened Terminal inside XFCE<br>        ↓<br>Changed into the ssClient directory<br>        ↓<br>Started Java</pre><p>From the XFCE terminal:</p><pre>cd ~/sabalcore/ssclient-4.2.2.6</pre><p>Then:</p><pre>java -jar ssclient-4.2.2.6.jar</pre><p>This time the Sabalcore Secure Client launched successfully.</p><h4>18. Why Running It From SSH Can Be a Problem</h4><p>If a graphical Java application is launched from a normal SSH session without graphical forwarding, you may encounter errors such as:</p><pre>No X11 DISPLAY variable was set</pre><p>or:</p><pre>Can&#39;t connect to X11 window server</pre><p>That doesn’t necessarily indicate a Java or Sabalcore problem.</p><p>It means the process doesn’t have access to a graphical display.</p><p>Launching the command from a terminal inside the RDP/XFCE desktop avoids that problem.</p><h3>Part 6 — Connecting to Sabalcore</h3><p>Once the ssClient GUI appeared, I returned to the instructions Sabalcore had sent in the onboarding email.</p><p>I pressed:</p><pre>Enter</pre><p>to bring up the Sabalcore Server prompt.</p><p>The server alias was already populated as:</p><pre>login.sabalcore.com</pre><p>The instructions specifically said to leave the prefilled alias and simply press:</p><pre>Enter</pre><p>I then received prompts related to the SSH known-host configuration.</p><p>I approved creating the Known Hosts directory:</p><pre>Create Known Hosts directory?<br>→ Yes</pre><p>Then approved adding the Sabalcore host:</p><pre>Add host?<br>→ Yes</pre><p>I continued through the remaining prompts according to the onboarding instructions Sabalcore had sent with my account.</p><p>Their instructions also warned that the connection could time out, so once the client started connecting, I proceeded through the authentication steps without leaving the session idle.</p><h4>Verifying the Mellanox Hardware</h4><p>Getting connected was only part of what I wanted to accomplish. I also wanted to confirm that I had actually reached an HPC environment with the NVIDIA/Mellanox networking hardware I was looking for.</p><p>Once I was logged in, I ran:</p><pre>lspci | grep -i mellanox</pre><p>This searches the system’s PCI devices for hardware identified as Mellanox.</p><p>The command returned Mellanox devices on the system, confirming that the environment exposed NVIDIA/Mellanox networking hardware.</p><p>That was the point where the setup became useful for what I actually wanted to learn.</p><p>I wasn’t just connected to another Linux VM. I now had access to an HPC environment where I could start exploring the networking stack from the Linux side and work toward hands-on InfiniBand and RDMA practice.</p><p>From here, the next step is to go deeper:</p><pre>lspci | grep -i mellanox<br>ibv_devices<br>ibv_devinfo<br>ibstat</pre><p>These tools can help answer progressively more interesting questions: What Mellanox hardware is visible? What RDMA devices does Linux expose? What ports exist? Are they active? What link layer are they using?</p><p>That exploration deserves its own hands-on lab. For this article, seeing the Mellanox hardware was enough to confirm that the environment I had spent all this time setting up was finally giving me access to the kind of infrastructure I was looking for.</p><h3>Complete Connection Path</h3><p>At this point the complete environment looked like:</p><pre>┌───────────────────────┐<br>│ My Laptop             │<br>│                       │<br>│ RDP Client            │<br>└──────────┬────────────┘<br>           │<br>           │ RDP / 3389<br>           ▼<br>┌───────────────────────────────┐<br>│ AWS EC2                       │<br>│                               │<br>│ Ubuntu 24.04                  │<br>│      │                        │<br>│      ▼                        │<br>│ XFCE Desktop                  │<br>│      │                        │<br>│      ▼                        │<br>│ Java 11                       │<br>│      │                        │<br>│      ▼                        │<br>│ Sabalcore ssClient            │<br>└──────────────┬────────────────┘<br>               │<br>               │ Internet<br>               ▼<br>       login.sabalcore.com<br>               │<br>               ▼<br>       Sabalcore HPC Cloud<br>               │<br>               ▼<br>      HPC / InfiniBand Resources</pre><p>This was exactly what I wanted.</p><p>Instead of turning my personal laptop into the Sabalcore workstation, I had effectively created a <strong>temporary cloud workstation dedicated to Sabalcore access</strong>.</p><h3>Security Lessons From This Setup</h3><p>The AWS instance isn’t a magic security boundary, but this approach gives me much better control over what I install on my personal computer.</p><p>I followed a few simple rules:</p><ul><li>Used a dedicated temporary EC2 instance.</li><li>Restricted SSH to my IP.</li><li>Restricted RDP to my IP.</li><li>Used a temporary Linux password.</li><li>Didn’t copy unrelated personal files into the instance.</li><li>Didn’t publish or store Sabalcore credentials in my notes.</li><li>Used the Sabalcore-provided client.</li><li>Avoided exposing RDP to 0.0.0.0/0.</li><li>Planned to terminate the EC2 instance when I no longer needed it.</li></ul><p>The Sabalcore website itself also emphasizes human support as part of the service, so if something in the account or onboarding process is unclear, using the support contact supplied in the account email is preferable to guessing about credentials or account-specific settings. (<a href="https://www.sabalcore.com/">Sabalcore HPC Cloud</a>)</p><h3>Cleanup</h3><p>When I’m finished experimenting, I have two options.</p><p>If I want to return later:</p><pre>EC2<br>→ Instances<br>→ Instance state<br>→ Stop instance</pre><p>Stopping prevents the instance from continuing to consume normal compute hours, although associated resources such as EBS storage can still incur charges.</p><p>If I no longer need the environment:</p><pre>EC2<br>→ Instances<br>→ Instance state<br>→ Terminate instance</pre><p>Because this environment was intentionally designed to be disposable, termination is ultimately the cleanest option once the work is complete.</p><h3>Thanks for reading!</h3><p>If you made it this far, thank you for spending your time reading through my hands-on experience getting access to a real HPC environment with InfiniBand and NVIDIA/Mellanox networking.</p><p>This article isn’t part of a specific series, but it connects closely with the topics I’ve been exploring and writing about — <strong>InfiniBand, RDMA, NVIDIA networking, GPU infrastructure, and AI/HPC systems</strong>. My goal is to document not only the concepts, but also the practical side: getting access to real environments, running commands, breaking things, troubleshooting them, and understanding what is actually happening underneath.</p><p>If those topics interest you, <strong>check out my profile</strong> for my other articles and series, including my deeper dive into AI networking from the wire all the way to the GPU.</p><p>I’m learning and exploring this space more deeply as I write, so I’d genuinely love to hear from you.</p><p>If you found this useful, consider <strong>following me</strong>, and leave a <strong>comment with your thoughts, corrections, questions, or ideas for future hands-on labs</strong>. If you know of other accessible environments where engineers can practice with real InfiniBand/RDMA hardware, I’d especially love to hear about them.</p><p>Thanks again for reading — and happy experimenting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5d1c7e00cf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernet vs. InfiniBand: Why AI and HPC Networks Are Different]]></title>
            <link>https://medium.com/@kethajayasandeep1254/ethernet-vs-infiniband-ai-hpc-networking-c8a219aca557?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8a219aca557</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[nvidia]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 10:17:31 GMT</pubDate>
            <atom:updated>2026-09-15T10:17:31.547Z</atom:updated>
            <content:encoded><![CDATA[<p><em>AI Networking from the Wire to the GPU - Part 2</em></p><p>In <a href="https://medium.com/@kethajayasandeep1254/nvidia-infiniband-rdma-ai-hpc-networking-explained-8f291c8724c6">Part 1</a>, we arrived at an interesting problem.</p><p>We can build incredibly powerful GPU servers. But once computation is distributed across multiple machines, those machines need to communicate. If that communication is slow or inefficient, expensive GPUs can end up waiting instead of computing.</p><p>That naturally leads to a question:</p><blockquote><strong><em>We already have Ethernet and TCP/IP. They connect practically the entire world. Why do AI and HPC systems need something different?</em></strong></blockquote><p>Is InfiniBand simply <strong>faster Ethernet</strong>? Not really.</p><p>The more interesting difference is <strong>how the two approaches were designed to move data between computers</strong>.</p><p>Let’s follow the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R_9hNse8JYZWDIcIdFN5zA.png" /></figure><h3>What happens when two normal applications communicate?</h3><p>Suppose an application on Server A wants to send some data to an application on Server B.</p><p>From the application’s perspective, it looks wonderfully simple:</p><pre>+-------------+                         +-------------+<br>|  Server A   |                         |  Server B   |<br>|             |                         |             |<br>| Application | -------- DATA --------&gt; | Application |<br>+-------------+                         +-------------+</pre><p>But that arrow hides quite a bit.</p><p>A simplified traditional networking path looks more like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F1raJyR_PowRMkBZAA53Ow.png" /></figure><p>Your application doesn’t directly control the cable or tell the NIC exactly how every bit should travel.</p><p>Instead, it relies on the operating system and networking stack.</p><p>And that’s a very good thing.</p><h3>Think of the OS as a shipping department</h3><p>Imagine you work in an office and need to send a package to another company.</p><p>Do you stop working, find a truck, determine the route, drive to the destination and deliver it yourself?</p><p>Of course not.</p><p>You hand the package to the shipping department.</p><p>They deal with the transportation details while you focus on your job.</p><p>Traditional application networking follows a similar idea.</p><p>The application says, essentially:</p><blockquote><em>“I need to send this data.”</em></blockquote><p>The networking stack handles much of the complexity underneath.</p><p>That abstraction helped make TCP/IP and Ethernet enormously successful.</p><p>So what’s the problem?</p><p>There isn’t one <strong>until the cost of communication becomes critical to the workload.</strong></p><p>Remember our AI cluster from Part 1. GPUs may repeatedly compute, exchange information, synchronize, and compute again.</p><p>Now we care not only about whether the data arrives.</p><p>We also care about:</p><blockquote><strong><em>How much work did the system have to perform just to move it?</em></strong></blockquote><h3>The CPU has better things to do</h3><p>Let’s extend our shipping analogy.</p><p>Imagine your company ships a package every few days.</p><p>Having employees interact with the shipping department isn’t a concern.</p><p>Now imagine shipping enormous amounts of material <strong>thousands of times per second</strong>.</p><p>Suddenly, every step in the process matters.</p><p>The same idea applies to high-performance computing.</p><p>In a traditional networking model, the CPU and operating system participate in networking operations.</p><p>Conceptually:</p><pre>CPU<br> |<br> +---- Application Work<br> |<br> +---- Network Processing<br> |<br> +---- Application Work<br> |<br> +---- Network Processing</pre><p>But in an AI or HPC server, we’d rather let the CPU spend as much time as possible doing useful application work.</p><p>What if specialized networking hardware could handle more of the communication itself?</p><pre>CPU ------------------&gt; Compute<br>Networking Hardware --&gt; Data Movement</pre><p>Interesting. Keep that idea in mind. We’re going to come back to it when we eventually introduce <strong>RDMA</strong>.</p><h3>Moving data can itself become work</h3><p>There’s another cost that’s easy to overlook: <strong>copying data</strong>.<br>Imagine you have a huge box that needs to reach another building.<br>Would you rather do this?</p><pre>Original Box<br>     |<br>     v<br> Temporary Box<br>     |<br>     v<br> Another Box<br>     |<br>     v<br> Delivery Truck</pre><p>Or:</p><pre>Original Box<br>     |<br>     +-------------&gt; Delivery</pre><p>Every unnecessary copy requires work.<br>Computers have the same problem.</p><p>A traditional networking path can involve data moving between application memory, operating-system-managed buffers and networking hardware.</p><p>Modern operating systems and NICs contain many optimizations and offloads, so don’t interpret this as <em>“TCP always makes X copies.”</em> That’s not the point.</p><p>The important question is:</p><blockquote><strong><em>Can we design a communication model that avoids unnecessary data movement and reduces CPU involvement?</em></strong></blockquote><p>For a web request, a tiny amount of extra overhead may barely matter.</p><p>For machines exchanging enormous amounts of data while tightly synchronizing expensive compute resources?</p><p>It matters much more.</p><h3>This is where the design philosophies separate</h3><p>Now we’re finally getting closer to InfiniBand.<br>The distinction is not:</p><pre>Ethernet = Slow<br>InfiniBand = Fast</pre><p>That would be misleading.</p><p>Modern Ethernet can be extremely fast and is widely used in data centers and AI infrastructure.</p><p>Instead, think about <strong>design priorities</strong>.</p><p>Traditional TCP/IP networking gives us a powerful, general-purpose communication model. Applications commonly communicate through sockets, while the operating system networking stack provides services such as TCP’s reliable delivery.</p><p>InfiniBand was designed as a <strong>high-performance fabric</strong>, with an architecture built around efficient communication between computing systems.</p><p>For now, the important thing is simply recognizing that InfiniBand isn’t just Ethernet with a bigger speed number.</p><p>It represents a different architecture optimized for high-performance communication.</p><h3>Where does RDMA fit?</h3><p>You’ll often see <strong>InfiniBand</strong> and <strong>RDMA</strong> mentioned together, which can make them sound like the same thing.</p><p>They aren’t.</p><p>RDMA stands for <strong>Remote Direct Memory Access</strong>.</p><p>We aren’t going deep into RDMA yet, but here’s the mental model I want you to carry forward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ygr7X666xvzMqJccENJYA.png" /></figure><p>The goal is to allow data movement with <strong>far less involvement from the traditional operating-system networking path</strong>.</p><p>RDMA plays key role in reducing CPU involvement and copies while allowing more direct memory-to-memory data movement between systems.</p><p>There’s a lot hiding behind that tiny diagram.</p><blockquote><strong>How can hardware access application memory safely?<br>How does it know which remote memory it’s allowed to access?<br>How does an application tell the hardware what operation to perform?</strong></blockquote><p>Those questions will eventually lead us to <strong>memory registration, protection keys, Queue Pairs, Work Requests and Completion Queues</strong>.</p><p>But not yet. One concept at a time.</p><p>And one important distinction before moving on:</p><blockquote><strong><em>RDMA is a data-movement capability. InfiniBand is a networking architecture that natively supports RDMA.</em></strong></blockquote><p>Later we’ll see that RDMA can also operate over Ethernet through technologies such as RoCE.</p><p>So this isn’t going to become an <em>Ethernet bad, InfiniBand good</em> series.</p><p>We’re going to understand the architectures well enough to know <strong>why and where each is used</strong>.</p><h3>Now let’s make InfiniBand real</h3><p>So far, InfiniBand is still an abstract cloud between two computers.</p><p>That’s about to change.</p><p>If I handed you two servers and said:</p><blockquote><strong><em>“Connect these machines using InfiniBand.”</em></strong></blockquote><blockquote>What would you actually need?<br>Where does the InfiniBand cable plug in?<br>Do we use a NIC?<br>What exactly is an <strong>HCA</strong>?<br>Where does <strong>NVIDIA ConnectX</strong> fit?<br>Do two servers connect directly, or do we need a switch?<br>And what does the complete physical path look like from one CPU to another?</blockquote><p>Something like this is waiting for us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b6w-mvY8UKhReWhbbI2YCQ.png" /></figure><p>In <strong>Part 3</strong>, we’re going to build this fabric from the ground up.</p><p>No RDMA internals yet.</p><p>First, let’s meet the actual hardware.</p><p><strong>Next: Part 3 — InfiniBand Architecture Explained: Building a Fabric from Servers, HCAs, Switches and Cables</strong></p><h3>Thanks for reading!</h3><p>If you made it this far, thank you for spending your time with the first article in this series.</p><p>My goal with <strong>AI Networking from the Wire to the GPU</strong> is to build a practical, beginner-friendly path into InfiniBand, RDMA, and NVIDIA networking — starting with <em>why</em> these technologies exist and gradually working our way toward how real AI/HPC infrastructure is designed, operated, and troubleshot.</p><p>I’m learning and exploring this space deeply as I write, so I’d genuinely love to hear from you.</p><p>If you found this useful, <strong>follow me</strong> to continue the series. And please leave a <strong>comment with your thoughts, corrections, questions, or ideas for topics you’d like me to cover</strong>. Discussions and feedback not only make the series better — they also keep me motivated to continue building it.</p><p><strong>Thank you for reading, and I’ll see you in Part 3!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8a219aca557" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why AI and HPC Need High-Speed Networking: Before Learning InfiniBand]]></title>
            <link>https://medium.com/@kethajayasandeep1254/nvidia-infiniband-rdma-ai-hpc-networking-explained-8f291c8724c6?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f291c8724c6</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[nvidia]]></category>
            <category><![CDATA[infiniband]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Sun, 13 Sep 2026 01:27:31 GMT</pubDate>
            <atom:updated>2026-09-13T01:27:31.525Z</atom:updated>
            <content:encoded><![CDATA[<p><em>AI Networking from the Wire to the GPU - Part 1</em></p><p>If you have been learning about AI infrastructure, you have probably heard some of these terms:<br><strong><em>InfiniBand. RDMA. RoCE. ConnectX. NVLink. NVSwitch. GPUDirect. NCCL. BlueField. Quantum.</em></strong></p><p>And if you are new to this space, they can quickly turn into alphabet soup.</p><p>You search for <em>“What is InfiniBand?”</em> and get told that it is a high-speed, low-latency interconnect used in HPC and AI.</p><p>Okay.</p><p>But <strong>why do we need it?</strong></p><p>Ethernet already exists. TCP/IP runs practically the entire Internet. Modern Ethernet links can deliver hundreds of gigabits per second.</p><p>So why did the HPC world build something different? Why are networking technologies such a big deal in modern AI clusters? And why does NVIDIA, a company most people associate with GPUs, have an entire networking ecosystem around technologies such as ConnectX, Quantum, BlueField, and Spectrum?</p><p>Before we answer any of those questions, we need to understand the problem they are trying to solve.</p><p>And that is exactly where I want to start this series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d933S8zb1p33ZyFFkaV7qA.png" /></figure><h3>What I want to do with this series</h3><p>I don’t want this to be a series where I throw definitions at you.</p><blockquote><em>InfiniBand is this.<br>RDMA is that.<br>Queue Pair means this.<br>Run this command.<br>Congratulations, next topic.</em></blockquote><p>You can find definitions anywhere.<br>My goal is to build the whole thing <strong>from the ground up</strong>.</p><p>We are eventually going to go quite deep: InfiniBand hardware, HCAs, switches, port states, Subnet Managers, LIDs and GIDs, RDMA, memory registration, Queue Pairs, verbs, packet structure, flow control, Virtual Lanes, routing, NVIDIA’s networking stack, GPUDirect RDMA, NCCL, performance testing, troubleshooting, and finally the design of actual AI/HPC fabrics.</p><p>But I want every new concept to answer a question created by the previous one.<br>By the end, when you see something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dZPBD-CEDcJgYqmHWKPhSg.png" /></figure><p>I don’t want it to look like a stack of mysterious technologies.<br>I want you to understand <strong>why every box exists and what the data is actually doing there</strong>.</p><p>So we’re going to start with none of them.<br>Let’s start with a computer.</p><h3>One computer is easy</h3><p>Imagine you have an application running on a server.</p><p>At a ridiculously simplified level, we could draw the system like this:</p><pre>              +------------------+<br>              |   Application    |<br>              +---------+--------+<br>                        |<br>                        v<br>              +------------------+<br>              |       CPU        |<br>              +------------------+<br>                        |<br>                        v<br>              +------------------+<br>              |      Memory      |<br>              +------------------+</pre><p>The application needs some computation. The CPU performs it. Data is stored in memory.</p><p>Of course, a real computer is vastly more complicated, but this model is enough for now.</p><p>Then our workloads get bigger.</p><p>We might add GPUs:</p><pre>              +------------------+<br>              |   Application    |<br>              +---------+--------+<br>                        |<br>                  +-----+-----+<br>                  |           |<br>                  v           v<br>                CPU          GPU<br>                  \           /<br>                   \         /<br>                    +-------+<br>                       |<br>                     Memory</pre><p>Now we have significantly more compute capability. Great.<br>But what happens when the problem becomes too large for one server?<br>Maybe we need more memory.<br>Maybe one GPU isn’t enough.<br>Maybe eight GPUs aren’t enough.<br>Maybe finishing the workload on one machine would simply take too long.<br>This is where things become interesting.<br>We add another machine.</p><h3>The moment you add another server, everything changes</h3><p>Now our system looks something like this:</p><pre>+----------------------+            +----------------------+<br>|       Server A       |            |       Server B       |<br>|                      |            |                      |<br>|    CPU      GPU      |            |    CPU      GPU      |<br>|     |        |       |            |     |        |       |<br>|     +--Memory--+     |            |     +--Memory--+     |<br>+----------+-----------+            +----------+-----------+<br>           |                                   |<br>           +------------- NETWORK -------------+</pre><p>We have doubled our compute resources. But we have also created a new problem.</p><p><strong>Server A and Server B are physically separate computers.</strong></p><p>Server A cannot simply reach into Server B’s memory as though it were its own.</p><p>If the two machines are working on different parts of the same problem, somehow information has to move between them. <br>And what sits between them?</p><p>The network.</p><p>This leads to one of the most important ideas I want you to remember throughout this series:</p><blockquote><strong><em>Once computation is distributed across machines, the network becomes part of the computer.</em></strong></blockquote><p>Not literally, of course. But from the workload’s perspective, it might as well be.</p><p>The material that motivated this series makes the same connection: distributed workloads run across multiple machines and therefore depend on fast node-to-node communication.</p><p>And modern AI takes this problem to another level.</p><h3>Now imagine 1,000 GPUs</h3><p>When we hear about an AI model being trained on thousands of GPUs, it’s tempting to imagine something like this:</p><blockquote><em>Give every GPU some work.<br>Let them calculate independently.<br>Combine everything at the end.</em></blockquote><p>If only it were that simple.</p><p>The GPUs frequently need to communicate.</p><p>Depending on how a workload is distributed, GPUs may need to exchange intermediate results, synchronize information, move tensors, aggregate gradients, distribute parameters, or coordinate different pieces of the model.</p><p>You don’t need to understand any of those mechanisms yet.<br>We’ll get there.</p><p>For now, imagine four workers solving one large problem.</p><pre>       Worker 1        Worker 2<br>           \              /<br>            \            /<br>             \          /<br>              COORDINATE<br>             /          \<br>            /            \<br>       Worker 3        Worker 4</pre><p>If they could work completely independently for eight hours and exchange answers once at the end, communication wouldn’t be particularly difficult.</p><p>But suppose they have to exchange results every few seconds before continuing.</p><p>Suddenly, communication matters a lot.</p><p>That’s closer to the problem we’re dealing with.</p><p>Your GPU can be incredibly fast, but if its next computation depends on information coming from another GPU, it may have to wait for that information.</p><p>This frequent synchronization between GPUs and nodes is one of the major networking demands of AI/ML workloads.</p><p>This is also why I don’t particularly like thinking about AI infrastructure as simply:</p><pre>Faster GPU = Faster AI</pre><p>The real picture is closer to:</p><pre>                 +-------------+<br>                 |   Compute   |<br>                 +------+------+<br>                        |<br>          +-------------+-------------+<br>          |             |             |<br>          v             v             v<br>       Memory        Storage       Network<br>          \             |             /<br>           \            |            /<br>            +-----------+-----------+<br>                        |<br>                        v<br>                Workload Performance</pre><p>Every component feeds the others.</p><p>Imagine owning a sports car capable of 200 mph but driving it through traffic where the average speed is 25 mph.</p><p>The engine isn’t the problem.</p><p>The environment around the engine prevents you from using its capability.</p><p>A high-performance GPU can face a similar problem.</p><p>So when people design large AI and HPC systems, they aren’t only asking:</p><blockquote><strong><em>How fast can my GPUs calculate?</em></strong></blockquote><p>They also have to ask:</p><blockquote><strong><em>How quickly can I feed those GPUs?</em></strong></blockquote><p>and:</p><blockquote><strong><em>How quickly can those GPUs exchange data with one another?</em></strong></blockquote><p>To answer that, we need two concepts. <strong>Bandwidth and latency.<br></strong>They sound similar.</p><h3>Bandwidth: How much can I move?</h3><p>Let’s build a highway with one lane.</p><p>Now let’s build eight lanes.</p><p>Which road can transport more cars during the same period?</p><p>Obviously the second.</p><p>That’s a useful way to think about <strong>bandwidth</strong>.</p><p>Bandwidth tells us how much data a communication link can theoretically transport over a period of time.</p><p>You will encounter numbers such as:</p><pre>10 Gb/s<br>25 Gb/s<br>100 Gb/s<br>200 Gb/s<br>400 Gb/s<br>800 Gb/s</pre><p>Gb/s means <strong>gigabits per second</strong>.</p><p>Don’t worry about specific InfiniBand speeds or generations yet. We’ll devote an entire article to the physical side of the fabric later.</p><p>For now, think:</p><blockquote><strong><em>Bandwidth = How wide is my data highway?</em></strong></blockquote><p>But there’s a trap here.</p><p>Suppose I build you a 50-lane highway.</p><p>Amazing bandwidth.</p><p>Unfortunately, the highway starts 200 miles away from your house.</p><p>You want to send one tiny package to your neighbor.</p><p>Is the 50-lane highway automatically fast for that task?</p><p>Not necessarily.</p><p>That brings us to latency.</p><h3>Latency: How long do I wait?</h3><p>Suppose Server A needs to send a small piece of information to Server B.</p><pre>Server A                              Server B<br>   |                                     |<br>   | ----------- information ----------&gt; |<br>   |                                     |</pre><p>Latency is concerned with the <strong>delay involved in that communication</strong>.</p><p>In computing we may talk about:</p><pre>milliseconds   = 10⁻³ seconds<br>microseconds   = 10⁻⁶ seconds<br>nanoseconds    = 10⁻⁹ seconds</pre><p>At human scale, microseconds sound absurdly small.</p><p>Who cares about a few microseconds?</p><p>Computers do.</p><p>Especially when the operation doesn’t happen once.</p><p>Imagine paying a tiny communication penalty millions of times.</p><p>Small delays accumulate.</p><p>And in tightly synchronized workloads, one participant may be waiting for another.</p><p>This is why some high-performance applications care deeply about latency.</p><p>So now we have two different questions:</p><pre>Bandwidth:<br>How MUCH data can I move?<br>Latency:<br>How LONG does communication take?</pre><p>And AI/HPC often wants both:</p><pre>            AI / HPC Network<br>                    |<br>             +------+------+<br>             |             |<br>             v             v<br>       High Bandwidth   Low Latency</pre><h3>“But if I have huge bandwidth, why should I care about latency?”</h3><p>Great question.</p><p>Imagine I operate two delivery companies.</p><p><strong>Company A</strong> owns 100 trucks. Once everything starts moving, it can transport an enormous amount of cargo.</p><p>But every order takes 30 minutes before the first truck leaves.</p><p><strong>Company B</strong> also has 100 trucks, but dispatch happens almost immediately.</p><p>If you’re moving an entire warehouse, both companies may spend most of their time transporting cargo.</p><p>But what if you need to send thousands of tiny, time-sensitive packages throughout the day?</p><p>That dispatch delay suddenly matters a lot.</p><p>Networking has a similar distinction.</p><p>For a huge continuous transfer: bandwidth becomes extremely important.</p><p>For frequent small communications: latency can become extremely important.</p><p>AI/HPC workloads can involve both.</p><p>They may move enormous amounts of data <strong>and</strong> communicate frequently.</p><p>That’s why simply advertising a large bandwidth number doesn’t tell us everything about how a network will behave for a workload.</p><p>Later in this series, when we actually benchmark RDMA, we’ll revisit this distinction. You’ll see why performance tests often measure <strong>bandwidth and latency separately</strong>, and why message size matters.</p><p>But we need another piece of the puzzle first.</p><h3>What does a distributed workload actually feel like?</h3><p>Forget the details of AI training for a moment.</p><p>Imagine a workload doing this:</p><pre>          COMPUTE<br>             |<br>             v<br>        COMMUNICATE<br>             |<br>             v<br>          COMPUTE<br>             |<br>             v<br>        COMMUNICATE<br>             |<br>             v<br>          COMPUTE</pre><p>If communication is quick:</p><pre>COMPUTE      ███████████████<br>NETWORK                     ██<br>COMPUTE                       ███████████████<br>NETWORK                                      ██<br>COMPUTE                                        ███████████████</pre><p>Most of our time is spent doing useful computation.</p><p>Now imagine the network is slow:</p><pre>COMPUTE      ███████████████<br>WAIT                        ████████████████████<br>COMPUTE                                         ███████████████<br>WAIT                                                            ████████████████████</pre><p>The GPUs didn’t suddenly become slower.</p><p>They’re still capable of exactly the same computation.</p><p>But the <strong>system</strong> became slower.</p><p>That’s the difference between component performance and system performance.</p><p>And it leads to an interesting consequence.</p><p>As compute becomes faster, networking can actually become <strong>more important</strong>, not less.</p><p>If cooking takes 10 minutes and delivery takes 30 seconds, delivery isn’t a huge concern.</p><p>Improve cooking to 30 seconds while delivery remains 30 seconds, and suddenly half the workflow is communication.</p><p>So improving one part of a system can expose bottlenecks somewhere else.</p><p>That is classic systems engineering.</p><h3>The network is now on the critical path</h3><p>Let’s simplify our workload to:</p><pre>GPU COMPUTE<br>     |<br>     v<br>COMMUNICATION<br>     |<br>     v<br>GPU COMPUTE<br>     |<br>     v<br>COMMUNICATION<br>     |<br>     v<br>GPU COMPUTE</pre><p>If the second compute stage cannot begin until communication finishes, then network time is part of the application’s <strong>critical path</strong>.</p><p>A rough mental model might be:</p><pre>Total Workload Time<br>        ≈<br>Compute Time<br>    +<br>Communication Time<br>    +<br>Data Movement / Storage Time<br>    +<br>Synchronization &amp; Software Overhead</pre><p>This isn’t intended as a universal performance equation.</p><p>It’s a way to change how we think.</p><p>A cluster isn’t fast because one component is fast.</p><p><strong>A cluster is fast when the components can work together efficiently.</strong></p><p>And now we’ve reached the question that eventually leads us to InfiniBand.</p><h3>Wait… don’t we already have Ethernet?</h3><p>Exactly.</p><p>We already have an extraordinarily successful networking technology.</p><p>Ethernet.</p><p>It connects servers, workstations, datacenters, switches, routers, storage systems, cloud infrastructure and an enormous portion of the technology around us.</p><p>And TCP/IP has proven that it can scale to something much larger than an AI cluster:</p><p><strong>the Internet.</strong></p><p>So if our problem is:</p><blockquote><em>“Server A needs to communicate with Server B”</em></blockquote><p>why can’t we simply do what computers have been doing for decades?</p><pre>Application<br>    |<br>    v<br> Operating System<br>    |<br>    v<br> TCP/IP<br>    |<br>    v<br>   NIC<br>    |<br>    v<br> Ethernet<br>    |<br>    v<br> Network</pre><p>We absolutely can.</p><p>And we do.</p><p>But here’s where things get interesting.</p><p>The Internet and an HPC/AI compute fabric were built around very different problems.</p><p>Think about what we care about in a tightly coupled compute cluster:</p><p><strong>How much CPU work is required to move data?<br>How many times does that data get copied?<br>Does the operating system need to participate in every communication?<br>What happens when network buffers fill?<br>Who guarantees reliable delivery?<br>How is congestion handled?<br>How quickly can one machine access data associated with another?</strong></p><p>Suddenly, “How many gigabits per second?” is only one piece of the problem.</p><p>And this is where the architecture becomes fascinating.</p><p>The material we’ll build from later contrasts traditional TCP/IP and InfiniBand across exactly these dimensions: sockets versus Queue Pairs, software versus hardware-assisted reliability, copy-based versus zero-copy data movement, different approaches to flow control, and different approaches to fabric routing and management.</p><p>But I’m deliberately <strong>not explaining any of those yet</strong>.</p><p>Because if I tell you that InfiniBand uses Queue Pairs and RDMA before we’ve understood the problem they solve, they’re just terms to memorize.</p><p>I don’t want you memorizing them.</p><p>I want them to feel inevitable when we reach them.</p><p>For much of this series, we’re going to keep asking the same deceptively simple question:</p><blockquote><strong><em>How can we move data through this path with as little delay, CPU involvement and unnecessary work as possible?</em></strong></blockquote><p>We’ll gradually replace those generic boxes with real technologies.</p><p>Eventually, our picture will look more like:</p><pre>              AI Application<br>                    |<br>                    v<br>                  NCCL<br>                    |<br>                    v<br>               GPU Memory<br>                    |<br>                    v<br>            GPUDirect RDMA<br>                    |<br>                    v<br>             ConnectX HCA<br>                    |<br>                    v<br>              InfiniBand<br>                    |<br>                    v<br>             Quantum Switch<br>                    |<br>                    v<br>          Remote ConnectX HCA<br>                    |<br>                    v<br>          Remote GPU Memory</pre><p>Right now, most of those words may mean nothing to you.</p><p>That’s fine.</p><p>By the end of this series, they won’t.</p><p>More importantly, you should be able to look at that path and reason about it:</p><p><strong>Where is the bottleneck?<br>Which component owns this operation?<br>Why is this link down?<br>Why isn’t this port ACTIVE?<br>Why is RDMA bandwidth below expectation?<br>Why are the GPUs communicating through an inefficient path?<br>Why isn’t a cluster achieving the performance its hardware suggests it should?</strong></p><p>That’s the level I want this series to reach.</p><p>Not just <em>“What is InfiniBand?”</em></p><p>But:</p><blockquote><strong><em>How does the whole thing actually work?</em></strong></blockquote><h3>Where do we go next?</h3><p>We started with a simple computer.<br>Then we added another computer.<br>That forced us to communicate.<br>We scaled to many GPUs, and communication became part of our workload.<br>That introduced bandwidth.<br>Then latency.<br>Then synchronization.<br>Then the realization that the network itself can sit on the critical path of distributed computation.</p><p>And finally we arrived at a very reasonable question:</p><blockquote><strong><em>If Ethernet and TCP/IP already connect the world, what exactly needed to change for high-performance computing?</em></strong></blockquote><p>That’s where Part 2 begins.</p><p>In the next article, we’re going to follow a piece of data through a conventional network.</p><p>Not conceptually.</p><p><strong>Step by step.</strong></p><pre>Application Memory<br>       |<br>       v<br>     Socket<br>       |<br>       v<br>     Kernel<br>       |<br>       v<br>     TCP/IP<br>       |<br>       v<br>   NIC Driver<br>       |<br>       v<br>      NIC<br>       |<br>       v<br>    Network<br>       |<br>       v<br> Remote Machine</pre><p>We’ll look at what the CPU is doing, where the operating system gets involved, where data moves, why copies matter, how reliability works, and what “network overhead” actually means.</p><p>Then we’ll finally be in a position to ask:</p><p><strong>What would we design differently if our priority wasn’t connecting billions of general-purpose devices, but connecting extremely powerful computers that need to exchange data as quickly and efficiently as possible?</strong></p><p>And from that question, <strong>InfiniBand starts to make sense.</strong></p><p><strong>Next: Part 2 - Ethernet/TCP/IP vs. InfiniBand: Why High-Performance Computing Took a Different Path</strong></p><h3>Thanks for reading!</h3><p>If you made it this far, thank you for spending your time with the first article in this series.</p><p>My goal with <strong>AI Networking from the Wire to the GPU</strong> is to build a practical, beginner-friendly path into InfiniBand, RDMA, and NVIDIA networking - starting with <em>why</em> these technologies exist and gradually working our way toward how real AI/HPC infrastructure is designed, operated, and troubleshot.</p><p>I’m learning and exploring this space deeply as I write, so I’d genuinely love to hear from you.</p><p>If you found this useful, <strong>follow me</strong> to continue the series. And please leave a <strong>comment with your thoughts, corrections, questions, or ideas for topics you’d like me to cover</strong>. Discussions and feedback not only make the series better - they also keep me motivated to continue building it.</p><p><strong>Thank you for reading, and I’ll see you in Part 2!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f291c8724c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Linux Systems Programming: From Basics to Advanced]]></title>
            <link>https://medium.com/@kethajayasandeep1254/mastering-linux-systems-programming-from-basics-to-advanced-0006ff787c1c?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/0006ff787c1c</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Fri, 08 Aug 2025 23:45:03 GMT</pubDate>
            <atom:updated>2025-08-08T23:45:03.453Z</atom:updated>
            <content:encoded><![CDATA[<p><em>From “Hello, World!” to advanced system-level mastery — with hands-on C/Python programming.</em></p><h4>Why This Series?</h4><p>If you’ve ever wondered how applications actually talk to the operating system, how processes are created, how files are read and written at the lowest level, or how multiple programs communicate with each other : you’re in the right place.</p><p><strong>Linux Systems Programming</strong> is about working <em>close to the metal</em> — writing C/Python programs that directly interact with the Linux kernel through system calls, managing processes, handling signals, sharing memory, and more.</p><p>This series will take you <strong>from absolute beginner to confident practitioner</strong>, with no prior systems programming experience needed. We’ll keep explanations simple, but code-focused, so you can <em>see</em> how things work in real life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DO4vH_q5FW1G0TgUe75mnQ.png" /></figure><h4>What We’ll Cover</h4><p>Here’s the roadmap we’ll follow — from basics to advanced:</p><h4>1. Getting Started</h4><ul><li>What is <strong>Linux Systems Programming</strong>?</li><li>Difference between <strong>System Calls</strong> &amp; <strong>Library Functions</strong></li><li>Your first C program on Linux</li><li>Compiling with <strong>GNU-GCC</strong></li><li>Understanding the <strong>man pages</strong> (manual pages)</li><li>How Linux executes your program</li></ul><h4>2. File Operations</h4><ul><li>Opening, reading, writing, and closing files using system calls</li><li>Understanding <strong>file descriptors</strong></li><li>Blocking vs. Non-blocking I/O</li><li>Atomic operations (and why they matter)</li><li>Race conditions (and how to avoid them)</li></ul><h4>3. User Mode &amp; Kernel Mode</h4><ul><li>How the CPU switches between modes</li><li>Why programs don’t run in kernel mode directly</li><li>Understanding <strong>privilege levels</strong> in Linux</li></ul><h4>4. Process Management</h4><ul><li>What is a <strong>process</strong>?</li><li>Creating processes with <strong>fork()</strong></li><li>Parent vs. child process relationships</li><li>Command-line arguments in main()</li><li>Memory layout of a process (Code, Data, Heap, Stack)</li><li>How processes terminate</li></ul><h4>5. Signals</h4><ul><li>What are <strong>signals</strong> in Linux?</li><li>Default signal actions</li><li>Writing your own <strong>signal handlers</strong></li><li>Sending signals to processes</li></ul><h4>6. Memory Management</h4><ul><li>Virtual memory in Linux</li><li>Code, data, stack, and heap segments</li><li>How processes manage their own memory</li></ul><h4>7. POSIX Threads</h4><ul><li>What are <strong>threads</strong> and why use them?</li><li>Creating and terminating threads</li><li>Thread IDs</li><li>Joinable vs. detached threads</li></ul><h4>8. Thread Synchronization</h4><ul><li>Race conditions in multi-threaded programs</li><li><strong>Mutexes</strong> (Mutual Exclusion Locks)</li><li><strong>Condition Variables</strong> for thread communication</li></ul><h4>9. Interprocess Communication (IPC)</h4><ul><li>Pipes &amp; FIFOs</li><li>POSIX Message Queues</li><li>POSIX Semaphores</li><li>POSIX Shared Memory</li></ul><h4>How We’ll Learn</h4><p>Every topic will have:</p><ol><li><strong>Simple explanations</strong> (no jargon overload)</li><li><strong>C/Python code examples</strong> you can compile and run</li><li><strong>Hands-on exercises</strong></li><li><strong>Real-world analogies</strong> so concepts stick</li></ol><h4>Who Is This For?</h4><ul><li>Students exploring systems programming for the first time</li><li>Developers wanting to go beyond just application code</li><li>Hobbyists curious about <em>how Linux really works</em> under the hood</li></ul><p>No prior Linux or C programming experience is required — just curiosity and willingness to type a few commands in the terminal.</p><h4>Next Step</h4><p>In the next article, we’ll:</p><ul><li>Set up your <strong>Linux programming environment</strong> step-by-step</li><li>Install all the <strong>essential tools</strong> you’ll need</li><li>Write and run your very first <strong>“Hello, Linux”</strong> program</li><li>Understand the difference between <strong>User Mode</strong> and <strong>Kernel Mode</strong></li><li>Explore how <strong>Library Functions</strong> differ from <strong>System Calls</strong> — and why it matters for systems programming</li></ul><p>💡 <em>By the end of this series, you’ll be able to write C programs that can create processes, communicate across programs, manage memory, and interact with the Linux kernel like a pro.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0006ff787c1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Observer Pattern: Java Design Patterns — The Ultimate Beginner’s Guide]]></title>
            <link>https://medium.com/@kethajayasandeep1254/observer-pattern-java-design-patterns-2b10ddaaf6ae?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b10ddaaf6ae</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Sat, 14 Jun 2025 19:38:30 GMT</pubDate>
            <atom:updated>2025-06-14T19:38:56.805Z</atom:updated>
            <content:encoded><![CDATA[<h3>Observer Pattern: Java Design Patterns — The Ultimate Beginner’s Guide</h3><p>Imagine you’re building an online electronics store. One user, Alice, is eagerly waiting for the next iPhone model. She has two options:</p><ol><li>Refresh the store page every day (waste of time)</li><li>Let the store blast email to <strong>all</strong> users when a new product arrives (annoying spam)</li></ol><p>Both options suck.</p><blockquote><strong>The problem:</strong> How do we <strong>only notify the people who care</strong>, <strong>when</strong> they care, without annoying everyone else?</blockquote><p>That’s where the <strong>Observer Pattern</strong> comes in.</p><h3>What Is the Observer Pattern?</h3><blockquote>The <strong>Observer Pattern</strong> defines a subscription mechanism to notify multiple objects when an event occurs.</blockquote><p>We have:</p><ul><li><strong>Publisher (Subject)</strong>: Holds state and sends updates</li><li><strong>Subscriber (Observer)</strong>: Wants to be notified when state changes</li></ul><p>When state changes, the publisher notifies <strong>only</strong> those who subscribed.</p><p>No more daily refreshing. No more spamming everyone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BGzKYKv_W-Jp4DxBB2DDwQ.png" /></figure><h3>Java: File Change Notification System</h3><h4>What We’re Building</h4><p>We’ll simulate a <strong>file editor system</strong> where:</p><ul><li>When a file is <strong>opened</strong>, we log it.</li><li>When a file is <strong>saved</strong>, an email alert is sent.</li></ul><p>We’ll use:</p><ul><li>EventManager to manage subscriptions.</li><li>Editor as the publisher.</li><li>LoggingListener and EmailAlertsListener as concrete subscribers.</li></ul><h4>Step 1: EventManager — Core Subscription Logic</h4><pre>// Manages subscriptions and event notifications<br>class EventManager {<br>    private Map&lt;String, List&lt;EventListener&gt;&gt; listeners = new HashMap&lt;&gt;();<br>    <br>    // Add a subscriber for a specific event type<br>    public void subscribe(String eventType, EventListener listener) {<br>        listeners.computeIfAbsent(eventType, k -&gt; new ArrayList&lt;&gt;()).add(listener);<br>    }<br>    <br>    // Remove a subscriber from a specific event type<br>    public void unsubscribe(String eventType, EventListener listener) {<br>        listeners.getOrDefault(eventType, new ArrayList&lt;&gt;()).remove(listener);<br>    }<br>    <br>    // Notify all listeners about an event<br>    public void notify(String eventType, String data) {<br>        for (EventListener listener : listeners.getOrDefault(eventType, new ArrayList&lt;&gt;())) {<br>            listener.update(data);<br>        }<br>    }<br>}</pre><p>This class is the core engine of the Observer Pattern. It manages all subscriptions for different event types using a HashMap. When an event occurs (like ‘open’ or ‘save’), it loops through the relevant list of listeners and calls their update() method.</p><p>This decouples the event-producing logic (publisher) from the event-handling logic (subscribers), allowing new listeners to be added/removed at runtime without modifying core business logic.</p><h4>Step 2: Publisher — The Editor Class</h4><pre>// Publisher that sends events when a file is opened or saved<br>class Editor {<br>    public EventManager events = new EventManager(); // Manages subscribers<br>    private File file;<br><br>    // Simulates opening a file and notifies &#39;open&#39; event<br>    public void openFile(String path) {<br>        this.file = new File(path);<br>        events.notify(&quot;open&quot;, file.getName());<br>    }<br>    <br>    // Simulates saving a file and notifies &#39;save&#39; event<br>    public void saveFile() {<br>        file.write();<br>        events.notify(&quot;save&quot;, file.getName());<br>    }<br>}</pre><p>This class is the core business logic: it opens and saves files. But here’s the magic: it <strong>doesn’t need to know</strong> which subscribers are listening. It just <strong>fires events</strong> (‘open’ or ‘save’) and the EventManager takes care of notifying the appropriate listeners. This keeps the Editor class focused only on its primary responsibility: editing files — without being tightly coupled to any logging, alerting, or notification systems.</p><h4>Step 3: Subscriber Interface and Concrete Implementations</h4><pre>// Common interface for all subscribers<br>interface EventListener {<br>    void update(String filename);<br>}<br><br>// Logs a message to a file whenever notified<br>class LoggingListener implements EventListener {<br>    private File log;<br>    private String message;<br>    public LoggingListener(String logFilePath, String message) {<br>        this.log = new File(logFilePath);<br>        this.message = message;<br>    }<br>    // Called when the event occurs<br>    public void update(String filename) {<br>        log.write(String.format(message, filename));<br>    }<br>}<br><br>// Sends an email alert whenever notified<br>class EmailAlertsListener implements EventListener {<br>    private String email;<br>    private String message;<br>    public EmailAlertsListener(String email, String message) {<br>        this.email = email;<br>        this.message = message;<br>    }<br>    // Called when the event occurs<br>    public void update(String filename) {<br>        sendEmail(email, String.format(message, filename));<br>    }<br>}</pre><p>Each subscriber implements update() in its own way, this means they each handle the same event differently. For example, the LoggingListener writes to a log file, while the EmailAlertsListener sends an email. This flexibility allows the system to react in multiple customized ways to the same event, without the publisher needing to know who is listening or how they&#39;re responding.</p><h4>Step 4: Client Code — Wire It All</h4><pre>// Client sets up the system by wiring subscribers to events<br>class Application {<br>    public void config() {<br>        Editor editor = new Editor();<br>        <br>        // Subscriber that logs when a file is opened<br>        LoggingListener logger = new LoggingListener(<br>            &quot;/log.txt&quot;, &quot;[LOG] File opened: %s&quot;);<br>        <br>        // Subscriber that emails when a file is saved<br>        EmailAlertsListener emailer = new EmailAlertsListener(<br>            &quot;admin@example.com&quot;, &quot;[ALERT] File saved: %s&quot;);<br>        <br>        // Subscribe listeners to specific events<br>        editor.events.subscribe(&quot;open&quot;, logger);<br>        editor.events.subscribe(&quot;save&quot;, emailer);<br>        <br>        // Simulate user actions<br>        editor.openFile(&quot;doc.txt&quot;);<br>        editor.saveFile();<br>    }<br>}</pre><p>This is the final piece where we wire everything together. The Application class acts as the client and is responsible for setting up the entire Observer system. It creates the Editor instance (our publisher), and also the LoggingListener and EmailAlertsListener instances (our subscribers). It then subscribes these listeners to specific events — &quot;open&quot; and &quot;save&quot; — using the editor.events.subscribe() method.</p><h3>Complete Flow Recap</h3><p>Let’s recap the full flow of this Observer system:</p><ol><li><strong>Create Publisher</strong> → Editor class is created, and it holds an EventManager object.</li><li><strong>Create Subscribers</strong> → LoggingListener and EmailAlertsListener are instantiated with their custom behaviors.</li><li><strong>Subscribe</strong> → Subscribers register to specific event types (&quot;open&quot;, &quot;save&quot;) via editor.events.subscribe().</li><li><strong>Trigger Event</strong> → The editor opens or saves a file.</li><li><strong>Notify Subscribers</strong> → The EventManager calls update() on all listeners for that event.</li><li><strong>React</strong> → Each listener performs its defined action (write log, send email).</li></ol><p>This keeps your system <strong>loosely coupled</strong>, <strong>extendable</strong>, and <strong>reactive</strong>.</p><h3>Mnemonic to Remember</h3><blockquote><strong>Publish. Subscribe. Notify. Detach. React.</strong> (aka PSNDR — “Passender”)</blockquote><p>Just memorize this one line. Once you do, it’ll be second nature to implement Observer — clean, decoupled, and totally under your control!</p><h3>When to Use Observer</h3><ul><li>You want a <strong>decoupled</strong> way to react to state changes</li><li>Multiple objects need to stay <strong>in sync</strong> with one</li><li>Subscribers may change at <strong>runtime</strong></li></ul><h3>Pros and Cons</h3><h4>Pros</h4><ul><li><strong>Loosely coupled</strong>: Publisher doesn’t know about concrete subscribers</li><li><strong>Flexible</strong>: Add/remove subscribers without breaking core logic</li><li><strong>Open/Closed Principle</strong>: Add new reactions without changing publisher</li></ul><h4>Cons</h4><ul><li><strong>Memory leaks</strong> possible if subscribers forget to unsubscribe</li><li>Complex chains of events can be hard to debug</li></ul><h3>Wrap Up</h3><p>With just a clean subscription mechanism, you unlock the ability to: Log user activity, Send alerts, Track changes, Sync UI components, React to real-world events — all without rewriting core logic</p><p>💡 Think of it like setting up smart notifications — <strong>only the interested parties get pinged</strong>, and you don’t need to know who they are ahead of time.</p><h3>Don’t Miss This</h3><p>Want to compare <strong>Observer Pattern </strong>with other patterns?<strong><br></strong>👉 Check out the <strong>Design Pattern Comparison Series</strong></p><p>💌 <em>If this article helped you or sparked any ideas, feel free to drop your thoughts at</em> <strong>kethajayasandeep1254@gmail.com</strong>. <em>I’d love to hear from you — whether it’s feedback, suggestions, or just a hello!</em></p><p>👍 <em>If you found this useful, kindly upvote or share so it can help others too!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b10ddaaf6ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Iterator Pattern: Java Design Patterns — The Ultimate Beginner’s Guide]]></title>
            <link>https://medium.com/@kethajayasandeep1254/iterator-pattern-java-design-patterns-bcc7568b9668?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcc7568b9668</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Sat, 14 Jun 2025 16:29:41 GMT</pubDate>
            <atom:updated>2025-06-14T16:29:41.341Z</atom:updated>
            <content:encoded><![CDATA[<h3>Iterator Pattern: Java Design Patterns — The Ultimate Beginner’s Guide</h3><p><strong>The Playlist Problem — From Simplicity to Chaos<br></strong>Let’s say you’re building a music app. You start simple - a flat playlist:</p><pre>List&lt;String&gt; playlist = Arrays.asList(&quot;Song A&quot;, &quot;Song B&quot;, &quot;Song C&quot;);<br>for (String song : playlist) {<br>    System.out.println(song);<br>}</pre><p>Works great. Life is easy.</p><p>But product demands grow:</p><ul><li>Add <strong>Albums</strong> with <strong>nested playlists</strong>.</li><li>Show only <strong>favorites</strong> or <strong>recently added</strong> songs.</li><li>Support different <strong>playback orders</strong> like shuffle, reverse, etc.</li></ul><p>Soon, your data looks like this:</p><pre>class Album {<br>    String name;<br>    List&lt;Playlist&gt; nestedPlaylists;<br>}</pre><p>Now your traversal logic gets bloated:</p><ul><li>Recursively dig through nested playlists</li><li>Filter favorites</li><li>Apply custom order</li></ul><p>Each view, each feature, each button requires custom looping logic:</p><pre>for (Album album : albums) {<br>    for (Playlist pl : album.nestedPlaylists) {<br>        for (String song : pl.getSongs()) {<br>            if (isFavorite(song)) {<br>                play(song);<br>            }<br>        }<br>    }<br>}</pre><p>Traversal logic is duplicated, tangled, error-prone.</p><h3>The Real Problem</h3><p>Your collections are <strong>structured differently</strong>:</p><ul><li>Lists, trees, graphs, sets…</li><li>Some are flat, some are nested, some filtered</li></ul><p>Yet clients want to <strong>iterate</strong> through them <strong>uniformly</strong>.</p><p>Instead of decoupling traversal, you’ve entangled it.</p><blockquote>“Why should the client care how elements are stored?”</blockquote><p>That’s where the <strong>Iterator Pattern</strong> comes in.</p><h3>What Is the Iterator Pattern?</h3><blockquote>The <strong>Iterator Pattern</strong> allows you to <strong>traverse</strong> a collection <strong>without exposing its internal structure</strong>.</blockquote><p>It introduces a separate object called <strong>Iterator</strong> that:</p><ul><li>Tracks the current position</li><li>Implements hasNext() and next()</li><li>Decouples traversal from the collection itself</li></ul><p>It enables multiple traversal strategies:</p><ul><li>Sequential</li><li>Reverse</li><li>Filtered</li><li>Lazy loaded</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MpICywnO2wF3o534dNvKCw.png" /></figure><h3>Real-World Analogy</h3><p>Imagine you walk into a restaurant.</p><ul><li>You don’t walk into the kitchen to grab food.</li><li>A <strong>waiter</strong> (iterator) brings one dish at a time.</li></ul><p>The waiter:</p><ul><li>Keeps track of your order</li><li>Brings dishes one-by-one (next())</li><li>Stops when no more dishes left (hasNext())</li></ul><p>You don’t need to know:</p><ul><li>How food is stored</li><li>Where it’s cooked</li><li>In what order it’s plated</li></ul><p>Just like a client doesn’t need to know how elements are stored, it uses the waiter (iterator) to get items.</p><h3>Java Implementation: Custom Playlist Iterator</h3><h4>Step 1: The SongIterator Interface</h4><pre>// Iterator interface defining two basic operations<br>public interface SongIterator {<br>    boolean hasNext(); // Check if there&#39;s another element<br>    String next();     // Return the next element<br>}</pre><p>Defines a contract that all iterators must follow.</p><h4>Step 2: The PlaylistIterator (Concrete Iterator)</h4><pre>// A concrete iterator that goes through a list of songs<br>public class PlaylistIterator implements SongIterator {<br>    private List&lt;String&gt; songs;<br>    private int position = 0; // Tracks current position<br><br>    public PlaylistIterator(List&lt;String&gt; songs) {<br>        this.songs = songs;<br>    }<br><br>    public boolean hasNext() {<br>        return position &lt; songs.size();<br>    }<br><br>    public String next() {<br>        return songs.get(position++); // Return and advance<br>    }<br>}</pre><p>Keeps internal state (position) and serves songs one by one.</p><h4>Step 3: The SongCollection Interface</h4><pre>// Interface for collections that support iterators<br>public interface SongCollection {<br>    SongIterator createIterator(); // Factory method<br>}</pre><p>Ensures any music collection can return an iterator.</p><h4>Step 4: The Playlist Class (Concrete Collection)</h4><pre>// A concrete collection holding songs<br>public class Playlist implements SongCollection {<br>    private List&lt;String&gt; songs = new ArrayList&lt;&gt;();<br><br>    public void addSong(String song) {<br>        songs.add(song);<br>    }<br><br>    public SongIterator createIterator() {<br>        return new PlaylistIterator(songs); // Return iterator<br>    }<br>}</pre><p>Holds songs and returns a custom iterator when asked.</p><h4>Step 5: Client Code (The App)</h4><pre>// Client code that consumes the iterator<br>public class MusicApp {<br>    public static void main(String[] args) {<br>        Playlist playlist = new Playlist();<br>        playlist.addSong(&quot;Imagine&quot;);<br>        playlist.addSong(&quot;Bohemian Rhapsody&quot;);<br>        playlist.addSong(&quot;Hotel California&quot;);<br><br>        SongIterator it = playlist.createIterator();<br>        while (it.hasNext()) {<br>            System.out.println(it.next());<br>        }<br>    }<br>}</pre><p>Client doesn’t care about the playlist’s internal structure, it just uses the iterator.</p><ul><li>Client doesn’t access the list directly.</li><li>We can later replace PlaylistIterator with ReverseIterator, FavoritesOnlyIterator, etc.</li></ul><h3>Iterator Pattern: Structure Breakdown</h3><h4>Mnemonic to Remember</h4><p>When someone asks:</p><blockquote>“How do you implement the Iterator Pattern?”</blockquote><p>Use this rhythm to connect the concepts with our code example step-by-step:</p><blockquote><strong>Interface. Track. Serve. Hide. Swap.</strong></blockquote><ol><li><strong>Interface</strong> → Start with the SongIterator interface (in SongIterator.java). It defines hasNext() and next() — like setting the ground rules for moving through songs.</li><li><strong>Track</strong> → In PlaylistIterator.java, maintain the position using a position variable. This tracks where you are in the list of songs, one by one — like knowing which track is currently playing.</li><li><strong>Serve</strong> → The next() method in PlaylistIterator returns the next song and moves the pointer forward — delivering one song at a time to the user, like a DJ playing the next track.</li><li><strong>Hide</strong> → In Playlist.java, we use createIterator() to provide access, but the actual song list remains private. The client (MusicApp.java) doesn’t see how songs are stored — it just uses the iterator.</li><li><strong>Swap</strong> → If you need new traversal styles (like reverse or favorites-only), just create a new iterator (e.g., ReverseIterator). No changes needed in MusicApp.java.</li></ol><p>This keeps your logic flexible, clean, and separated — no matter how complex the playlist structure becomes.</p><h3>Why Use Iterator Pattern?</h3><p>Use it when:</p><ul><li>You want to <strong>hide</strong> internal structure of collections</li><li>You need <strong>custom traversals</strong> without changing client logic</li><li>You have <strong>multiple views</strong> or UI components needing their own iterators</li><li>You want <strong>clean separation</strong> between traversal &amp; storage</li></ul><h3>Pros &amp; Cons</h3><h4>Pros</h4><ul><li>Decouples traversal logic from data structure</li><li>Clean and reusable iterator logic</li><li>Multiple iterators can work on the same data independently</li><li>Easier to add new traversal strategies</li></ul><h4>Cons</h4><ul><li>Slight boilerplate for simple lists</li><li>Overkill if only one straightforward traversal is needed</li></ul><h3>Wrap Up</h3><p>The Iterator Pattern looks simple — but it’s a <strong>powerful abstraction</strong>.</p><p>It lets you:</p><ul><li>Traverse any structure without knowing its internals</li><li>Write clean, decoupled traversal logic</li><li>Add custom iteration strategies without rewriting loops</li></ul><p>You no longer care <em>how</em> data is stored. You just get what you need.</p><p>🎵 Like a good playlist — just hit play and enjoy the flow.</p><p>Follow for more pattern deep-dives!</p><h3>Don’t Miss This</h3><p>Want to compare <strong>Iterator Pattern </strong>with other patterns?<strong><br></strong>👉 Check out the <strong>Design Pattern Comparison Series</strong></p><p>💌 <em>If this article helped you or sparked any ideas, feel free to drop your thoughts at</em> <strong>kethajayasandeep1254@gmail.com</strong>. <em>I’d love to hear from you — whether it’s feedback, suggestions, or just a hello!</em></p><p>👍 <em>If you found this useful, kindly upvote or share so it can help others too!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcc7568b9668" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Command Pattern: Java Design Patterns — The Ultimate Beginner’s Guide]]></title>
            <link>https://medium.com/@kethajayasandeep1254/command-pattern-java-design-patterns-4d07f3e674ac?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d07f3e674ac</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Sat, 14 Jun 2025 15:42:29 GMT</pubDate>
            <atom:updated>2025-06-14T15:43:13.202Z</atom:updated>
            <content:encoded><![CDATA[<h3>Command Pattern: Java Design Patterns — The Ultimate Beginner’s Guide</h3><p>Have you ever clicked a button, pressed a shortcut, or used a menu option, and wondered how the system knows what to do? You might think it’s as simple as calling a method. But what happens when you want to:</p><ul><li>Log that action?</li><li>Undo it?</li><li>Trigger the same operation from multiple UI elements?</li></ul><p>That’s where the <strong>Command Design Pattern</strong> comes in.</p><p>This guide walks you from ground zero to fully understanding how the Command Pattern works, with relatable analogies, clear code examples, and a deep dive into its structure and benefits.</p><h3>Intent</h3><p>The <strong>Command Pattern</strong> is a behavioral pattern that turns a <strong>request</strong> into a stand-alone <strong>object</strong>. This lets you:</p><ul><li>Treat operations as first-class objects</li><li>Pass commands around like variables</li><li>Queue them for later</li><li>Log and undo them</li></ul><blockquote>“A command is an object that encapsulates all details of an action: who should do it, what should be done, and with what data.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yT_-uoblwDbZS55OxDrOJA.png" /></figure><h3>Analogy: Restaurant Ordering System</h3><p>Imagine you’re at a restaurant:</p><ul><li>You tell the waiter: “One pizza, please.”</li><li>The waiter writes that down (command)</li><li>He passes it to the kitchen (receiver)</li><li>Later, the chef cooks your pizza</li></ul><p>That piece of paper is the <strong>Command</strong>. It holds everything required to execute your request, without the waiter or chef needing to discuss the details with you again.</p><h3>Problem</h3><p>Suppose you’re building a <strong>Text Editor</strong>. You have UI elements like:</p><ul><li><strong>Buttons</strong>: Copy, Paste, Cut, Undo</li><li><strong>Menus</strong>: File &gt; Paste, Edit &gt; Undo</li><li><strong>Keyboard</strong> <strong>shortcuts</strong>: Ctrl+C, Ctrl+V, Ctrl+Z</li></ul><p>All of these interact with the same actions.</p><p>You could wire all buttons to call the same methods, like:</p><pre>copyButton.onClick(() -&gt; editor.copy());</pre><p>But now you:</p><ul><li>Can’t log/undo these actions easily</li><li>Have duplicate logic in multiple places</li><li>Tightly couple UI to business logic</li></ul><h3>Solution: Enter the Command Pattern</h3><p>The <strong>Command Pattern</strong> lets you:</p><ul><li>Encapsulate the logic of an action in its own class</li><li>Treat that command like data (pass, store, trigger later)</li><li>Reuse the same command object for buttons, menus, etc.</li></ul><h3>Core Concepts</h3><p>When someone asks: “How do you implement the Command Pattern?” — remember this slightly extended rhythm:</p><blockquote>Interface. Implementation. Real logic. Trigger. Wire it up.</blockquote><p>Here’s how to decode it:</p><ul><li><strong>Interface</strong> → Start with a Command interface that defines an execute() method (and optionally undo())</li><li><strong>Implementation</strong> → Create ConcreteCommand classes that implement the interface and hold reference to the receiver</li><li><strong>Real Logic</strong> → Push actual logic into the Receiver class (the real worker)</li><li><strong>Trigger </strong>→ Build an Invoker class (button/menu) that just calls command.execute()</li><li><strong>Wire it up </strong>→ Let the Client create and wire all parts together: command ↔ receiver ↔ invoker</li></ul><h3>Let’s Build a Simple Java Example: Text Editor Commands</h3><h4>Step 1: Define the Command Interface</h4><pre>public interface Command {<br>    void execute();<br>    void undo(); // Optional: For undo functionality<br>}</pre><h4>Step 2: Create the Receiver — Editor</h4><pre>public class Editor {<br>    private String text = &quot;&quot;;<br>    private String clipboard = &quot;&quot;;<br>    private String lastBackup = &quot;&quot;;<br><br>    public void copy(String selection) {<br>        clipboard = selection;<br>        System.out.println(&quot;Copied: &quot; + clipboard);<br>    }<br><br>    public void cut(String selection) {<br>        lastBackup = text;<br>        clipboard = selection;<br>        text = text.replace(selection, &quot;&quot;);<br>        System.out.println(&quot;Cut: &quot; + clipboard);<br>    }<br><br>    public void paste() {<br>        lastBackup = text;<br>        text += clipboard;<br>        System.out.println(&quot;Pasted: &quot; + clipboard);<br>    }<br><br>    public void undo() {<br>        text = lastBackup;<br>        System.out.println(&quot;Undo: Reverted to previous state.&quot;);<br>    }<br><br>    public String getText() {<br>        return text;<br>    }<br>}</pre><h4>Step 3: Concrete Commands</h4><p><strong><em>CopyCommand</em></strong></p><pre>public class CopyCommand implements Command {<br>    private Editor editor;<br>    private String selection;<br><br>    public CopyCommand(Editor editor, String selection) {<br>        this.editor = editor;<br>        this.selection = selection;<br>    }<br>   <br>   @Override<br>    public void execute() {<br>        editor.copy(selection);<br>    }<br>   <br>    @Override<br>    public void undo() {<br>        // Copy doesn&#39;t change state. Nothing to undo.<br>    }<br>}</pre><p><strong><em>CutCommand</em></strong></p><pre>public class CutCommand implements Command {<br>    private Editor editor;<br>    private String selection;<br><br>    public CutCommand(Editor editor, String selection) {<br>        this.editor = editor;<br>        this.selection = selection;<br>    }<br><br>    @Override<br>    public void execute() {<br>        editor.cut(selection);<br>    }<br><br>    @Override<br>    public void undo() {<br>        editor.undo();<br>    }<br>}</pre><p><strong><em>PasteCommand</em></strong></p><pre>public class PasteCommand implements Command {<br>    private Editor editor;<br><br>    public PasteCommand(Editor editor) {<br>        this.editor = editor;<br>    }<br><br>    @Override<br>    public void execute() {<br>        editor.paste();<br>    }<br><br>    @Override<br>    public void undo() {<br>        editor.undo();<br>    }<br>}</pre><h4>Step 4: The Invoker (Button / Shortcut / Menu)</h4><pre>public class CommandInvoker {<br>    public void executeCommand(Command command) {<br>        command.execute();<br>        // Optional: Add to history if it changes state<br>    }<br>}</pre><h4>Step 5: Putting It All Together</h4><pre>public class Main {<br>    public static void main(String[] args) {<br>        Editor editor = new Editor();<br><br>        Command copy = new CopyCommand(editor, &quot;Hello&quot;);<br>        Command cut = new CutCommand(editor, &quot;Hello&quot;);<br>        Command paste = new PasteCommand(editor);<br>        <br>        CommandInvoker invoker = new CommandInvoker();<br>        invoker.executeCommand(copy);<br>        invoker.executeCommand(cut);<br>        invoker.executeCommand(paste);<br>        <br>        // Undo last operation (paste)<br>        paste.undo();<br>    }<br>}</pre><h3>Summary Flow</h3><ol><li><strong>Client</strong> creates command and assigns it to UI elements</li><li><strong>Invoker</strong> (button, menu) triggers the command</li><li><strong>Command</strong> executes logic on <strong>Receiver</strong></li><li>Commands can be logged, undone, or queued</li></ol><h3>When to Use the Command Pattern</h3><ul><li>You want to decouple UI from execution logic</li><li>You want to support undo/redo</li><li>You want to queue or log actions</li><li>You want to support macro or batch commands</li></ul><h3>Pros and Cons</h3><h4>️Pros</h4><ul><li>Clean separation between UI and logic</li><li>Easy to add new commands</li><li>Enables undo/redo</li><li>Allows logging and scheduling</li></ul><h4>Cons</h4><ul><li>More boilerplate (extra classes)</li><li>Can be overkill for very simple operations</li></ul><h3>Wrap-Up</h3><p>The <strong>Command Pattern</strong> gives you flexibility, structure, and power:</p><ul><li>It lets you package an operation as an object</li><li>It simplifies GUI to logic interactions</li><li>It opens up powerful tools like <strong>undo</strong>, <strong>redo</strong>, <strong>history</strong>, and <strong>macros</strong></li></ul><p>If your system has actions coming from many sources, or needs control over how/when things happen — Command is your best friend.</p><p>Follow for more pattern deep-dives!</p><h3>Don’t Miss This</h3><p>Want to compare <strong>Command Pattern </strong>with other patterns like <strong>Chain of Responsibility, Mediator,</strong> or <strong>Observer?<br></strong>👉 Check out the <strong>Design Pattern Comparison Series</strong></p><p>💌 <em>If this article helped you or sparked any ideas, feel free to drop your thoughts at</em> <strong>kethajayasandeep1254@gmail.com</strong>. <em>I’d love to hear from you — whether it’s feedback, suggestions, or just a hello!</em></p><p>👍 <em>If you found this useful, kindly upvote or share so it can help others too!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d07f3e674ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strategy Pattern: Java Design Patterns — The Ultimate Beginner’s Guide]]></title>
            <link>https://medium.com/@kethajayasandeep1254/strategy-pattern-java-design-patterns-6b756c712089?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b756c712089</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 06:06:59 GMT</pubDate>
            <atom:updated>2025-06-12T06:06:59.552Z</atom:updated>
            <content:encoded><![CDATA[<h3>Strategy Pattern: Java Design Patterns — The Ultimate Beginner’s Guide</h3><p>Ever written code where behavior changes based on a choice, like sorting, searching, or routing, and ended up stacking if-else or switch blocks? Those conditionals can bloat your code and make it difficult to scale.</p><p>The <strong>Strategy Design Pattern</strong> offers a clean way to switch between different algorithms without touching the core logic. This article walks you through the Strategy pattern step-by-step with fun analogies and a complete working Java example.</p><blockquote>Sounds a bit like the <a href="https://medium.com/@kethajayasandeep1254/state-pattern-java-design-patterns-4fa04944239d">State pattern</a>, right? Both let you switch behavior dynamically, but there’s a key difference we’ll uncover later in this article.</blockquote><h3>What Is the Strategy Pattern?</h3><p>The <strong>Strategy Pattern</strong> is a behavioral design pattern that lets you define a <strong>family of algorithms</strong>, encapsulate each one in a separate class, and make them interchangeable at runtime.</p><blockquote>“The algorithm can change without changing the context that uses it.”</blockquote><p>Instead of hardcoding logic into one massive class, you write different strategies (algorithms) and plug them into a flexible shell (context).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CF3XfrQvZX_DjB6YIybr3A.png" /></figure><h3>Real-Life Analogy: Getting to the Airport</h3><p>Imagine you need to get to the airport. You have several options:</p><ul><li><strong>Bus</strong>: Cheap but slow</li><li><strong>Taxi</strong>: Expensive but fast</li><li><strong>Bike</strong>: Healthy and green</li></ul><p>These are all <strong>strategies</strong> for transportation. Depending on your time, money, or mood, you choose one. Your decision-making logic doesn’t change, you simply <strong>swap the strategy</strong>.</p><p>That’s how Strategy works in code.</p><h3>Why Use the Strategy Pattern?</h3><p>Let’s say you’re building a <strong>navigation app</strong> that supports:</p><ul><li>Car routes</li><li>Walking routes</li><li>Public transport</li><li>Bicycle paths</li><li>Tourist trails</li></ul><p>In version 1, you only had car routes. Then came walking, then bus, then more… and now your route calculation method looks like this:</p><pre>if (mode.equals(&quot;car&quot;)) {<br>    // do car route<br>} else if (mode.equals(&quot;walk&quot;)) {<br>    // walk logic<br>} else if (mode.equals(&quot;bus&quot;)) {<br>    // bus route logic<br>} ... // and so on</pre><p>Now you’re stuck in conditional hell. The code is hard to read, change, or test. Your team gets merge conflicts because everyone edits the same file.</p><p><strong>Solution?</strong> Strategy pattern.</p><h3>Core Concepts</h3><ul><li><strong>Strategy Interface</strong>: Declares the algorithm contract (e.g., execute() method).</li><li><strong>Concrete Strategies</strong>: Different algorithms implementing that interface.</li><li><strong>Context</strong>: Holds a reference to a Strategy and delegates behavior to it.</li><li><strong>Client</strong>: Chooses which strategy to use and injects it into the context.</li></ul><h3>Let’s Build It in Java: Arithmetic Calculator with Strategies</h3><h4>Step 1: Define Strategy Interface</h4><pre>public interface CalculationStrategy {<br>    int execute(int a, int b);<br>}</pre><h4>Step 2: Implement Concrete Strategies</h4><h4>Addition</h4><pre>public class AdditionStrategy implements CalculationStrategy {<br>    public int execute(int a, int b) {<br>        return a + b;<br>    }<br>}</pre><h4>Subtraction</h4><pre>public class SubtractionStrategy implements CalculationStrategy {<br>    public int execute(int a, int b) {<br>        return a - b;<br>    }<br>}</pre><h4>Multiplication</h4><pre>public class MultiplicationStrategy implements CalculationStrategy {<br>    public int execute(int a, int b) {<br>        return a * b;<br>    }<br>}</pre><h4>Step 3: Context Class</h4><pre>public class CalculatorContext {<br>    private CalculationStrategy strategy;<br><br>    public void setStrategy(CalculationStrategy strategy) {<br>        this.strategy = strategy;<br>    }<br>    <br>    public int calculate(int a, int b) {<br>        if (strategy == null) {<br>            throw new IllegalStateException(&quot;Strategy not set!&quot;);<br>        }<br>        return strategy.execute(a, b);<br>    }<br>}</pre><h4>Step 4: Demo — Switching Strategies at Runtime</h4><pre>public class Main {<br>    public static void main(String[] args) {<br>        CalculatorContext context = new CalculatorContext();<br><br>        context.setStrategy(new AdditionStrategy());<br>        System.out.println(&quot;Add: &quot; + context.calculate(5, 3)); // 8<br>        <br>        context.setStrategy(new SubtractionStrategy());<br>        System.out.println(&quot;Subtract: &quot; + context.calculate(5, 3)); // 2<br>        <br>        context.setStrategy(new MultiplicationStrategy());<br>        System.out.println(&quot;Multiply: &quot; + context.calculate(5, 3)); // 15<br>    }<br>}</pre><h3>How Is Strategy Different from State?</h3><p>At first glance, Strategy and State may look nearly identical. Both patterns involve delegation: you swap in a different object that implements a common interface. But they differ in <strong>intent</strong>, <strong>control flow</strong>, and <strong>design motivation</strong>.</p><p>Here’s a deeper breakdown:</p><p><strong>Intent</strong>:</p><ul><li>The <strong>Strategy Pattern</strong> is all about allowing the client (the external caller) to pick which algorithm to use. It’s focused on behavior that can change <strong>independently</strong> from the context. For example, choosing between different sorting methods or route calculation logic.</li><li>The <strong>State Pattern</strong>, on the other hand, is about representing the different phases or conditions of an object over time. The object’s own internal logic decides when to transition from one state to another.</li></ul><p><strong>Control Flow</strong>:</p><ul><li>With Strategy, the <strong>client explicitly decides</strong> which strategy to use. It can even change strategies dynamically at runtime by calling setStrategy(...).</li><li>With State, the <strong>context drives the transition</strong>. The object changes its internal state and thereby changes its behavior automatically. The client is often unaware of the exact state.</li></ul><p><strong>Awareness and Transition</strong>:</p><ul><li>Strategies are typically <strong>independent</strong> of each other. They don’t know or care about one another.</li><li>State objects often <strong>know about other states</strong> and can trigger transitions. For example, a PlayingState might switch to a PausedState in a media player.</li></ul><p><strong>Example Analogy</strong>:<br><strong>Strategy</strong>: You’re picking a tool from a toolbox — scissors, knife, or laser cutter — to perform a task. You decide.</p><p><strong>State</strong>: A vending machine that changes from “Waiting for Coins” to “Dispensing Item” based on your actions. You don’t switch the state — it responds to your input internally.</p><blockquote>So, while they look similar structurally, they serve <strong>very different purposes</strong>.</blockquote><blockquote>Use <strong>Strategy</strong> when the algorithm can vary and should be selected by the client.</blockquote><blockquote>Use <strong>State</strong> when an object’s behavior needs to evolve <strong>based on its internal lifecycle</strong>.</blockquote><h3>When to Use the Strategy Pattern</h3><p>Use Strategy when:</p><ul><li>You want to support multiple ways to do something (algorithms)</li><li>You need to <strong>switch logic at runtime</strong></li><li>You want to follow <strong>Open/Closed Principle</strong></li><li>You want to avoid if-else or switch bloat</li></ul><h3>Pros &amp; Cons</h3><h4><strong>Pros</strong></h4><ul><li>Swap algorithms at runtime</li><li>Cleaner code with <strong>Single Responsibility Principle</strong></li><li>Add new algorithms without touching core logic</li><li>Good for testing and extension</li></ul><h4>Cons</h4><ul><li>Requires more classes</li><li>Client must know which strategy to choose</li><li>Overkill for very simple tasks</li></ul><h3>Wrap-Up</h3><p>The <strong>Strategy Pattern</strong> is a clean, flexible way to manage behavior that varies by algorithm or decision. Instead of cluttering your code with if-else, you delegate to strategy classes.</p><p>Follow me for more real-world pattern walkthroughs!</p><h3>Don’t Miss This</h3><p>Want to compare <strong>Strategy Pattern </strong>with other patterns like <strong>State, Bridge,</strong> or <strong>Adapter?<br></strong>👉 Check out the <strong>Design Pattern Comparison Series</strong></p><p>💌 <em>If this article helped you or sparked any ideas, feel free to drop your thoughts at</em> <strong>kethajayasandeep1254@gmail.com</strong>. <em>I’d love to hear from you — whether it’s feedback, suggestions, or just a hello!</em></p><p>👍 <em>If you found this useful, kindly upvote or share so it can help others too!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b756c712089" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[State Pattern: Java Design Patterns — The Ultimate Beginner’s Guide]]></title>
            <link>https://medium.com/@kethajayasandeep1254/state-pattern-java-design-patterns-4fa04944239d?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fa04944239d</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 05:40:33 GMT</pubDate>
            <atom:updated>2025-06-12T05:40:33.786Z</atom:updated>
            <content:encoded><![CDATA[<h3>State Pattern: Java Design Patterns — The Ultimate Beginner’s Guide</h3><p>If you’ve ever tried to write code that behaves differently depending on some internal value, like a status, mode, or phase; you might have ended up with a jungle of if and switch statements. These conditionals work... until they don’t. The logic becomes messy, hard to scale, and painful to maintain.</p><p>Let’s change that.</p><p>Today, we’ll explore the <strong>State Design Pattern, </strong>a powerful, beginner-friendly way to make your code smarter, cleaner, and more adaptable. This article is your complete guide, from the basics to a fully working Java example.</p><h3>What Is the State Pattern?</h3><p>The <strong>State Design Pattern</strong> is a behavioral design pattern that allows an object to change its behavior when its <strong>internal state</strong> changes. It’s like the object is transforming into a different version of itself.</p><blockquote>“When the state changes, the behavior changes.”</blockquote><p>You don’t need messy if-else ladders anymore. Instead, you create a separate class for each state and let them handle behavior.</p><h3>A Simple Analogy: Video Game Character</h3><p>Let’s say you’re coding a game character. This character can be in different modes:</p><ul><li><strong>Idle</strong>: He’s just standing</li><li><strong>Walking</strong>: He moves slowly</li><li><strong>Running</strong>: He moves fast</li></ul><p>When you press a key:</p><ul><li>If idle → start walking</li><li>If walking → start running</li><li>If running → slow down</li></ul><p>Instead of writing logic like:</p><pre>if (state.equals(&quot;IDLE&quot;)) {<br>    walk();<br>} else if (state.equals(&quot;WALKING&quot;)) {<br>    run();<br>}</pre><p>You define each mode as its <strong>own class</strong>. Each class knows what to do when a button is pressed. That’s the <strong>State pattern</strong> in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TrwyE-qgWzIkNsWKzowEFw.png" /></figure><h3>Why Use the State Pattern?</h3><h4>Problem:</h4><p>Imagine you’re building a <strong>Document Workflow</strong>. A document can be:</p><ul><li>Draft</li><li>In Review</li><li>Published</li></ul><p>Each state changes how the document behaves:</p><ul><li>In <strong>Draft</strong>, you can edit or submit.</li><li>In <strong>Review</strong>, only a reviewer can approve or reject.</li><li>In <strong>Published</strong>, everything is read-only.</li></ul><p>Now imagine putting this in one class using conditions:</p><pre>public void approve() {<br>    // ❌ Problematic conditional logic<br>    if (state.equals(&quot;Review&quot;)) {<br>        System.out.println(&quot;Approved and published.&quot;);<br>        state = &quot;Published&quot;;<br>    } else {<br>        System.out.println(&quot;Error: You can only approve during Review state.&quot;);<br>    }<br>}</pre><p>This kind of logic might look simple now, but imagine having many such methods for many states. Each method gets polluted with condition checks, making it hard to test and extend. The moment someone adds a new state, they have to revisit every method, introducing risk and bugs. That’s why we use the <strong>State Pattern</strong> to cleanly separate state-specific behavior.</p><h3>Key Concepts</h3><ul><li><strong>Context</strong>: The object whose behavior changes with state (e.g., Document)</li><li><strong>State Interface</strong>: Declares common methods (e.g., edit(), submit())</li><li><strong>Concrete States</strong>: Implement the interface and define unique behavior</li><li><strong>Delegation</strong>: Context delegates to the current state object</li></ul><blockquote>“State Pattern uses composition over inheritance to achieve flexible behavior based on runtime state.”</blockquote><h3>Let’s Build It in Java: A Document Workflow System</h3><h4>Step 1: Define the State Interface</h4><pre>public interface DocumentState {<br>    void edit();<br>    void submit();<br>    void approve();<br>    void reject();<br>}</pre><h4>Step 2: Context Class — Document</h4><pre>public class Document {<br>    private DocumentState state;<br><br>    public Document() {<br>        this.state = new DraftState(this); // start as draft<br>    }<br>    <br>    public void setState(DocumentState state) {<br>        this.state = state;<br>    }<br>    <br>    public void edit() {<br>        state.edit();<br>    }<br>    <br>    public void submit() {<br>        state.submit();<br>    }<br>    <br>    public void approve() {<br>        state.approve();<br>    }<br>    <br>    public void reject() {<br>        state.reject();<br>    }<br>}</pre><h4>Step 3: Implement State Classes</h4><h4>DraftState</h4><pre>public class DraftState implements DocumentState {<br>    private final Document document;<br><br>    public DraftState(Document document) {<br>        this.document = document;<br>    }<br>    <br>    public void edit() {<br>        System.out.println(&quot;You can edit the draft.&quot;);<br>    }<br>    <br>    public void submit() {<br>        System.out.println(&quot;Draft submitted for review.&quot;);<br>        document.setState(new ReviewState(document));<br>    }<br>    <br>    public void approve() {<br>        System.out.println(&quot;Cannot approve a draft.&quot;);<br>    }<br>    <br>    public void reject() {<br>        System.out.println(&quot;Draft can&#39;t be rejected.&quot;);<br>    }<br>}</pre><h4>ReviewState</h4><pre>public class ReviewState implements DocumentState {<br>    private final Document document;<br>    <br>    public ReviewState(Document document) {<br>        this.document = document;<br>    }<br>    <br>    public void edit() {<br>        System.out.println(&quot;Editing not allowed during review.&quot;);<br>    }<br>    <br>    public void submit() {<br>        System.out.println(&quot;Already under review.&quot;);<br>    }<br>    <br>    public void approve() {<br>        System.out.println(&quot;Approved and published.&quot;);<br>        document.setState(new PublishedState(document));<br>    }<br>    <br>    public void reject() {<br>        System.out.println(&quot;Review rejected. Back to draft.&quot;);<br>        document.setState(new DraftState(document));<br>    }<br>}</pre><h4>PublishedState</h4><pre>public class PublishedState implements DocumentState {<br>    private final Document document;<br>    <br>    public PublishedState(Document document) {<br>        this.document = document;<br>    }<br>    <br>    public void edit() {<br>        System.out.println(&quot;Cannot edit a published document.&quot;);<br>    }<br>    <br>    public void submit() {<br>        System.out.println(&quot;Already published.&quot;);<br>    }<br>    <br>    public void approve() {<br>        System.out.println(&quot;Already published.&quot;);<br>    }<br>    <br>    public void reject() {<br>        System.out.println(&quot;Cannot reject a published document.&quot;);<br>    }<br>}</pre><h4>Demo in Action</h4><pre>public class Main {<br>    public static void main(String[] args) {<br>        Document doc = new Document();<br><br>        doc.edit();    // You can edit the draft.<br>        doc.submit();  // Draft submitted for review.<br>       <br>        doc.edit();    // Editing not allowed during review.<br>        doc.approve(); // Approved and published.<br>        <br>        doc.edit();    // Cannot edit a published document.<br>    }<br>}</pre><h3>When to Use the State Pattern</h3><p>Use this pattern when:</p><ul><li>You have <strong>multiple states</strong> and <strong>state-dependent behavior</strong></li><li>You want to avoid if-else conditionals everywhere</li><li>You want a <strong>clean, extendable, testable</strong> design</li></ul><h3>Pros &amp; Cons</h3><p><strong>Pros:</strong></p><ul><li>Each state is self-contained</li><li>Easy to add/remove new states</li><li>No long if-else ladders</li></ul><p><strong>Cons:</strong></p><ul><li>Can be overkill for very simple problems</li><li>More classes to manage</li></ul><h3>Wrap-Up</h3><p>The State Pattern is a great tool when behavior changes based on internal state. It replaces conditionals with polymorphism and makes your code cleaner and more scalable.</p><p>Follow me for more beginner-friendly breakdowns!</p><h3>Don’t Miss This</h3><p>Want to compare <strong>State Pattern </strong>with other patterns like <strong>Bridge, Strategy,</strong> or <strong>Adapter?<br></strong>👉 Check out the <strong>Design Pattern Comparison Series</strong></p><p>💌 <em>If this article helped you or sparked any ideas, feel free to drop your thoughts at</em> <strong>kethajayasandeep1254@gmail.com</strong>. <em>I’d love to hear from you — whether it’s feedback, suggestions, or just a hello!</em></p><p>👍 <em>If you found this useful, kindly upvote or share so it can help others too!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fa04944239d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chain of Responsibility Pattern: Java Design Patterns — The Ultimate Beginner’s Guide]]></title>
            <link>https://medium.com/@kethajayasandeep1254/chain-of-responsibility-pattern-java-design-patterns-c27594972fd3?source=rss-6ff0c775091d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c27594972fd3</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Jaya Sandeep Ketha]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 05:04:58 GMT</pubDate>
            <atom:updated>2025-06-12T05:04:58.540Z</atom:updated>
            <content:encoded><![CDATA[<h3>Chain of Responsibility Pattern: Java Design Patterns — The Ultimate Beginner’s Guide</h3><p>Have you ever contacted customer support and been passed from chatbot to agent to specialist? That’s the Chain of Responsibility pattern in action. In this article, we’ll break it down from the absolute basics to building flexible, decoupled request pipelines in Java.</p><h3>What Is the Chain of Responsibility Pattern?</h3><p><strong>Chain of Responsibility (CoR)</strong> is a <strong>behavioral design pattern</strong> that allows a request to be passed through a <strong>chain of handlers</strong>. Each handler can choose to handle the request or pass it to the next one.</p><p>This pattern is useful when:</p><ul><li>Multiple objects may handle a request.</li><li>You don’t want to couple sender and receiver.</li><li>You want to build <strong>flexible chains of processing logic</strong>.</li></ul><p>Also known as: <strong>CoR</strong>, <strong>Chain of Command</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6vws43x280kXy7kF2TlCkg.png" /></figure><h3>The Problem It Solves</h3><p>Let’s say you’re building an online ordering system. Before placing an order, the system must:</p><ol><li>Authenticate the user</li><li>Authorize admin permissions if needed</li><li>Sanitize incoming data</li><li>Block repeated failed attempts (security)</li><li>Return cached data if applicable</li></ol><p>You initially write all these checks in one long method. But soon:</p><ul><li>The method becomes messy and fragile.</li><li>Adding/removing checks is hard.</li><li>Reusing checks elsewhere causes duplication.</li></ul><h3>The Chain-Based Solution</h3><p>The Chain of Responsibility pattern solves this by turning <strong>each check into a standalone handler class</strong>, each with a handle() method.</p><p>Each handler decides:</p><ul><li>Should I process this?</li><li>Should I pass it along?</li></ul><p>You then link these handlers to form a processing pipeline (chain).</p><p>This gives you:</p><ul><li>Reusable, decoupled logic</li><li>Cleaner, composable workflows</li><li>Full control over the processing order</li></ul><h3>Structure</h3><pre>Handler (interface)<br>├── BaseHandler (optional abstract class with chaining logic)<br>├── AuthHandler<br>├── SanitizeHandler<br>└── CacheHandler</pre><p>Each handler only knows about the <strong>next handler</strong>, allowing the request to move down the line.</p><h3>Java Implementation: Step-by-Step</h3><h4>Step 1: Define the Handler Interface</h4><pre>interface Handler {<br>    void handle(Request request);<br>}</pre><h4>Step 2: Create the BaseHandler (optional but useful)</h4><pre>// BaseHandler provides the common logic to link and forward requests<br>// down the chain. It implements the Handler interface.<br>abstract class BaseHandler implements Handler {<br><br>    // Holds a reference to the next handler in the chain<br>    private Handler next;<br><br>    /**<br>     * Sets the next handler in the chain.<br>     * This enables chaining like: auth.setNext(validation).setNext(logger);<br>     *<br>     * @param next The next handler<br>     * @return The same handler passed in, to allow method chaining<br>     */<br>    public BaseHandler setNext(Handler next) {<br>        this.next = next;<br>        return (BaseHandler) next;<br>    }<br><br>    /**<br>     * Forwards the request to the next handler in the chain,<br>     * if one exists.<br>     *<br>     * @param request The request to pass along<br>     */<br>    protected void forward(Request request) {<br>        if (next != null) {<br>            next.handle(request);  // Delegate to the next handler<br>        }<br>    }<br>}</pre><ul><li>BaseHandler is an <strong>abstract class</strong>, so it’s never used directly — it’s meant to be <strong>extended by real handlers</strong> like AuthHandler, ValidationHandler, etc.</li></ul><p>It provides the <strong>core logic for chaining</strong>:</p><ul><li>setNext() sets the next handler and returns it for fluent chaining.</li><li>forward() passes the Request to the next handler if there is one.</li></ul><p>This class helps keep your concrete handlers clean — they only need to implement the actual handle() logic and can use forward(request) when they’re done.</p><h4>Step 3: Define the Request Object</h4><pre>class Request {<br>    public String user;<br>    public boolean isAdmin;<br>    public boolean isValid = true;<br>    public boolean isCached;<br>    // ... add more fields as needed<br>}</pre><h4>Step 4: Create Concrete Handlers</h4><pre>// Handler 1: Checks if the user is authenticated<br>class AuthHandler extends BaseHandler {<br>    @Override<br>    public void handle(Request request) {<br>        // If user is not logged in, stop the chain<br>        if (request.user == null) {<br>            System.out.println(&quot;[Auth] User not authenticated. Stopping.&quot;);<br>            return; // Do not pass the request further<br>        }<br><br>        // Otherwise, continue to the next handler<br>        System.out.println(&quot;[Auth] User authenticated.&quot;);<br>        forward(request); // Delegate to next handler<br>    }<br>}<br><br>// Handler 2: Performs admin-level checks<br>class AdminHandler extends BaseHandler {<br>    @Override<br>    public void handle(Request request) {<br>        // If the user is not an admin, we don&#39;t stop — just skip admin-specific logic<br>        if (!request.isAdmin) {<br>            System.out.println(&quot;[Admin] Not an admin. Skipping admin checks.&quot;);<br>        } else {<br>            System.out.println(&quot;[Admin] Admin verified.&quot;);<br>            // Admin-specific logic could go here<br>        }<br><br>        // Always forward the request regardless of admin status<br>        forward(request);<br>    }<br>}<br><br>// Handler 3: Cleans up or preprocesses request data<br>class SanitizeHandler extends BaseHandler {<br>    @Override<br>    public void handle(Request request) {<br>        // Simulate data sanitization<br>        System.out.println(&quot;[Sanitize] Cleaning data...&quot;);<br><br>        // Pass it to the next handler<br>        forward(request);<br>    }<br>}</pre><h4>Step 5: Compose the Chain</h4><pre>public class ChainApp {<br>    public static void main(String[] args) {<br>        Request request = new Request();<br>        request.user = &quot;john&quot;;<br>        request.isAdmin = true;<br><br>        Handler chain = new AuthHandler();<br>        <br>        chain.setNext(new AdminHandler())<br>             .setNext(new SanitizeHandler());<br>        <br>        chain.handle(request);<br>    }<br>}</pre><h3>Flow Summary</h3><ol><li>The AuthHandler verifies the user.</li><li>If successful, it forwards the request to AdminHandler.</li><li>That continues to SanitizeHandler.</li><li>If any handler stops the chain, remaining ones are not executed.</li></ol><h3>Advantages</h3><ul><li>Handlers are reusable and easy to test.</li><li>You can reconfigure chains at runtime.</li><li>Logic is clean and follows <strong>Single Responsibility Principle</strong>.</li><li>No hardcoding of processing sequence inside handlers.</li></ul><h3>Drawbacks</h3><ul><li>Some requests might go unhandled if not all paths are covered.</li><li>Tracing a request through a long chain can become difficult.</li><li>Debugging dynamic chains might be tricky if not logged well.</li></ul><h3>Use Cases</h3><ul><li>Middleware pipelines (authentication, validation, logging)</li><li>Event processing in GUI (mouse/keyboard events)</li><li>Spam filtering</li><li>Input sanitization chains</li><li>File format detection</li></ul><h3>When to Use</h3><p>Use Chain of Responsibility when:</p><ul><li>You have multiple objects that can handle a request.</li><li>You want to decouple senders and receivers.</li><li>You want to reuse or reorder processing logic.</li><li>You want to <strong>stop processing early</strong> if a condition fails.</li></ul><h3>Wrap-Up</h3><p>The Chain of Responsibility pattern is all about <strong>flexibility</strong>. You chain your logic like links in a pipeline — each handler doing one job well. It’s clean, testable, extensible, and lets you break away from long, messy conditionals.</p><h3>Don’t Miss This</h3><p>Want to compare <strong>Chain of Responsibility </strong>with other patterns like <strong>Command</strong>, or <strong>Composite?<br></strong>👉 Check out the <strong>Design Pattern Comparison Series</strong></p><p>💌 <em>If this article helped you or sparked any ideas, feel free to drop your thoughts at</em> <strong>kethajayasandeep1254@gmail.com</strong>. <em>I’d love to hear from you — whether it’s feedback, suggestions, or just a hello!</em></p><p>👍 <em>If you found this useful, kindly upvote or share so it can help others too!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c27594972fd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>