<?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 Nikhil Kashyap on Medium]]></title>
        <description><![CDATA[Stories by Nikhil Kashyap on Medium]]></description>
        <link>https://medium.com/@nikhilkashyap819?source=rss-7c1d2cb221e1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fbCfCSC40RpIX-QNdE0Ufg.jpeg</url>
            <title>Stories by Nikhil Kashyap on Medium</title>
            <link>https://medium.com/@nikhilkashyap819?source=rss-7c1d2cb221e1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 22 May 2026 18:19:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nikhilkashyap819/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[We Built an AI That Can See Your City — Here’s How]]></title>
            <link>https://medium.com/@nikhilkashyap819/we-built-an-ai-that-can-see-your-city-heres-how-ec080ae7e9b4?source=rss-7c1d2cb221e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec080ae7e9b4</guid>
            <category><![CDATA[yolo]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Nikhil Kashyap]]></dc:creator>
            <pubDate>Fri, 15 May 2026 12:13:33 GMT</pubDate>
            <atom:updated>2026-05-15T12:13:33.057Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>Our hackathon project uses satellite imagery and YOLOv11 to automatically detect and map urban infrastructure in real time.</em></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*1KUJiRx7DduRwF48gf458Q.png" /></figure><p>Cities are growing faster than governments can keep up with. Roads get built, encroachments happen, properties go unmapped, and green cover disappears — often without anyone in city administration even noticing. The result? Outdated records, revenue leakage, and infrastructure that’s impossible to manage efficiently.</p><p>At our internal hackathon, we set out to fix this with Urban Asset Intelligence — an AI-powered platform that analyzes satellite and drone imagery to automatically detect, classify, and register urban assets on a live map.</p><p><strong>The Problem No One Talks About</strong></p><p>Most city administrations still rely on manual field surveys to maintain their asset registries. This means records are always months or years out of date, illegal encroachments go undetected until it’s too late, and infrastructure maintenance is reactive — not proactive.</p><p><em>There’s no single source of truth for what a city actually contains. We wanted to build one.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*W9UZZCzz_weVobUaCVr-MA.png" /></figure><p><strong>What We Built</strong></p><p>Urban Asset Intelligence is an end-to-end platform that takes a satellite or drone image as input and outputs a fully annotated, geo-referenced map of urban assets within seconds. Upload an image and get back detected buildings, roads, water bodies, parks, drains, and trees — each tagged with coordinates, estimated dimensions, and an area summary. All exportable as GeoJSON, JSON, or CSV, and ready to plug into governance systems like DIGIT Urban Governance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*lMHiRTrg9tkj27WEW7-U5Q.png" /></figure><h3>How the Pipeline Works</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*T7in9bp2jRrzATOoU8I3qQ.png" /></figure><h3>Under the Hood: The Tech Stack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*V2hz4bmLfeA8W7mkmy_lNA.png" /></figure><h3>Three Asset Categories Detected so far</h3><p>- 🏢 <strong>Buildings &amp; Properties</strong></p><p>- 🌳 <strong>Trees &amp; Green Cover</strong></p><p>- 💧 <strong>Water Bodies</strong></p><p>Each detected asset is tagged with its boundary polygon, estimated area, and GPS coordinates — ready for ingestion into a city’s asset registry.</p><p><strong>Why This Matters</strong></p><p>The impact goes beyond just having a prettier map:</p><p>- <strong>Track Infrastructure</strong> at scale without expensive field surveys</p><p>- <strong>Improve Governance </strong>with accurate, real-time asset data</p><p>- <strong>Enable Smart Urban Planning </strong>backed by current ground truth</p><p>- <strong>Reduce Revenue Loss</strong> by surfacing unmapped and encroached properties</p><p>Built for integration with <strong>DIGIT Urban Governance</strong>, the platform is designed to slot into existing municipal workflows rather than replace them.</p><p><strong>What We Learned</strong></p><p>Training a segmentation model on satellite imagery is humbling. Rooftops look like roads from above. Shadows fool the model. Resolution matters enormously. We spent a significant portion of the hackathon just understanding <em>*why*</em> the model was wrong, not just fixing it.</p><p>The LLM integration — using Groq to generate natural language reports from detection outputs — turned out to be one of the most demo-friendly features we built. Seeing a model describe a neighborhood’s infrastructure in plain English from a satellite image is genuinely striking.</p><p><strong>What’s Next</strong></p><p>We’re just getting started. On the roadmap:</p><p>- Temporal monitoring with automated alerts for detected changes</p><p>- Multi-city deployment with federated data</p><p>- Integration with IoT sensor data for real-time infrastructure health</p><p>- Finer-grained asset categories (building type, road condition, encroachment probability)</p><p>If you’re working on smart city tech, urban governance, or satellite imagery ML — we’d love to connect. Drop a comment or reach out directly.</p><p><strong>Built at an internal hackathon</strong> · YOLOv11 · DeepGlobe · FastAPI · React</p><p><em>*Thanks for reading! If this resonated, give it a clap 👏 — it helps others find the project.*</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec080ae7e9b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Singleton Design Pattern]]></title>
            <link>https://medium.com/@nikhilkashyap819/singleton-design-pattern-a16421774265?source=rss-7c1d2cb221e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a16421774265</guid>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[lld]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <dc:creator><![CDATA[Nikhil Kashyap]]></dc:creator>
            <pubDate>Sun, 28 Dec 2025 18:53:20 GMT</pubDate>
            <atom:updated>2025-12-28T18:53:20.715Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0DhI1G5pwX3JSuvlUC0W3A.png" /></figure><p>Singleton ensures <strong>only one instance</strong> of a class exists and provides a <strong>global access point</strong> to it.</p><p><strong>Real World Use case:</strong> For Logger, Database Connection, Configuration Manager.</p><h3>Problem</h3><p>Creating multiple instances of a class like a logger and DBContext can cause:</p><ul><li>Resource wastage</li><li>Inconsistent state</li><li>Hard-to-manage global resources</li></ul><ol><li><strong>Classic Singleton (Not Thread-Safe)Because Mutliple thread can access the instance:</strong></li></ol><pre>#include &lt;bits/stdc++.h&gt;<br>using namespace std;<br><br>class Logger {<br>private:<br>    // Static pointer to hold the single instance of Logger<br>    static Logger* instance;<br><br>    // Mutex to ensure thread safety in multi-threaded environment<br>    static mutex mtx;<br><br>    // Private constructor<br>    // Prevents object creation from outside the class<br>    Logger() {<br>        cout &lt;&lt; &quot;Logger instance created&quot; &lt;&lt; endl;<br>    }<br><br>    // -------------------------------<br>    // Prevent breaking Singleton<br>    // -------------------------------<br><br>    // Disable copy constructor<br>    Logger(const Logger&amp;) = delete;<br><br>    // Disable copy assignment operator<br>    Logger&amp; operator=(const Logger&amp;) = delete;<br><br>    // Disable move constructor (optional but recommended)<br>    Logger(Logger&amp;&amp;) = delete;<br><br>    // Disable move assignment operator<br>    Logger&amp; operator=(Logger&amp;&amp;) = delete;<br><br>public:<br>    // Static method to provide global access to the instance<br>    // Static because it belongs to the class, not to any object<br>    static Logger* getInstance() {<br><br>        // Lock mutex to ensure only one thread can enter this block<br>        lock_guard&lt;mutex&gt; lock(mtx);<br><br>        // Lazy Initialization:<br>        // Create instance only when it is first requested<br>        if (instance == nullptr) {<br>            lock_guard&lt;mutex&gt; lock(mtx);<br>            instance = new Logger();<br>        }<br><br>        // Return the same instance every time<br>        return instance;<br>    }<br><br>    // Example logging method<br>    void log(const string&amp; message) {<br>        cout &lt;&lt; &quot;[LOG]: &quot; &lt;&lt; message &lt;&lt; endl;<br>    }<br>};<br><br>// Static member initialization<br>Logger* Logger::instance = nullptr;<br>mutex Logger::mtx;<br><br>int main() {<br>    // Get Logger instance multiple times<br>    Logger* logger1 = Logger::getInstance();<br>    Logger* logger2 = Logger::getInstance();<br><br>    // Both pointers should point to the same instance<br>    if (logger1 == logger2) {<br>        cout &lt;&lt; &quot;Both logger instances are the same.&quot; &lt;&lt; endl;<br>    } else {<br>        cout &lt;&lt; &quot;Different logger instances created!&quot; &lt;&lt; endl;<br>    }<br><br>    // Using logger<br>    logger1-&gt;log(&quot;Application started&quot;);<br>    logger2-&gt;log(&quot;Logging from same instance&quot;);<br><br>    return 0;<br>}</pre><p><strong>Highlights:</strong></p><ul><li>Only one instance is created.</li><li>Client doesn’t use new directly.</li></ul><p>2: <strong>Eager Initialization (Early Load) Singleton</strong></p><h3>What is Eager Initialization?</h3><blockquote><em>The Singleton instance is created </em><strong><em>at program start</em></strong><em>, not when it is first requested.</em></blockquote><pre>#include &lt;bits/stdc++.h&gt;<br>using namespace std;<br><br>class Logger {<br>private:<br>    // Instance is created at load time (before main())<br>    static Logger* instance;<br><br>    // Private constructor<br>    Logger() {<br>        cout &lt;&lt; &quot;Logger instance created at load time&quot; &lt;&lt; endl;<br>    }<br><br>    // Prevent copy and assignment<br>    Logger(const Logger&amp;) = delete;<br>    Logger&amp; operator=(const Logger&amp;) = delete;<br><br>public:<br>    // Global access point<br>    static Logger* getInstance() {<br>        return instance;<br>    }<br><br>    void log(const string&amp; message) {<br>        cout &lt;&lt; &quot;[LOG]: &quot; &lt;&lt; message &lt;&lt; endl;<br>    }<br>};<br><br>// Instance created eagerly at program start<br>Logger* Logger::instance = new Logger();<br><br>int main() {<br>    // Instance already exists even before this line<br>    Logger* logger = Logger::getInstance();<br>    logger-&gt;log(&quot;Application started&quot;);<br><br>    return 0;<br>}</pre><p>Disadvantages of Eager Initialization<br> 1. Resource Wastage</p><ul><li>Instance is created <strong>even if it is never used</strong></li><li>Bad for heavy objects (DB connection, file logger, network setup)</li></ul><p>2. Slower Application Startup</p><ul><li>Object creation happens <strong>before </strong><strong>main()</strong></li><li>Can increase application startup time</li></ul><p>3. No Lazy Control</p><ul><li>You lose control over <em>when</em> the object is created</li><li>Not ideal when initialization depends on runtime configuration</li></ul><p>4. Harder to Handle Failures</p><ul><li>If constructor throws an error → application may fail during startup</li><li>Debugging becomes difficult</li></ul><h3>When Eager Singleton Is Acceptable</h3><ul><li>Constructor is <strong>very lightweight</strong></li><li>Instance is <strong>always required</strong></li><li>Application startup cost is not critical</li></ul><blockquote><strong>Eager Singleton creates the instance at startup, while Lazy Singleton creates it only when needed — making Lazy initialization more memory and performance efficient.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a16421774265" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Factory Design Pattern]]></title>
            <link>https://medium.com/@nikhilkashyap819/factory-design-pattern-e7998e81b3c2?source=rss-7c1d2cb221e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7998e81b3c2</guid>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[lld]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <dc:creator><![CDATA[Nikhil Kashyap]]></dc:creator>
            <pubDate>Sun, 28 Dec 2025 18:23:25 GMT</pubDate>
            <atom:updated>2025-12-28T18:23:25.990Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0aKBJy0qrJA0woiO0yCgEA.png" /></figure><p><strong>Factory Design Pattern</strong> is a creational design pattern that provides an interface for creating objects, but allows subclasses or factory classes to decide which class to instantiate.</p><p>In Simple Words:</p><p><strong>Factory Design Pattern helps us decouple object creation from the client code by moving the creation logic to a separate factory class.</strong><br>The client only asks for an object , it doesn’t care how or which object is created.</p><p>Let’s take Example of Real World Problem:</p><p>Problem Statement:<br>Imagine we are building a <strong>Notification System</strong> that supports:</p><ul><li>Email</li><li>SMS</li><li>Push Notifications</li></ul><p>Without a factory, the code looks like this:</p><pre>if(type == &quot;EMAIL&quot;) {<br>   new EmailNotification().send();<br>} else if(type == &quot;SMS&quot;) {<br>   new SmsNotification().send();<br>}</pre><h3>Problems</h3><ul><li>Too many if-else conditions</li><li>Violates <strong>Open/Closed Principle</strong></li><li>Hard to maintain and extend</li><li>Tight coupling between client and concrete classes</li></ul><h3>Use Cases (Why Factory?)</h3><ul><li>Payment gateways (UPI, Card, Wallet)</li><li>Notification systems (Email, SMS, Push)</li><li>Logging frameworks</li><li>Database drivers</li><li>Cloud SDKs (AWS, Azure, GCP)</li></ul><p><strong>Simple Factory Pattern<br></strong>A <strong>Simple Factory</strong> uses a single factory class to create objects based on input.</p><pre>#include &lt;iostream&gt;<br>#include &lt;string&gt;<br>using namespace std;<br><br>// Product Interface<br>class Notification {<br>public:<br>    virtual void send() = 0;<br>    virtual ~Notification() {}<br>};<br><br>// Concrete Products<br>class EmailNotification : public Notification {<br>public:<br>    void send() override {<br>        cout &lt;&lt; &quot;Sending Email Notification&quot; &lt;&lt; endl;<br>    }<br>};<br><br>class SmsNotification : public Notification {<br>public:<br>    void send() override {<br>        cout &lt;&lt; &quot;Sending SMS Notification&quot; &lt;&lt; endl;<br>    }<br>};<br><br>// Simple Factory<br>class NotificationFactory {<br>public:<br>    static Notification* createNotification(const string&amp; type) {<br>        if (type == &quot;EMAIL&quot;) return new EmailNotification();<br>        if (type == &quot;SMS&quot;) return new SmsNotification();<br>        return nullptr;<br>    }<br>};<br><br>// Usage<br>int main() {<br>    Notification* n1 = NotificationFactory::createNotification(&quot;EMAIL&quot;);<br>    n1-&gt;send();<br><br>    Notification* n2 = NotificationFactory::createNotification(&quot;SMS&quot;);<br>    n2-&gt;send();<br><br>    delete n1;<br>    delete n2;<br>    return 0;<br>}<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*6jtzir06j3Kf59d14Db1nQ.png" /></figure><h3>Limitation</h3><ul><li>Simple Factory still contains conditional logic</li><li>Not fully extensible</li></ul><h3><strong>Factory Method Pattern (Most Important)</strong></h3><p>The <strong>Factory Method Pattern</strong> defines an interface for creating objects, but lets subclasses decide which class to instantiate.</p><pre>#include &lt;iostream&gt;<br>using namespace std;<br><br>// Product Interface<br>class Notification {<br>public:<br>    virtual void send() = 0;<br>    virtual ~Notification() {}<br>};<br><br>// Concrete Products<br>class EmailNotification : public Notification {<br>public:<br>    void send() override {<br>        cout &lt;&lt; &quot;Sending Email Notification&quot; &lt;&lt; endl;<br>    }<br>};<br><br>class SmsNotification : public Notification {<br>public:<br>    void send() override {<br>        cout &lt;&lt; &quot;Sending SMS Notification&quot; &lt;&lt; endl;<br>    }<br>};<br><br>// Factory Interface<br>class NotificationFactory {<br>public:<br>    virtual Notification* createNotification() = 0;<br>    virtual ~NotificationFactory() {}<br>};<br><br>// Concrete Factories<br>class EmailFactory : public NotificationFactory {<br>public:<br>    Notification* createNotification() override {<br>        return new EmailNotification();<br>    }<br>};<br><br>class SmsFactory : public NotificationFactory {<br>public:<br>    Notification* createNotification() override {<br>        return new SmsNotification();<br>    }<br>};<br><br>// Usage<br>int main() {<br>    NotificationFactory* factory1 = new EmailFactory();<br>    Notification* n1 = factory1-&gt;createNotification();<br>    n1-&gt;send();<br><br>    NotificationFactory* factory2 = new SmsFactory();<br>    Notification* n2 = factory2-&gt;createNotification();<br>    n2-&gt;send();<br><br>    delete n1;<br>    delete n2;<br>    delete factory1;<br>    delete factory2;<br><br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*CKV-jr_iewWSXXONIBzwqQ.png" /></figure><h3>Benefits</h3><ul><li>No if-else</li><li>Follows Open/Closed Principle</li><li>Easy to extend</li><li>Highly used in frameworks</li></ul><h3>Abstract Factory Pattern (Advanced)</h3><p>The <strong>Abstract Factory Pattern</strong> provides an interface to create families of related objects without specifying their concrete classes.</p><h3>Real-World Example</h3><ul><li>AWS Notification Factory</li><li>Firebase Notification Factory</li></ul><pre>#include &lt;iostream&gt;<br>using namespace std;<br><br>// Abstract Products<br>class Email {<br>public:<br>    virtual void send() = 0;<br>    virtual ~Email() {}<br>};<br><br>class Sms {<br>public:<br>    virtual void send() = 0;<br>    virtual ~Sms() {}<br>};<br><br>// Concrete Products (AWS)<br>class AwsEmail : public Email {<br>public:<br>    void send() override { cout &lt;&lt; &quot;AWS Email Sent&quot; &lt;&lt; endl; }<br>};<br><br>class AwsSms : public Sms {<br>public:<br>    void send() override { cout &lt;&lt; &quot;AWS SMS Sent&quot; &lt;&lt; endl; }<br>};<br><br>// Abstract Factory<br>class NotificationFactory {<br>public:<br>    virtual Email* createEmail() = 0;<br>    virtual Sms* createSms() = 0;<br>    virtual ~NotificationFactory() {}<br>};<br><br>// Concrete Factory<br>class AwsNotificationFactory : public NotificationFactory {<br>public:<br>    Email* createEmail() override { return new AwsEmail(); }<br>    Sms* createSms() override { return new AwsSms(); }<br>};<br><br>// Usage<br>int main() {<br>    NotificationFactory* factory = new AwsNotificationFactory();<br>    Email* email = factory-&gt;createEmail();<br>    Sms* sms = factory-&gt;createSms();<br><br>    email-&gt;send();<br>    sms-&gt;send();<br><br>    delete email;<br>    delete sms;<br>    delete factory;<br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*ckfOtzl-GPA--nZ_HqWJPA.png" /></figure><h3>When to Use</h3><ul><li>Large-scale systems</li><li>Multiple product families</li><li>Enterprise applications</li></ul><p>Strategy focuses on choosing an algorithm at runtime, while Factory focuses on creating objects without exposing the instantiation logic to the client.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7998e81b3c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strategy Design Pattern: Why Inheritance Fails and How Strategy Saves Us]]></title>
            <link>https://medium.com/@nikhilkashyap819/strategy-design-pattern-why-inheritance-fails-and-how-strategy-saves-us-0eec6c25c40d?source=rss-7c1d2cb221e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/0eec6c25c40d</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[lld]]></category>
            <dc:creator><![CDATA[Nikhil Kashyap]]></dc:creator>
            <pubDate>Fri, 26 Dec 2025 17:38:01 GMT</pubDate>
            <atom:updated>2025-12-28T18:25:18.395Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-1qhVJY9skxA8BJ3MVo0Q.png" /></figure><h3>Introduction to Design Patterns</h3><p>In real-world software systems, <strong>change is inevitable</strong>. New features are added, requirements evolve, and behaviors vary over time. If our design is rigid, even a small change can ripple through the entire codebase.</p><p>This is where <strong>Design Patterns</strong> help.</p><blockquote>Design Patterns are proven, reusable solutions to recurring software design problems.</blockquote><p>A core idea behind many design patterns is:</p><blockquote>Encapsulate what varies and separate it from what stays the same.</blockquote><p>The <strong>Strategy Design Pattern</strong> is one of the best examples of this idea in action.</p><p>The Common Mistake: Solving Everything with Inheritance</p><blockquote><em>Most developers naturally start with </em><strong><em>inheritance</em></strong><em>.<br>It feels intuitive, clean, and object-oriented.</em></blockquote><p>But inheritance has a hidden limitation.</p><p>Inheritance works well when variation exists in only one dimension.<br>When behavior varies in <strong>multiple dimensions</strong>, inheritance quickly breaks down.<br>Let’s understand this with examples.</p><p>Example 1: Robot System<br>Problem Statement: <br>We are building a <strong>Robot Simulation System</strong>.<br>Different robots may have different abilities:</p><ul><li>Walk / Cannot Walk</li><li>Talk / Cannot Talk</li><li>Fly / Cannot Fly</li></ul><p>Inheritance-Based Design (The Wrong Turn)<br>A typical inheritance-based solution looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*k6RyCZYgaBaO6aFn9Daxug.png" /></figure><h3>What’s Wrong Here?</h3><ol><li><strong>Class explosion: </strong>Each new combination of abilities creates a new subclass.</li></ol><p><strong>2. Poor scalability: </strong>Adding a new ability (e.g., <em>Swim</em>) multiplies the hierarchy.</p><p><strong>3. Violates SOLID principles</strong></p><ul><li>SRP: Robots handle too many responsibilities</li><li>OCP: Existing classes must be modified for new behavior</li></ul><p><strong>Inheritance is growing in multiple dimensions -&gt;</strong>this is the real problem.</p><h3>Key Insight :</h3><blockquote><strong><em>Inheritance models “is-a” relationships.<br>Strategy models “can-do” behaviors.</em></strong></blockquote><p>Robots don’t <em>become</em> walkable or talkable — they <strong>perform</strong> walking or talking.</p><p>This leads us to the <strong>Strategy Pattern</strong>.</p><h3><strong>Introducing the Strategy Design Pattern</strong></h3><p>The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable at runtime.</p><p>Strategy-Based Design (Robot Example)<br>Step 1: Identify the Changing Parts</p><ul><li>Walking behavior</li><li>Talking behavior</li><li>Flying behavior</li></ul><p>Each behavior varies independently.</p><p><strong>Class Diagram — Strategy Pattern (Robot)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*dGdOpIN0gig6TUoqOYZbWg.png" /></figure><h3>Why This Works</h3><p>No inheritance explosion<br>Behaviors are reusable<br>New behavior added without touching existing code<br>Composition over inheritance</p><p>Code Example :</p><pre>#include &lt;bits/stdc++.h&gt;<br>using namespace std;<br><br>// ---------- Walk Strategy ----------<br>class Walkable {<br>public:<br>    virtual void walk() = 0;<br>    virtual ~Walkable() {}<br>};<br><br>class NormalWalk : public Walkable {<br>public:<br>    void walk() override {<br>        cout &lt;&lt; &quot;Walking normally&quot; &lt;&lt; endl;<br>    }<br>};<br><br>class NoWalk : public Walkable {<br>public:<br>    void walk() override {<br>        cout &lt;&lt; &quot;Cannot walk&quot; &lt;&lt; endl;<br>    }<br>};<br><br>// ---------- Talk Strategy ----------<br>class Talkable {<br>public:<br>    virtual void talk() = 0;<br>    virtual ~Talkable() {}<br>};<br><br>class NormalTalk : public Talkable {<br>public:<br>    void talk() override {<br>        cout &lt;&lt; &quot;Talking normally&quot; &lt;&lt; endl;<br>    }<br>};<br><br>class NoTalk : public Talkable {<br>public:<br>    void talk() override {<br>        cout &lt;&lt; &quot;Cannot talk&quot; &lt;&lt; endl;<br>    }<br>};<br><br>// ---------- Fly Strategy ----------<br>class Flyable {<br>public:<br>    virtual void fly() = 0;<br>    virtual ~Flyable() {}<br>};<br><br>class NormalFly : public Flyable {<br>public:<br>    void fly() override {<br>        cout &lt;&lt; &quot;Flying normally&quot; &lt;&lt; endl;<br>    }<br>};<br><br>class NoFly : public Flyable {<br>public:<br>    void fly() override {<br>        cout &lt;&lt; &quot;Cannot fly&quot; &lt;&lt; endl;<br>    }<br>};<br><br>// ---------- Context ----------<br>class Robot {<br>protected:<br>    Walkable* walkable;<br>    Talkable* talkable;<br>    Flyable* flyable;<br><br>public:<br>    Robot(Walkable* w, Talkable* t, Flyable* f)<br>        : walkable(w), talkable(t), flyable(f) {}<br><br>    virtual void projection() = 0;<br><br>    void performWalk() { walkable-&gt;walk(); }<br>    void performTalk() { talkable-&gt;talk(); }<br>    void performFly()  { flyable-&gt;fly(); }<br><br>    virtual ~Robot() {<br>        delete walkable;<br>        delete talkable;<br>        delete flyable;<br>    }<br>};<br><br>// ---------- Concrete Robots ----------<br>class CompanionRobot : public Robot {<br>public:<br>    CompanionRobot()<br>        : Robot(new NormalWalk(), new NormalTalk(), new NoFly()) {}<br><br>    void projection() override {<br>        cout &lt;&lt; &quot;I am a Companion Robot&quot; &lt;&lt; endl;<br>    }<br>};<br><br>class WorkerRobot : public Robot {<br>public:<br>    WorkerRobot()<br>        : Robot(new NormalWalk(), new NoTalk(), new NoFly()) {}<br><br>    void projection() override {<br>        cout &lt;&lt; &quot;I am a Worker Robot&quot; &lt;&lt; endl;<br>    }<br>};<br><br>// ---------- Main ----------<br>int main() {<br>    Robot* companion = new CompanionRobot();<br>    companion-&gt;projection();<br>    companion-&gt;performWalk();<br>    companion-&gt;performTalk();<br>    companion-&gt;performFly();<br><br>    cout &lt;&lt; &quot;-------------------&quot; &lt;&lt; endl;<br><br>    Robot* worker = new WorkerRobot();<br>    worker-&gt;projection();<br>    worker-&gt;performWalk();<br>    worker-&gt;performTalk();<br>    worker-&gt;performFly();<br><br>    delete companion;<br>    delete worker;<br><br>    return 0;<br>}</pre><p>This problem is very common in real systems like payment methods, notification systems, and pricing engines, where behavior changes independently.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0eec6c25c40d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Azure Private Link, Private Endpoint, and Private DNS with a College Analogy]]></title>
            <link>https://medium.com/@nikhilkashyap819/understanding-azure-private-link-private-endpoint-and-private-dns-with-a-college-analogy-8defa1cddec1?source=rss-7c1d2cb221e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8defa1cddec1</guid>
            <category><![CDATA[azure-vnet]]></category>
            <category><![CDATA[azure-private-dns]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[netwroking]]></category>
            <category><![CDATA[azure-private-link]]></category>
            <dc:creator><![CDATA[Nikhil Kashyap]]></dc:creator>
            <pubDate>Fri, 01 Aug 2025 06:15:13 GMT</pubDate>
            <atom:updated>2025-08-01T06:15:13.220Z</atom:updated>
            <content:encoded><![CDATA[<p>When working with Azure networking, concepts like <strong>Private Link</strong>, <strong>Private Endpoint</strong>, and <strong>Private DNS</strong> can be overwhelming at first. But let’s simplify things using a real-world analogy: a <strong>private college</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kcPnE0WqSxYTrYlRw3efVQ.png" /></figure><h3>🏫 The College Analogy</h3><h3>🏫 VNet = Private College</h3><ul><li>A secure space where only authorized people and services can enter.</li></ul><h3>👤 Private Link = Admission Approval System</h3><ul><li>Think of Private Link as the <strong>permission system</strong> that grants students (apps) access to specific departments (Azure services) securely inside the college (VNet).</li></ul><h3>📄 Private Endpoint = Student ID + Gate Pass</h3><ul><li>A <strong>Private Endpoint</strong> is like a <strong>physical ID card</strong> and <strong>gate pass</strong> that gives a specific student the right to enter a certain department.</li><li>It creates a <strong>network interface (NIC)</strong> with a <strong>private IP address</strong> inside your VNet that connects to a specific Azure resource.</li></ul><h3>🛏️ NSG / Firewall = College Watchman</h3><ul><li>Network Security Groups and firewalls are like security guards who validate whether the student with an ID is allowed to go to a certain department or not.</li></ul><h3>📁 What is DNS?</h3><ul><li><strong>DNS (Domain Name System)</strong> is like the college <strong>receptionist</strong> or <strong>student directory</strong>.</li><li>When you ask for a service like mydb.database.windows.net, it tells you the room number (IP address).</li></ul><h3>🌐 Public DNS = Info Booth for Outsiders</h3><ul><li>Anyone can ask for a public domain and be routed to an external (public) IP.</li></ul><h3>🏢 Private DNS Zone = Internal Directory</h3><ul><li>Only accessible from inside the college (your VNet).</li><li>Points domain names to <strong>private IP addresses</strong>.</li></ul><h3>🧬 DNS Resolution = Asking Receptionist for a Room</h3><ul><li>You ask where the DB is. If the receptionist finds a <strong>private DNS entry</strong>, they give you the internal room number.</li><li>Otherwise, you might be sent outside the college.</li></ul><h3>Putting It All Together</h3><p>Let’s say you have a database at mydb.database.windows.net, and you want to access it <strong>privately</strong>:</p><ol><li>You enable <strong>Private Link</strong> on the DB.</li><li>You create a <strong>Private Endpoint</strong> in your VNet.</li><li>Azure assigns it a <strong>private IP</strong> and sets up a DNS entry like:<br>mydb.privatelink.database.windows.net -&gt; 10.1.0.5</li><li>You link a <strong>Private DNS Zone</strong> to your VNet.</li><li>Now when you access mydb.database.windows.net, Azure rewrites it to the private version, and you stay inside the college.</li></ol><h3>Summaries table contents</h3><p>Azure Concept College Analogy Role VNet Private College Secure boundary Private Link Admission system Grants access to services Private Endpoint Student ID + Gate Pass Entry point with private IP NSG / Firewall Watchman Controls traffic Public DNS Info booth for outsiders Public directory Private DNS Zone Internal map/directory Private resolution DNS Resolution Asking receptionist Name to IP translation</p><h3>Why This Matters</h3><p>Understanding these concepts is critical when you’re:</p><ul><li>Accessing Azure PaaS services (like SQL, Storage, PostgreSQL) from AKS or VMs securely.</li><li>Avoiding data exposure to the internet.</li><li>Building enterprise-grade, secure, and compliant architectures.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8defa1cddec1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Design]]></title>
            <link>https://medium.com/@nikhilkashyap819/system-design-3a5c3a4d7ce6?source=rss-7c1d2cb221e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a5c3a4d7ce6</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <dc:creator><![CDATA[Nikhil Kashyap]]></dc:creator>
            <pubDate>Sat, 01 Mar 2025 11:07:34 GMT</pubDate>
            <atom:updated>2025-03-01T11:07:34.529Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*PtIUiAGZ7gAySHcHqfuKtg.jpeg" /></figure><p><strong>System Design: The Importance for Software Engineers</strong></p><p>When we talk about small or large applications, system design helps us build a high-level understanding of the components of an application and their relationships with each other.</p><p>Why do we focus on components? Because to ensure the success of a project, we can divide it into components so that it becomes well-structured, maintainable, scalable, and meets user requirements.</p><p><strong>Now, let’s talk about what system design is.</strong></p><p>In simple terms, system design is an approach by which we structure a system to ensure it meets required functionality, performance, scalability, and other quality attributes.</p><p>It is the process of defining the architecture of components, data, etc., for a system to satisfy both<a href="https://www.geeksforgeeks.org/functional-vs-non-functional-requirements/"> functional (what the system is doing, related to a specific task) and non-functional requirements (how the system should perform, system attributes, or quality attributes)</a>.</p><p><strong>What are the key factors we need to ensure when designing a good system?</strong></p><ul><li>Scalability (both horizontal and vertical)</li><li>Caching</li><li>Load balancing</li><li>Data partitioning</li><li>Various types of databases</li><li>Network protocols</li><li>Database sharding, etc.</li></ul><p><strong>Similarly, we must consider various trade-offs, such as:</strong></p><ul><li>Latency vs throughput</li><li>Performance vs scalability</li><li>Consistency vs availability</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a5c3a4d7ce6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker Fundamentals: Why Containers Are the Solution for Application Deployment]]></title>
            <link>https://medium.com/@nikhilkashyap819/docker-fundamentals-why-containers-are-the-solution-for-application-deployment-4f50918f5094?source=rss-7c1d2cb221e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f50918f5094</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[devtools]]></category>
            <dc:creator><![CDATA[Nikhil Kashyap]]></dc:creator>
            <pubDate>Sat, 23 Nov 2024 06:27:35 GMT</pubDate>
            <atom:updated>2024-11-23T06:27:35.315Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*9Qtcw7XnKdZfEKO-yPxMCg.png" /></figure><p>When it comes to deploying applications, there’s always been a big challenge in traditional methods. Let’s break down why this is an issue, and how <strong>containers</strong>, like Docker, came to solve it.</p><h3><strong>The Problems with Traditional Deployment</strong></h3><p>In the traditional way, developers write code and test it on their local machines. Everything seems to work fine, so they push the code to version control, and from there, it gets promoted through different environments. It’s then sent to the testing environment, where it works with the same setup as the development environment. Everything seems good, and the application passes all the tests.</p><p>But here’s where things start to go wrong. Once the code gets handed off to the operations team and moves into the <strong>production environment</strong>, it <strong>fails</strong>. Suddenly, it’s not working as expected. The developer might scratch their head and say, “But it worked fine on my machine!” Meanwhile, the operations team is left confused and frustrated.</p><p>The problem often lies in the <strong>misconfiguration of environments</strong>. The dependencies, libraries, and settings in production might be slightly different from what was in the developer’s environment. These little differences cause big issues, and sometimes the only way to fix them is by going through a lengthy <strong>change request</strong> process, which can slow everything down.</p><p>This disconnect between development and production is a huge problem that causes unnecessary delays and confusion. And it’s precisely this issue that containers, like Docker, aim to fix.</p><h3><strong>How Containers Help Fix This Problem</strong></h3><p>The issue we face with traditional deployment is that there’s no simple way to pack all the libraries, dependencies, and configurations needed for an application into a single, portable unit. When the application is moved to a different environment, things can break.</p><p>This is where <strong>containers</strong> come into play. A container is an isolated environment that includes everything the application needs to run — the code, the libraries, the dependencies, and the runtime (including the operating system). This means that, regardless of where you run the container — whether it’s on a developer’s machine, a testing server, or in production — it will behave exactly the same. No more “works on my machine” excuses.</p><h3>What Exactly Are Containers?</h3><p>Containers are Isolated Environment.</p><p>All the required Libraries, Application, Binaries, Dependency and Runtime(OS) are encapsulated inside it.</p><p>Containers are like <strong>lightweight sandboxes</strong>. They don’t require an entire operating system like a virtual machine, but they do have everything you need to run an application.</p><p>This means they are fast, portable, and easy to use.</p><p>Containers are isolated from each other, which means you can run multiple containers on the same machine without them interfering with each other.</p><p>This solves the problem of inconsistent environments because everything the application needs is bundled inside the container itself.</p><p>It doesn’t matter where you run it — it will always behave the same way.</p><h3>What Is Docker?</h3><p>Now, let’s talk about <strong>Docker</strong>. Docker is not a container itself — it’s a platform that allows you to build, ship, and run containers.</p><p>Think of Docker as the tool that makes it easy for developers to package up their applications into containers. Docker simplifies the process of managing containers, and it helps ensure that everything runs smoothly, whether you’re working locally, testing in a QA environment, or deploying to production.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f50918f5094" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Serializers in Django REST Framework:]]></title>
            <link>https://medium.com/@nikhilkashyap819/understanding-serializers-in-django-rest-framework-402b862557ea?source=rss-7c1d2cb221e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/402b862557ea</guid>
            <category><![CDATA[serializers]]></category>
            <category><![CDATA[django-rest-framework]]></category>
            <dc:creator><![CDATA[Nikhil Kashyap]]></dc:creator>
            <pubDate>Wed, 23 Oct 2024 19:32:11 GMT</pubDate>
            <atom:updated>2024-10-23T19:32:11.643Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, I learned about serializers in Django REST Framework (DRF) , Serializers are essential for converting complex data types into a format suitable for APIs, such as JSON. Here’s a breakdown of the different types of serializers and their usage.<br>What is a Serializer?</p><p>A serializer acts like a translator between complex data (like database records) and simple formats (like JSON). They help with:</p><ul><li><strong>Data Transformation:</strong> Converting data for API responses.</li><li><strong>Input Validation:</strong> Ensuring incoming data is correct.</li><li><strong>Code Simplification:</strong> Reducing boilerplate code for data handling.</li></ul><h3>Types of Serializers in Django</h3><h4>1. Serializer</h4><p>This is the basic serializer where you define fields manually and here the all three types validators also used.</p><p><strong>Example:<br></strong>from rest_framework import serializers</p><p>#validators</p><p>def alphanumeric(value):</p><p>if not str(value).isalnum():</p><p>raise serializers.ValidationError(&quot;Value must be alphanumeric&quot;)</p><p>class CarSerializer(serializers.Serializer):</p><p>id = serializers.IntegerField(read_only=True)</p><p>name = serializers.CharField()</p><p>description = serializers.CharField()</p><p>active = serializers.BooleanField(read_only=True)</p><p>chassisnumber = serializers.CharField(validators= [alphanumeric])</p><p>price = serializers.DecimalField(max_digits=9, decimal_places=2)</p><p>def create(self, validated_data):</p><p>return CarList.objects.create(**validated_data)</p><p>def update(self, instance, validated_data):</p><p>instance.name = validated_data.get(&#39;name&#39;, instance.name)</p><p>instance.description = validated_data.get(&#39;description&#39;, instance.description)</p><p>instance.active = validated_data.get(&#39;active&#39;, instance.active)</p><p>instance.chassisnumber = validated_data.get(&#39;chassisnumber&#39;,instance.chassisnumber)</p><p>instance.price = validated_data.get(&#39;price&#39;, instance.price)</p><p>instance.save()</p><p>return instance</p><p>#field level validator</p><p>def validate_price(self, value):</p><p>if value &lt;= 20000.00:</p><p>raise serializers.ValidationError(&quot;Price must be greater then 20 k&quot;)</p><p>return value</p><p>#Object level Validation</p><p>def validate(self,data):</p><p>if data[&#39;name&#39;] == data[&#39;description&#39;]:</p><p>raise serializers.ValidationError(&quot;Name and description must not be same&quot;)</p><p>return data</p><h4>2. ModelSerializer</h4><p>This serializer automatically generates fields based on a Django model, making it easier to work with.</p><p><strong>Example:<br></strong>class ReviewSerializer(serializers.ModelSerializer):</p><p>class Meta:</p><p>model=Review</p><p>fields = ‘__all__’</p><h4>3. HyperlinkedModelSerializer</h4><p>Similar to ModelSerializer , but it uses hyperlinks for relationships instead of primary keys.</p><p><strong>Example:<br></strong>class UserHyperlinkedSerializer(serializers.HyperlinkedModelSerializer):<br> class Meta: <br> model = User <br>fields = ‘__all__’</p><h4>4. ListSerializer</h4><p>Used to handle lists of objects, allowing for multiple instances to be serialized at once.</p><p><strong>Example:<br></strong>class UserListSerializer(serializers.ListSerializer):<br> child = UserSerializer() # Use the basic serializer for each user</p><h4>5. Nested Serializers</h4><p>Allows you to include one serializer within another, useful for representing related models.</p><p>Example:<br>class ProfileSerializer(serializers.ModelSerializer):<br> class Meta:<br> model = Profile<br> fields = [‘bio’, ‘location’]</p><p>class UserWithProfileSerializer(serializers.ModelSerializer):<br> profile = ProfileSerializer() # Nested serializer</p><p>class Meta:<br> model = User<br> fields = [‘username’, ‘email’, ‘profile’]</p><h3>Custom Serializers</h3><p>You can also create custom serializers by extending existing ones, adding specific validation or custom logic as needed.</p><p>Example:<br>class CustomUserSerializer(serializers.ModelSerializer):<br> class Meta:<br> model = User<br> fields = [‘username’, ‘email’]</p><p>def validate_email(self, value):</p><p>if ‘<a href="http://twitter.com/example">@example</a>.com’ in value:<br> raise serializers.ValidationError(“Email cannot be from example.com”)<br> return value</p><p>Understanding serializers in Django is crucial for building efficient APIs. They help transform complex data, validate input, and simplify your code.</p><p>I hope this overview helps clarify serializers for you! If you have questions or experiences to share, feel free to comment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=402b862557ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>