<?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[The Distributed Mind - Medium]]></title>
        <description><![CDATA[Where systems think, and minds connect. A home for thinkers who build. The Distributed Mind blends creativity and computation — decoding how modern systems think, grow, and scale. - Medium]]></description>
        <link>https://medium.com/the-distributed-mind?source=rss----46c61e84dfb1---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>The Distributed Mind - Medium</title>
            <link>https://medium.com/the-distributed-mind?source=rss----46c61e84dfb1---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:34:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/the-distributed-mind" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Starting with Low-Level Design (LLD) — First Stop: OOPS Foundations — (DAY 1 &2)]]></title>
            <link>https://medium.com/the-distributed-mind/starting-with-low-level-design-lld-first-stop-oops-foundations-day-1-2-9025b506b5a5?source=rss----46c61e84dfb1---4</link>
            <guid isPermaLink="false">https://medium.com/p/9025b506b5a5</guid>
            <category><![CDATA[oops-concepts]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[sugam]]></category>
            <category><![CDATA[low-level-design]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Sugam Arora]]></dc:creator>
            <pubDate>Fri, 19 Dec 2025 19:21:10 GMT</pubDate>
            <atom:updated>2025-12-19T19:21:08.876Z</atom:updated>
            <content:encoded><![CDATA[<h3>Starting with Low-Level Design (LLD) — First Stop: OOPS Foundations — (DAY 1 &amp;2)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zIFBdhxsi01Cy77O" /></figure><blockquote>Free !! -&gt; <br><a href="https://medium.com/@sugam.arora23/starting-with-low-level-design-lld-first-stop-oops-foundations-day-1-2-9025b506b5a5?sk=2e170be711c24a9c53fd65bc7540c736">https://medium.com/@sugam.arora23/starting-with-low-level-design-lld-first-stop-oops-foundations-day-1-2-9025b506b5a5?sk=2e170be711c24a9c53fd65bc7540c736</a></blockquote><h3>Why LLD First?</h3><p>When we talk about <strong>System Design</strong>, most people immediately think of <strong>huge architectures</strong>: load balancers, sharding, distributed caches, etc. But here’s the catch — <strong>all of that rests on a strong foundation of Low-Level Design (LLD)</strong>.</p><p>Without LLD, high-level design becomes like building skyscrapers on sand.<br> That’s why in this journey, I’m starting with <strong>LLD first</strong> — and the very first milestone is mastering <strong>Object-Oriented Programming (OOPS)</strong>.</p><h3>🏗️ The First Topic in Our Journey: OOPS Fundamentals</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*sg9huONnNoI8h1W0" /></figure><p>In this article, we’ll cover the <strong>four pillars of OOPS</strong>:</p><ol><li><strong>Encapsulation</strong></li><li><strong>Abstraction</strong></li><li><strong>Inheritance</strong></li><li><strong>Polymorphism</strong></li></ol><p>Plus, we’ll also weave in <strong>Composition over Inheritance</strong>, because it’s one of the most important modern perspectives in design.</p><p>This won’t be your usual dry “textbook OOPS” lecture.<br> Instead:</p><ul><li>We’ll use <strong>visual diagrams</strong></li><li><strong>Relatable analogies</strong> from real life</li><li><strong>Step-by-step breakdowns</strong></li><li>And yes, even <strong>a meme</strong></li></ul><p>So by the end, this becomes a <strong>one-stop resource</strong> for anyone who wants to truly <em>understand</em> OOPS — not just cram it.</p><h3>What OOPS is really about !!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*AN6LCIJQrK0QlxV-" /></figure><p><strong>Object-Oriented Programming (OOPS)</strong> is a way of organizing software so it feels like the real world: you model <strong>things</strong> (objects) with <strong>attributes</strong> (data/state) and <strong>behaviors</strong> (methods).</p><ul><li>In a food-delivery app, objects are <strong>User, Restaurant, MenuItem, Cart, Order, Rider</strong>.</li><li>In a ride-hailing app, objects are <strong>Rider, Driver, Ride, Vehicle, Payment</strong>.</li></ul><p>Instead of keeping random functions and global data, OOPS <strong>bundles state + behavior together</strong> so your code becomes easier to reason about, test, and extend.</p><h3>Class vs Object — the blueprint and the thing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*fg7Tbz6DKB7LrQ-r" /></figure><ul><li><strong>Class</strong> = a <strong>blueprint</strong> (recipe/architect’s drawing). It defines <strong>fields</strong> (data) and <strong>methods</strong> (behavior). Basic template for creating objects.</li><li><strong>Object (Instance)</strong> = a <strong>real thing</strong> built from the blueprint, living in memory with its <strong>own state</strong>. Basic run time entities.</li></ul><p>A class is just a <strong>plan</strong>; an object is the <strong>real-world thing</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*P7HjgNPCHqJ5lGcnFdItwg.png" /></figure><blockquote>Real-life analogy you’ll never forget :</blockquote><blockquote><strong>Class</strong>: a <strong>menu</strong> that describes dishes<br><strong>Object</strong>: the <strong>actual dish</strong> delivered to your table<br> Same recipe, many dishes. Same class, many objects.</blockquote><h3>How objects live in memory</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*naGxnWwaUhV3kyCA" /></figure><ul><li><strong>Stack</strong>: where references and local variables live (short-lived).</li><li><strong>Heap</strong>: where <strong>objects</strong> live (created with new).</li><li>A variable like <strong>Car myCar</strong> holds a <strong>reference</strong> (arrow) to an object on the heap</li></ul><pre>Stack                    Heap<br>-----                    ----------------------<br>myCar ────────▶   [Car object: color=&quot;Red&quot;, speed=60]</pre><p>When no references point to an object, <strong>Garbage Collector</strong> eventually frees it. (No manual destructor in Java but not so in other languages.)</p><h3>Constructors and Destructors — The Building Blocks of Objects</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*HqPVtGouVuW4pAY7sHGAcQ.png" /></figure><p>When we talk about <strong>Object-Oriented Programming (OOPS)</strong>, the real magic starts when an object is <em>born</em> (created) and when it <em>dies</em> (destroyed).<br> This lifecycle is managed by two special methods:</p><ul><li><strong>Constructors</strong> → Methods that are automatically called when an object is created. Think of them as the <em>birth certificate + initial setup</em> of an object.</li><li><strong>Destructors</strong> → Methods that are automatically called when an object is destroyed. Think of them as the <em>clean-up crew</em> that ensures everything is wrapped up nicely.</li></ul><h4>What is a Constructor?</h4><p>A <strong>constructor</strong> is a special method in a class that is invoked automatically when an object of that class is created.</p><blockquote>Imagine moving into a new apartment. When you enter for the first time, the landlord ensures:</blockquote><blockquote>The lights are working.</blockquote><blockquote>Water supply is connected.</blockquote><blockquote>Keys are handed over.</blockquote><blockquote>That initial setup = Constructor.</blockquote><h4>Key Features of Constructors</h4><ol><li>Same name as the class.</li><li>No return type (not even void)</li><li>Called automatically when an object is created.</li><li>Can be <strong>overloaded</strong> (multiple constructors with different parameters).</li></ol><h4>Types of Constructors</h4><p>Different languages provide slightly different flavors, but broadly we have:</p><h4>1. Default Constructor</h4><ul><li>Provided automatically by the compiler if you don’t define any constructor.</li><li>Initializes objects with default values.</li></ul><pre>class Student {<br>    String name;<br>    int age;<br><br>    // Default constructor<br>    Student() {<br>        name = &quot;Unknown&quot;;<br>        age = 0;<br>        System.out.println(&quot;Default constructor called!&quot;);<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        Student s1 = new Student(); // default constructor called<br>        System.out.println(s1.name + &quot; &quot; + s1.age);<br>    }<br>}</pre><p>Buying a plain pizza with no toppings when you don’t specify anything. The restaurant gives you a “default” one.</p><h4>2. Parameterized Constructor</h4><ul><li>Allows passing parameters during object creation.</li><li>Helps initialize objects with custom values.</li></ul><pre>class Student {<br>    String name;<br>    int age;<br><br>    // Parameterized constructor<br>    Student(String n, int a) {<br>        name = n;<br>        age = a;<br>        System.out.println(&quot;Parameterized constructor called!&quot;);<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        Student s1 = new Student(&quot;Sugam&quot;, 22);<br>        System.out.println(s1.name + &quot; &quot; + s1.age);<br>    }<br>}</pre><p>Ordering a pizza with your favorite toppings. You tell the chef what you want → they prepare accordingly.</p><h4>3. Copy Constructor (C++ mainly, but concept exists everywhere)</h4><ul><li>Creates a new object as a copy of another object.</li></ul><p><strong>Java Equivalent (since Java doesn’t have a true copy constructor):</strong></p><pre>class Student {<br>    String name;<br>    int age;<br><br>    Student(String n, int a) {<br>        name = n;<br>        age = a;<br>    }<br><br>    // Copy constructor<br>    Student(Student s) {<br>        name = s.name;<br>        age = s.age;<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        Student s1 = new Student(&quot;Sugam&quot;, 22);<br>        Student s2 = new Student(s1); // copy constructor<br>        System.out.println(s2.name + &quot; &quot; + s2.age);<br>    }<br>}</pre><p>Duplicating a Google Doc. You get the same content, but it’s a new file.</p><h4>4. Private Constructor</h4><ul><li>Used when you want to restrict object creation.</li><li>Commonly used in <strong>Singleton Design Pattern</strong>.</li></ul><pre>class Singleton {<br>    private static Singleton instance;<br><br>    private Singleton() {<br>        System.out.println(&quot;Private constructor called!&quot;);<br>    }<br><br>    public static Singleton getInstance() {<br>        if (instance == null) {<br>            instance = new Singleton();<br>        }<br>        return instance;<br>    }<br>}</pre><p>Think of the President’s chair. Only one person can sit there at a time.</p><h4>What is a Destructor?</h4><p>A <strong>destructor</strong> is a special method automatically invoked when an object is destroyed or goes out of scope.<br> Its main job is to <strong>release resources</strong>, such as memory, file handles, or database connections.</p><p>Leaving a hotel room → you switch off the lights, return the key, clear the minibar.</p><h4>Lifecycle of an Object</h4><ol><li>Object Created → <strong>Constructor called</strong> (birth).</li><li>Object Used → Methods perform operations (life).</li><li>Object Out of Scope/Destroyed → <strong>Destructor called</strong> (death).</li></ol><p><strong>Diagram</strong></p><pre> [Object Creation] → [Constructor → Initialization] → [Object in Use] → [Destructor → Cleanup] → [Memory Released]</pre><h4>Why Should We Care About Constructors &amp; Destructors?</h4><ul><li>They ensure <strong>safe object initialization</strong> (no half-baked objects).</li><li>They provide <strong>clean memory management</strong>.</li><li>They form the foundation of <strong>robust OOP design</strong>.</li><li>Used heavily in <strong>design patterns</strong> (Singleton, Factory, Builder).</li></ul><h3>Breaking Down a Class: The Essential Building Blocks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*PUbyiom04de-oAVAPqNh8w.png" /></figure><p>Before diving into Encapsulation, Abstraction, Inheritance, and Polymorphism, let’s <strong>truly understand what makes up a class</strong></p><p>In programming terms AS YOU KNOW A <strong>class</strong> is the <strong>blueprint and object</strong> is the <strong>house built from the blueprint</strong>. While <strong>constructor</strong> is like the <strong>construction process</strong> (decides how your house looks initially) and <strong>destructor</strong> (in some languages) is like the <strong>demolition process</strong> (what happens when the house is no longer needed). Now let’s break down the <strong>core parts of a class</strong>, one by one.</p><p><strong>1️⃣ Class Declaration</strong> : Every language has its own syntax, but the idea is the same: you define a new “type”.</p><pre>public class Car {<br>    // body of the class<br>}</pre><p>Declaring a class is like saying <em>“I want to design a new model of car — here’s the blueprint folder</em></p><p><strong>2️⃣ Fields / Attributes (Data Members) : </strong>These are the <strong>characteristics or properties</strong> that each object will have.</p><pre>public class Car {<br>    String color;<br>    int maxSpeed;<br>}</pre><p>Think of them as the <strong>features on a car brochure</strong> — color, horsepower, number of seats</p><blockquote><strong>Across Languages</strong>:<br>In <strong>Python</strong>, attributes are defined in __init__().<br>In <strong>C++/Java</strong>, fields are part of the class body.<br>In <strong>C#</strong>, you often see properties with getters/setters</blockquote><h4>3️⃣ Methods (Behavior)</h4><p>These are the <strong>actions your object can perform</strong>.</p><pre>public class Car {<br>    String color;<br>    int maxSpeed;<br>    void drive() {<br>        System.out.println(&quot;Car is driving...&quot;);<br>    }<br>}</pre><p>If fields are <em>what a car </em><strong><em>is</em></strong>, methods are <em>what a car </em><strong><em>can do</em></strong> — like <em>drive</em>, <em>brake</em>, or <em>honk</em>.</p><h4>4️⃣ Constructors</h4><p>Constructors decide <strong>how your object is created</strong> and <strong>initialized</strong>.</p><pre>public class Car {<br>    String color;<br>    int maxSpeed;<br>    // Default constructor<br>    public Car() {<br>        color = &quot;White&quot;;<br>        maxSpeed = 120;<br>    }   <br>    // Parameterized constructor<br>    public Car(String color, int maxSpeed) {<br>        this.color = color;<br>        this.maxSpeed = maxSpeed;<br>    }<br>}</pre><blockquote>Constructors are like choosing <strong>which showroom package</strong> of a car you want:</blockquote><blockquote>Default = <em>basic model, white color</em>.<br>Parameterized = <em>custom order, red color, 200 km/h</em>.<br>Copy = <em>duplicate my friend’s exact car.</em></blockquote><h4>5️⃣ Destructors</h4><p>Not all languages use destructors the same way:</p><ul><li><strong>C++</strong>: Supports explicit destructors using ~ClassName().</li><li><strong>Java</strong>: Doesn’t have destructors. It has a <strong>Garbage Collector</strong> that handles memory cleanup automatically. You can override finalize(), but it’s deprecated now.</li><li><strong>Python</strong>: Has __del__() method that acts like a destructor.</li></ul><pre>class Car {<br>public:<br>    ~Car() {<br>        cout &lt;&lt; &quot;Car object destroyed&quot;;<br>    }<br>};</pre><p>Destructors are like <strong>scrapping your car when it’s old</strong> — cleanup before it’s gone.</p><h4>6️⃣ Access Modifiers</h4><p>These define <strong>how much of your class is visible</strong> to the outside world.</p><pre>public class Car {<br>    private String engineNumber; // hidden<br>    public String color; // visible to all<br>}</pre><blockquote><strong>Public</strong>: Open to everyone.<br><strong>Private</strong>: Hidden inside the class.<br><strong>Protected</strong>: Accessible to sub-classes.<br><strong>Default / Internal</strong>: Package or module level access (Java/Python have slight variations).</blockquote><p>Imagine <strong>car compartments</strong>:</p><ul><li>Public = glove box anyone can open.</li><li>Private = secret locker only you know.</li><li>Protected = only family members know the code.</li></ul><h4>7️⃣ Static Members</h4><p>Static members belong to the <strong>class itself, not to any individual object</strong>.</p><pre>public class Car {<br>    static int numberOfCarsProduced = 0;<br>}</pre><p>A static member is like company-wide data — e.g., total number of cars sold globally. Not tied to one specific car.</p><h4><strong>8️⃣ Nested / Inner Classes</strong></h4><p>A class defined inside another class. Used for <strong>logical grouping</strong>.</p><pre>public class Car {<br>    class Engine {<br>        void start() {<br>            System.out.println(&quot;Engine started...&quot;);<br>        }<br>    }<br>}</pre><p>Think of the <strong>engine</strong> as a component that belongs to the car, but still has its own design.</p><h4>9️⃣ Keywords That Define Behavior</h4><p>Some important terms across languages:</p><ul><li><strong>Abstract Classes</strong>: Blueprint but incomplete (cannot be instantiated).</li><li><strong>Interfaces</strong>: Contracts of what a class must do.</li><li><strong>Final (Java)/Sealed (C#)</strong>: Class cannot be extended.</li><li><strong>Virtual (C++) / Override (C#)</strong>: Enables polymorphism.</li></ul><h3>The Four Pillars of OOPS and Beyond</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*EbjmSjjTgDXERXIl" /></figure><p>We’ve already broken down <strong>classes</strong> as the blueprint. Now let’s step into the <strong>soul of OOPS</strong> — the principles that make objects not just data buckets, but <em>living, breathing entities in code</em></p><h4>1. Encapsulation — <em>The Art of Keeping Secrets</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*KIhzB6FCsjoWXU6a" /></figure><p>Encapsulation is about wrapping data (variables) and methods (functions) together into a single unit (class) and restricting direct access to some components. Think of it as a <strong>capsule of medicine</strong>: you can’t touch what’s inside directly, you just swallow the capsule and it does its job</p><p><strong>Example :</strong> Imagine your <strong>ATM machine</strong>. You don’t know how the ATM validates your PIN or communicates with the bank. You just <em>enter your PIN and press withdraw</em>. The internal details are <strong>encapsulated</strong>, hidden from you.</p><h3>Types of Encapsulation:</h3><ol><li><strong>Data Encapsulation</strong></li></ol><ul><li>Binding the variables (state) with methods (behavior).</li><li>Example: A BankAccount has balance (data) and deposit() / withdraw() (methods).</li></ul><p><strong>2. Information Hiding</strong></p><ul><li>Controlling <em>who</em> can access <em>what</em>.</li><li>Achieved using <strong>access modifiers</strong> (private, protected, public).</li><li>Example: Your bank balance isn’t visible to everyone; only the bank’s system and you can see it.</li></ul><p><strong>3. Functional Encapsulation</strong></p><ul><li>Wrapping logic in reusable functions/methods.</li><li>Example: Instead of rewriting calculateInterest(), you encapsulate it in a method and reuse it.</li></ul><p><strong>Technical Perspective :<br></strong>Achieved using access modifiers :<br><strong>private</strong> -&gt; hidden, only accessible within class<br><strong>protected</strong> -&gt; accessible within class &amp; subclasses<br><strong>public</strong> -&gt; accessible from anywhere</p><pre>class BankAccount {<br>    private double balance;  // encapsulated data<br><br>    // getter<br>    public double getBalance() {<br>        return balance;<br>    }<br><br>    // setter<br>    public void deposit(double amount) {<br>        if(amount &gt; 0) balance += amount;<br>    }<br>}</pre><p>Here as you can see the <strong>balance</strong> is hidden. You can’t directly modify it and you must use controlled functions (deposit, getBalance here)</p><h4>2. Abstraction — <em>The Art of Showing Only What’s Necessary</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*dc3V0whkn-o7wGI-" /></figure><p>Abstraction means exposing only the <strong>relevant details</strong> and hiding the internal complexity.<br><strong>Data Abstraction</strong></p><ul><li>Exposing only essential attributes.</li><li>Example: You don’t see <em>how</em> balance is stored internally, you just call getBalance().</li></ul><p><strong>Control Abstraction</strong></p><ul><li>Hiding complex control flows behind methods.</li><li>Example: Java’s Collections.sort() hides sorting algorithm complexity.</li></ul><p><strong>Implementation Abstraction</strong></p><ul><li>Hiding actual logic, exposing only an interface.</li><li>Example: Interface Database with connect() method.MySQL and MongoDB classes implement it differently.</li></ul><p>Think about <strong>driving a car</strong>. You just use the <em>steering wheel, accelerator, brake</em>. You don’t care about how combustion happens inside the engine. That’s abstraction</p><pre>abstract class Payment {<br>    abstract void pay(int amount);<br>}<br><br>class CreditCardPayment extends Payment {<br>    void pay(int amount) {<br>        System.out.println(&quot;Paid &quot; + amount + &quot; using Credit Card&quot;);<br>    }<br>}</pre><p>Here Payment is abstract; it just says “you must pay”. The actual implementation is left to subclasses.</p><h4><strong>Bonus:</strong></h4><p>When we’re designing software, we often face the question: <em>Should I use an abstract class or an interface?</em><br> Both are ways to define <strong>contracts</strong> for how classes should behave, but they serve slightly different purposes.</p><h4>Firstly the Basics -&gt;</h4><h4>Abstract Class</h4><ul><li>A class that <strong>cannot be instantiated directly</strong>.</li><li>It can have:</li></ul><p><strong>a) Abstract methods</strong> (methods with no body).<br><strong>b) Concrete methods</strong> (methods with an actual implementation).<br><strong>c) Member variables</strong>.</p><ul><li>Think of it as a <strong>partially built house</strong> — it has a structure, maybe some walls, but leaves the rest for subclasses to finish.</li></ul><h3>Interface</h3><ul><li>A <strong>pure contract</strong> — it defines <em>what a class must do</em> but not <em>how</em>.</li><li>It can only have method signatures (before Java 8), but now can also include <strong>default methods</strong> and <strong>static methods</strong>.</li><li>No state (instance variables) in most languages.</li><li>Think of it as a <strong>house blueprint</strong> — you can’t live in a blueprint, but you can follow it to build a house.</li></ul><p><strong>Abstract Class</strong> = A <strong>template</strong>.<br> Example: Vehicle is an abstract class. Every vehicle has wheels, an engine, and a way to start. But the exact implementation of start() may differ (a car starts with a key, a bike may use a button, an electric scooter may use an app).</p><p><strong>Interface</strong> = A <strong>set of promises</strong>.<br> Example: Drivable is an interface. Anything that can be driven (Car, Bike, Drone, even a TeslaBot) must implement the drive() method. It doesn’t care <em>how</em>—only that the class provides a way to drive.</p><pre>// Abstract Class Example<br>abstract class Vehicle {<br>    int wheels;<br>    <br>    Vehicle(int wheels) {<br>        this.wheels = wheels;<br>    }<br>    <br>    abstract void start(); // abstract method<br>    <br>    void showWheels() { // concrete method<br>        System.out.println(&quot;This vehicle has &quot; + wheels + &quot; wheels.&quot;);<br>    }<br>}<br><br>class Car extends Vehicle {<br>    Car() {<br>        super(4);<br>    }<br>    void start() {<br>        System.out.println(&quot;Car starts with a key.&quot;);<br>    }<br>}<br><br>// Interface Example<br>interface Drivable {<br>    void drive();<br>}<br><br>class Bike implements Drivable {<br>    public void drive() {<br>        System.out.println(&quot;Bike is being driven with balance.&quot;);<br>    }<br>}</pre><p>Use <strong>Abstract Class</strong> when:</p><ul><li>You want to share <strong>state (fields)</strong> or <strong>common code</strong> across related classes.</li><li>You want subclasses to have some default behavior but still enforce some methods to be defined</li><li>Example: PaymentMethod as an abstract class for CreditCardPayment, UPIPayment, etc.</li></ul><p>Use <strong>Interface</strong> when:</p><ul><li>You just need to enforce a <strong>capability/contract</strong> across <em>unrelated classes</em>.</li><li>Example: Printable can be implemented by Book, Invoice, Image — all totally different things.</li></ul><pre>          Abstract Class (Vehicle)<br>              /            \<br>         Car (concrete)    Truck (concrete)<br>         <br>          Interface (Drivable)<br>              /     |      \<br>          Car     Bike    Drone</pre><p><strong>Abstract classes</strong> give you a foundation + partial implementation for <em>related</em> classes.<br> <strong>Interfaces</strong> let you enforce rules across <em>unrelated</em> classes.</p><p>Together, they provide the flexibility to design systems that are both <strong>organized</strong> and <strong>extensible</strong>.</p><p>In short:</p><ul><li><strong>Abstract class = What you are</strong></li><li><strong>Interface = What you can do</strong></li></ul><h4><strong>3. Inheritance — <em>The Family Tree of OOPS</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*z-992awZ_vL6QBTM" /></figure><p>Inheritance allows one class (child) to acquire properties and methods of another (parent).</p><p>Think about a family . You inherit traits from your parents(eye color , habits etc) . Similarly a class inherits attributes from another.</p><p><strong>Types:</strong></p><p><strong>a) Single Inheritance: <br>What:</strong> A class extends exactly one parent.<br> <strong>When:</strong> Clear, strict <em>is-a</em> relationship; you want to reuse and specialize behavior.</p><pre>Vehicle<br>  │<br>  └── Car</pre><pre>class Vehicle {<br>    void move() { System.out.println(&quot;Vehicle moving&quot;); }<br>}<br><br>class Car extends Vehicle {<br>    void honk() { System.out.println(&quot;Beep!&quot;); }<br>}<br><br>Vehicle v = new Car();  // polymorphism still works<br>v.move();               // &quot;Vehicle moving&quot;<br>// v.honk(); // not visible via Vehicle reference</pre><p><strong>b) Multilevel:<br>What:</strong> Inheritance across multiple levels: grandparent → parent → child.<br> <strong>When:</strong> You need a <strong>progressive specialization</strong>.</p><pre>Vehicle<br>  │<br>  └── Car<br>        │<br>        └── ElectricCar</pre><pre>class Vehicle { void move() {} }<br>class Car extends Vehicle { void refuel() {} }<br>class ElectricCar extends Car {<br>    @Override void refuel() { System.out.println(&quot;Charge battery&quot;); }<br>}</pre><p><strong>c) Hierarchical:<br>What:</strong> Many children share the same parent.<br> <strong>When:</strong> You want a common API/contract and utilities in the parent, with specialized behavior in each child.</p><pre>            Payment<br>           /   |    \<br>     CardPay  Upi   WalletPay</pre><pre>abstract class Payment {<br>    abstract void pay(long paise);<br>    void audit() { System.out.println(&quot;Audit trail...&quot;); }<br>}<br><br>class CardPayment extends Payment {<br>    @Override void pay(long paise) { System.out.println(&quot;Card paid: &quot; + paise); }<br>}<br>class UpiPayment extends Payment {<br>    @Override void pay(long paise) { System.out.println(&quot;UPI paid: &quot; + paise); }<br>}</pre><p><strong>d) Multiple Inheritance:</strong></p><p><strong>What:</strong> A class inherits from <strong>more than one</strong> parent class.</p><ul><li><strong>C++ / Python:</strong> Supported (with diamond rules).</li><li><strong>Java / C#:</strong> <strong>Not</strong> for classes. You can implement <strong>multiple interfaces</strong> (and with Java default methods you can share behavior).</li></ul><pre>    A (Base)<br>   / \<br>  B   C<br>   \ /<br>    D</pre><pre>interface Clickable { default void act(){ System.out.println(&quot;click&quot;); } }<br>interface Focusable { default void act(){ System.out.println(&quot;focus&quot;); } }<br><br>class Button implements Clickable, Focusable {<br>    @Override public void act() { // must resolve conflict explicitly<br>        Clickable.super.act();<br>        Focusable.super.act();<br>        System.out.println(&quot;button logic&quot;);<br>    }<br>}</pre><p><strong>e) Hybrid:</strong></p><p><strong>What:</strong> A <strong>combination</strong> of hierarchical, multilevel, and/or multiple inheritance.</p><p>Typical in C++/Python:</p><ul><li>A common base type, branched children, and a subclass that also inherits from another branch or mixin.</li></ul><p>Java flavor (no MI of classes):</p><ul><li>Base abstract class + hierarchy, plus <strong>interfaces</strong> used as “mixins” for extra capabilities.</li></ul><pre>        Media (abstract)<br>        /      |      \<br>   Video    Audio     Image<br>      \       |         |<br>     Streamable (interface)<br>          \     |     /<br>             LiveStream</pre><pre>interface Streamable { void startStream(); }<br><br>abstract class Media { abstract void play(); }<br><br>class Video extends Media implements Streamable {<br>    @Override void play() { System.out.println(&quot;Play video&quot;); }<br>    @Override public void startStream() { System.out.println(&quot;Live video stream&quot;); }<br>}<br><br>class Audio extends Media implements Streamable {<br>    @Override void play() { System.out.println(&quot;Play audio&quot;); }<br>    @Override public void startStream() { System.out.println(&quot;Live audio stream&quot;); }<br>}</pre><h4>4. Polymorphism — <em>One Face, Many Forms</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*9H0YyeYuaxYU_OJ6" /></figure><p>Polymorphism allows the same method to behave differently depending on the context.</p><p>You smartphone’s “Home Button”:</p><ul><li>On single tap → goes home</li><li>On double tap → opens recent apps</li><li>On long press → launches assistant<br> Same button → multiple behaviors</li></ul><h4>Types</h4><ol><li><strong>Compile-time Polymorphism</strong> (Function Overloading, Operator Overloading)<br>Decision made at compile-time.<br><strong>Function Overloading (Compile-time)</strong> : Same method name, different parameter list</li></ol><pre>class MathUtil {<br>    int add(int a, int b) { return a+b; }<br>    double add(double a, double b) { return a+b; }<br>}</pre><p><em>Operator Overloading(C++, not Java):</em><br> Example: <strong>+</strong> operator used for both numbers and strings.</p><p><strong>2. Runtime Polymorphism</strong> (Function Overriding, Virtual Functions, Dynamic Dispatch) — Decision made at runtime using overriding.<br><strong>Function Overriding (Runtime) : </strong>Subclass provides its own version of a method.</p><pre>class Animal {<br>    void sound() { System.out.println(&quot;Animal sound&quot;); }<br>}<br>class Dog extends Animal {<br>    void sound() { System.out.println(&quot;Bark&quot;); }<br>}<br>Animal a = new Dog();<br>a.sound(); // Bark (runtime decision)</pre><h3><strong>Composition over Inheritance: A Modern Perspective</strong></h3><p>When we first learn OOP, inheritance feels like the superpower — just extend a parent class and you instantly get its properties and behavior. But as systems grow, inheritance often creates rigid hierarchies that are hard to modify or extend without breaking things.</p><p>That’s where <strong>Composition over Inheritance</strong> comes in. Instead of saying <em>“This class is a type of that class”</em> (inheritance), composition says <em>“This class has that behavior or functionality inside it.”</em></p><ul><li><strong>Inheritance</strong> = “is-a” relationship</li><li><strong>Composition</strong> = “has-a” relationship</li></ul><h3>Why Composition Is Preferred</h3><ol><li><strong>Flexibility</strong>: You can mix and match behaviors without being tied to one rigid parent.</li><li><strong>Avoids Fragile Hierarchies</strong>: Changes in base classes won’t ripple across dozens of subclasses.</li><li><strong>Follows SOLID Principles</strong>: Especially the <em>Single Responsibility</em> and <em>Open-Closed Principle</em>.</li><li><strong>Promotes Reusability</strong>: Small components can be reused across multiple classes.</li></ol><p>Think of a <strong>Car</strong>.</p><ul><li>With <strong>inheritance</strong>, you might say: <em>“SportsCar extends Car”</em> → which works, but what if tomorrow you want to add ElectricCar, SUV, or HybridCar? You keep piling on subclasses.</li><li>With <strong>composition</strong>, you instead say:</li></ul><p>A Car <strong>has</strong> an Engine.<br>A Car <strong>has</strong> a MusicSystem.<br>A Car <strong>has</strong> Wheels.</p><p>Now you can build a SportsCar by plugging in a <strong>TurboEngine</strong> and a <strong>PremiumMusicSystem</strong>, or an ElectricCar by plugging in a <strong>BatteryPack</strong> instead of a traditional engine. Much cleaner, much easier to extend.</p><pre>// Composition Example<br>class Engine {<br>    void start() {<br>        System.out.println(&quot;Engine starts...&quot;);<br>    }<br>}<br><br>class MusicSystem {<br>    void playMusic() {<br>        System.out.println(&quot;Playing music...&quot;);<br>    }<br>}<br><br>class Car {<br>    private Engine engine;<br>    private MusicSystem musicSystem;<br><br>    Car(Engine engine, MusicSystem musicSystem) {<br>        this.engine = engine;<br>        this.musicSystem = musicSystem;<br>    }<br><br>    void startCar() {<br>        engine.start();<br>        musicSystem.playMusic();<br>        System.out.println(&quot;Car is ready to go!&quot;);<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        Engine turboEngine = new Engine();<br>        MusicSystem bose = new MusicSystem();<br>        <br>        Car sportsCar = new Car(turboEngine, bose);<br>        sportsCar.startCar();<br>    }<br>}</pre><h3>More Advanced OOPS Concepts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*QHNo9eCznILquxjd" /></figure><p>Once you’ve mastered the foundational pillars of Object-Oriented Programming, the real magic begins with its advanced concepts. These ideas — ranging from runtime polymorphism and operator overloading to deep copies and dynamic constructors — are what truly separate beginner-level code from professional, production-grade software. They not only refine how we design classes but also empower us to build efficient, reusable, and flexible systems</p><p><strong>Virtual Functions &amp; vtable / vptr (C++ concept)</strong></p><ul><li>When a function is declared virtual, it enables <strong>runtime method dispatch</strong>.</li><li><strong>vtable</strong> = virtual table storing addresses of overridden functions.</li><li><strong>vptr</strong> = hidden pointer each object carries to refer to its class vtable.</li><li>Think of vtable like a <strong>restaurant menu</strong>, and vptr is your <strong>personal waiter</strong> pointing to the right dish (method).</li></ul><h4>Getters and Setters</h4><p>Encapsulation mechanism to control access.</p><h4>Static Variables and Functions:</h4><ul><li><strong>Static Variable</strong>: Shared across all objects.</li><li><strong>Static Function</strong>: Belongs to class, not object.</li></ul><h4>Operator Overloading (C++)</h4><p>Allow operators to behave differently for objects.</p><pre>class Complex {<br>    int real, imag;<br>public:<br>    Complex(int r=0, int i=0): real(r), imag(i) {}<br>    Complex operator + (Complex const &amp;obj) {<br>        return Complex(real + obj.real, imag + obj.imag);<br>    }<br>};</pre><h4>Deep Copy vs Shallow Copy</h4><ul><li><strong>Shallow Copy</strong> → Copies references, not actual data</li><li><strong>Deep Copy</strong> → Creates an entirely new copy of data</li></ul><h4>Dynamic Constructors</h4><p>Constructors that allocate memory at runtime.</p><pre>class String {<br>    char* str;<br>public:<br>    String(const char* s) {<br>        str = new char[strlen(s)+1];<br>        strcpy(str, s);<br>    }<br>};</pre><h3><strong>Conclusion</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*UidFNjMVVL-bxGvN" /></figure><p>Object-Oriented Programming is not just a paradigm; it’s a way of thinking about software as a living, evolving ecosystem of objects that interact with each other. From the four pillars — encapsulation, inheritance, abstraction, and polymorphism — to the more advanced mechanisms like virtual functions, operator overloading, and dynamic constructors, OOPS equips us with the tools to design systems that are scalable, maintainable, and intuitive. At its heart, OOPS mirrors the real world: just as people, things, and relationships shape our daily lives, classes, objects, and their interactions shape the software we build. Mastering these concepts doesn’t just make you a better programmer — it makes you a better problem-solver, capable of modeling complex realities into elegant, functioning code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*Xeo-HB8XHjUKGP6Y.jpg" /></figure><p><em>Written by Sugam Arora — on a mission to make System Design human.</em></p><p><em>Thank you for taking the time to read my blog. Your feedback is immensely valuable to me. Please feel free to share your thoughts and suggestions</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9025b506b5a5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-distributed-mind/starting-with-low-level-design-lld-first-stop-oops-foundations-day-1-2-9025b506b5a5">Starting with Low-Level Design (LLD) — First Stop: OOPS Foundations — (DAY 1 &amp;2)</a> was originally published in <a href="https://medium.com/the-distributed-mind">The Distributed Mind</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing and Configuring SonarQube on AWS EC2: A Step-by-Step Guide]]></title>
            <link>https://medium.com/the-distributed-mind/installing-and-configuring-sonarqube-on-aws-ec2-a-step-by-step-guide-defd8955eb30?source=rss----46c61e84dfb1---4</link>
            <guid isPermaLink="false">https://medium.com/p/defd8955eb30</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[sonarqube]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[sugam-arora]]></category>
            <dc:creator><![CDATA[Sugam Arora]]></dc:creator>
            <pubDate>Fri, 10 Oct 2025 16:05:36 GMT</pubDate>
            <atom:updated>2025-10-10T16:05:32.077Z</atom:updated>
            <content:encoded><![CDATA[<p>Unlock the full potential of your codebase with SonarQube on AWS EC2 — a seamless blend of cutting-edge technology and cloud scalability, ensuring your software reaches new heights of quality and performance.</p><p>Free !! -&gt;</p><blockquote><a href="https://medium.com/@sugam.arora23/installing-and-configuring-sonarqube-on-aws-ec2-a-step-by-step-guide-defd8955eb30?sk=ebf09ba0129d0c74d4fca6fa80a99d66">https://medium.com/@sugam.arora23/installing-and-configuring-sonarqube-on-aws-ec2-a-step-by-step-guide-defd8955eb30?sk=ebf09ba0129d0c74d4fca6fa80a99d66</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*TAaE0CLjuKUV2XFLxZErdA.png" /></figure><h3>Introduction</h3><p>SonarQube is a powerful tool for ensuring code quality, providing developers with detailed insights into code issues and vulnerabilities. By installing and configuring SonarQube on AWS EC2, you can leverage the scalability and flexibility of the cloud to enhance your software development process. This guide will walk you through the step-by-step process of setting up SonarQube on an AWS EC2 instance, empowering you to deliver high-quality code with confidence.</p><h3>Specifications</h3><ol><li>Ubuntu 22.04 / 20.04 LTS</li><li>CPU : 2 vCPU</li><li>Volume : 20 GB</li><li>RAM : 4 GB</li><li>Security Ports (shown below)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HL7GbiVcEgJF4HBXoLi2zg.png" /></figure><blockquote><strong>NOTE :</strong> The specifications provided are the minimum; however, feel free to increase them according to your needs.</blockquote><h4><strong>Step 1 : Ubuntu EC2 Instance: Command-Line Gateway Unlocked</strong></h4><p>a) Connect to an AWS EC2 Ubuntu server using SSH</p><pre>chmod 600 &quot;key-pair-file&quot;<br>ssh -i &quot;key-pair-file&quot; ubuntu@ec2-Public-IP.ap-south-1.compute.amazonaws.com</pre><p>Now, you are in your instance.</p><p>b) In the instance firstly we need to upgrade and update the packages</p><pre>sudo apt update<br>sudo apt upgrade -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vras9FWBlQj13-AjWuBX1Q.png" /><figcaption>update</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XcubH33-1-I9SntCnm5i0Q.png" /><figcaption>upgrade</figcaption></figure><p><strong>Step 2 : Effortless Installation: Java and PostgreSQL Made Simple!</strong></p><p>a) To unlock the full potential of the latest SonarQube version, ensure you have OpenJDK 17 installed.</p><pre>sudo apt install -y openjdk-17-jdk</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kvuUU4zVwKVrh1o9SrlVA.png" /><figcaption>java installation</figcaption></figure><p>b) It’s crucial to verify the installed Java version.</p><pre>java -version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*kfSCpOP-pACSo-S9sQqsLA.png" /><figcaption>java version check</figcaption></figure><p>c) To install and configure PostgreSQL, start by adding the PostgreSQL repository.</p><pre>sudo sh -c &#39;echo &quot;deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main&quot; /etc/apt/sources.list.d/pgdg.list&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uwVQvBQCoM26BrTAcv-n9Q.png" /><figcaption>PostgreSQL repo</figcaption></figure><p>d) To proceed with installing and configuring PostgreSQL, add the PostgreSQL signing key.</p><pre>wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t9qeHciVEYDGANiw2CAJRA.png" /><figcaption>PostgreSQL signing key</figcaption></figure><p>e) To complete the PostgreSQL setup, proceed by installing PostgreSQL.</p><pre>sudo apt install postgresql postgresql-contrib -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_QlJgWrrxUBKAm19XTNKg.png" /><figcaption>PostgreSQL installation</figcaption></figure><p>f) Ensure the database server starts automatically upon reboot for seamless operation.</p><pre>sudo systemctl enable postgresql</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4N4tLJWvHSgF4RD6nc0eA.png" /><figcaption>Enable PostgreSQL</figcaption></figure><p>g) Initiate the database server to begin operations.</p><pre>sudo systemctl start postgresql</pre><p>h) Verify the current status of the database server.</p><pre>sudo systemctl status postgresql</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9hr0dYOgmOFiP1bSA-XB5g.png" /><figcaption>Active state of PostgreSQL</figcaption></figure><p>i) It’s crucial to validate the installed version of the Postgres database.</p><pre>psql --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*PdVDqGhxklMUU_OBr9Kepw.png" /><figcaption>PostgreSQL version</figcaption></figure><p>j) Switch to the Postgres user account for further configuration.</p><pre>sudo -i -u postgres</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*ngHa7rB0qdMBUVuer6oRGw.png" /><figcaption>PostgreSQL User Account</figcaption></figure><p><strong>Step 3 : Database Mastery: Crafting Configurations with Elegance!</strong></p><p>a) Create a new database user to manage the sqube database.</p><pre>createuser new_user</pre><p>In my case, the command to set the password for the “sonar” user would be:</p><pre>createuser sona</pre><p>b) Log in to the PostgreSQL database to proceed with database operations.</p><pre>psql</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*UjsrtZwNlBKer-u4oCaJUw.png" /><figcaption>Login PostgreSQL</figcaption></figure><p>c) Set a strong password for the “sona” user. Use a password that meets security requirements in place of `my_password`.</p><pre>ALTER USER [Created_user_name] WITH ENCRYPTED password &#39;my_password&#39;;</pre><p>In my case command would be :</p><pre>ALTER USER sona WITH ENCRYPTED password &#39;Sona#123&#39;;</pre><p>d) Create a sqube database and assign the ownership to the “sona” user.</p><pre>CREATE DATABASE [database_name] OWNER [Created_user_name];</pre><p>In my case command would be :</p><pre>CREATE DATABASE sqube OWNER sona;</pre><p>e) Grant all privileges on the “sqube” database to the “sona” user.</p><pre>GRANT ALL PRIVILEGES ON DATABASE sqube to sona;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*sZFGvhUmUHonZXJWws2Log.png" /><figcaption>Creating user and database</figcaption></figure><p>f) To verify the creation of the database, use the following command:</p><pre>\l</pre><p>g) To verify the creation of the database user, use the following command:</p><pre>\du</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qq3y0b5nxMgomTASeIo-Zg.png" /><figcaption>List of databases and their role</figcaption></figure><p>h) To exit the PostgreSQL command-line interface, use the following command:</p><pre>\q</pre><p>i) To return to your non-root sudo user account, use the following command:</p><pre>exit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*8qWXRslPOsIBjDCR6A54nw.png" /><figcaption>return to sudo user</figcaption></figure><p><strong>Step 4 : Empower Your Development: Downloading and Installing SonarQube</strong></p><p>a) Install the zip utility, required for extracting the SonarQube files, using the following command:</p><pre>sudo apt install zip -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*paKd6GzbzQAzoqWVf1Z94w.png" /><figcaption>Install zip</figcaption></figure><p>b) First, obtain the latest download URL from the SonarQube official download page.</p><p>Then, download the SonarQube distribution files. For example, you can use the following link to download the latest version:</p><p>[Download SonarQube](<a href="https://www.sonarsource.com/products/sonarqube/downloads/">https://www.sonarsource.com/products/sonarqube/downloads/</a>)</p><p>Here, we are installing the latest version of SonarQube 10.4 Community Edition (free version).</p><pre>sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.4.1.88267.zip</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-fVXjk3IB0HVTjDCavszg.png" /><figcaption>Installing binaries</figcaption></figure><p>c) Unzip the downloaded file using the following command:</p><pre>sudo unzip sonarqube-10.4.1.88267.zip</pre><p>d) Move the unzipped files to the /opt/sonarqube directory using the following command:</p><pre>sudo mv sonarqube-10.4.1.88267 sonarqube<br>sudo mv sonarqube /opt/</pre><p><strong>Step 5 : Setting Up SonarQube: Adding Group and User</strong></p><p>a) Create a dedicated user and group for SonarQube, ensuring it cannot run as the root user. For example, you can use the following commands to create a user and group named “sona”:</p><pre>sudo groupadd sona<br>sudo useradd -d /opt/sonarqube -g sona sona</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*9x1SP9R_PXFAWoxRT7t1mg.png" /><figcaption>Adding group and user</figcaption></figure><p>b) Grant the “sona” user access to the /opt/sonarqube directory using the following command:</p><pre>sudo chown -R sona:sona /opt/sonarqube</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*KaBGUui-49p7sAOyNsPkSw.png" /><figcaption>Granting user access</figcaption></figure><p><strong>Step 6 : Fine-Tuning SonarQube: Configuring for Peak Performance</strong></p><p>a) Edit the SonarQube configuration file located at /opt/sonarqube/conf/sonar.properties.</p><pre>sudo nano /opt/sonarqube/conf/sonar.properties</pre><p>b) Uncomment the following lines in the SonarQube configuration file (/opt/sonarqube/conf/sonar.properties) and add the database user and password you created:</p><pre>sonar.jdbc.username=sona<br>sonar.jdbc.password=Sona#123</pre><p>c) Below these lines, add the following line to specify the JDBC URL:</p><pre>sonar.jdbc.url=jdbc:postgresql://localhost:5432/sqube</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w_MU0hyczJhtA_H8iqD1vg.png" /><figcaption>Adding to sonar.properties</figcaption></figure><p>d) Replace “sona” with your database username, “Sona#123” with your database password, and “sqube” with your database name.</p><p>e) Save and exit the sonar.properties file.</p><p>f) To edit the SonarQube script file, use the following command:</p><pre>sudo nano /opt/sonarqube/bin/linux-x86-64/sonar.sh</pre><p>g) Replace “linux-x86–64” with the appropriate directory for your installation if it’s different.</p><p>h) Add the following line to the SonarQube script file (/opt/sonarqube/bin/linux-x86–64/sonar.sh) to specify the user to run SonarQube as:</p><pre>RUN_AS_USER=sona</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DhUru_-2x7Lhhecffw6_PA.png" /><figcaption>Adding to sonar.sh</figcaption></figure><p>i) Replace “sona” with the name of the user you created earlier.</p><p>j) Save and exit the sonar.sh file.</p><p><strong>Step 7 : Streamlining SonarQube: Setting Up a systemd Service</strong></p><p>a) To create a systemd service file for SonarQube, use the following steps:</p><p>(i) Create a new service file using a text editor:</p><pre>sudo nano /etc/systemd/system/sonar.service</pre><p>(ii) Add the following content to the file:</p><pre>[Unit]<br>Description=SonarQube service<br>After=syslog.target network.target<br>[Service]<br>Type=forking<br>ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start<br>ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop<br>User=sona<br>Group=sona<br>Restart=always<br>LimitNOFILE=65536<br>LimitNPROC=4096<br>[Install]<br>WantedBy=multi-user.target</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*cH8huSAISzWRpanhl7qE3A.png" /><figcaption>Adding to sonar.service</figcaption></figure><p>Make sure to replace “User=sona” and “Group=sona” with the appropriate values you have created for your SonarQube installation.</p><p>(iii)Save and close the file.</p><p>b) Reload the systemd sonar to apply the changes:</p><pre>sudo systemctl enable sonar</pre><p>c) Enable the SonarQube service to start at boot:</p><pre>sudo systemctl start sonar</pre><p>d) Now, you can start the SonarQube service using the following command:</p><pre>sudo systemctl status sonar</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y9mm-cLuVRqNQoYgZOxmuA.png" /><figcaption>Checking status of sonar service</figcaption></figure><p>e) Hooray, it’s up and running smoothly!</p><p><strong>Step 8 : Enhancing Performance: Modifying Kernel System Limits</strong></p><p>a) To ensure SonarQube functions correctly with Elasticsearch, you’ll need to make some adjustments to the system defaults.</p><p>b) To edit the sysctl configuration file, use the following command:</p><pre>sudo nano /etc/sysctl.conf</pre><p>c) This file controls various kernel parameters.</p><p>d) Add the following lines to the sysctl configuration file (/etc/sysctl.conf):</p><pre>vm.max_map_count=262144<br>fs.file-max=65536<br>ulimit -n 65536<br>ulimit -u 4096</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*5SsM0Yy2hBGqfUV-PWKtEw.png" /><figcaption>Adding to sysctl file</figcaption></figure><p>e) Save and exit the sysctl configuration file.</p><p>f) To apply the changes, reboot the system using the following command:</p><pre>sudo reboot</pre><p><strong>Step 9 : Exploring SonarQube: Accessing the Web Interface</strong></p><p>a) Access SonarQube in a web browser by entering your server’s IP address followed by port 9000.</p><p>For example, <a href="http://ip:9000/">http://IP:9000</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*6NpdLuIFq3hIBR4S4-Y6qA.png" /><figcaption>Login SonarQube</figcaption></figure><p>b) The default username and password are both “admin”.</p><p>c) To change the password in SonarQube, follow these steps:</p><p>(i) Log in to SonarQube using the username “admin” and password “admin”.</p><p>(ii) Once logged in, SonarQube will prompt you to change your password. Enter the current password “admin” and then enter your new password twice as prompted.</p><p>(iii) Click on the “Change password” button to save your new password.</p><p>Your password has now been successfully changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*f0oE1CzGBpmKfffZXLwecg.png" /><figcaption>Updating Password</figcaption></figure><p>c) Congratulations on successfully installing SonarQube Community version 10.0 on AWS EC2 Ubuntu 22! If you have any more questions or need further assistance, feel free to ask. Happy coding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0Sc00ts4mkeccV5BZ_aDg.png" /><figcaption>SonarQube Portal</figcaption></figure><h3><strong>Conclusion :</strong></h3><p>We’ve now completed the successful installation of SonarQube Community version 10.4 on AWS EC2 Ubuntu 22/20. This accomplishment opens up new possibilities for enhancing code quality and optimizing development workflows. Should you encounter any challenges or require additional support, please don’t hesitate to reach out. Here’s to leveraging the power of SonarQube for improved software development practices!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/0*H-wdve0gbIMtgQpB.jpg" /></figure><p><em>Thank you for taking the time to read my blog. Your feedback is immensely valuable to me. Please feel free to share your thoughts and suggestions.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=defd8955eb30" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-distributed-mind/installing-and-configuring-sonarqube-on-aws-ec2-a-step-by-step-guide-defd8955eb30">Installing and Configuring SonarQube on AWS EC2: A Step-by-Step Guide</a> was originally published in <a href="https://medium.com/the-distributed-mind">The Distributed Mind</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Machine Learning: A Beginner’s Guide to Regression and Classification Techniques]]></title>
            <link>https://medium.com/the-distributed-mind/demystifying-machine-learning-a-beginners-guide-to-regression-and-classification-techniques-a0624a1ecde3?source=rss----46c61e84dfb1---4</link>
            <guid isPermaLink="false">https://medium.com/p/a0624a1ecde3</guid>
            <category><![CDATA[ojas-arora]]></category>
            <category><![CDATA[gradient-descent]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ojas Arora]]></dc:creator>
            <pubDate>Thu, 09 Oct 2025 18:09:13 GMT</pubDate>
            <atom:updated>2025-10-09T18:09:09.593Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nAU7y-OHrsWtHxx7eTcgHQ.jpeg" /></figure><p>Machine learning (ML) is transforming industries by providing systems the ability to automatically learn and improve from experience without being explicitly programmed. This guide will introduce key concepts and techniques that form the backbone of machine learning, with a focus on regression and classification methods.</p><h3>I. Introduction to Machine Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d3dje6zNQ8V3Y-b2XXwA0A.jpeg" /><figcaption>Introduction to Machine Learning</figcaption></figure><p>Machine learning is a subset of artificial intelligence (AI) that focuses on building systems capable of learning from data. At its core, ML is about finding patterns in data to make predictions or decisions. The primary types of machine learning are:</p><ul><li><strong>Supervised Learning:</strong> Learning from labeled data to predict outcomes.</li><li><strong>Unsupervised Learning:</strong> Finding hidden patterns in unlabeled data.</li><li><strong>Reinforcement Learning:</strong> Learning by interacting with an environment to achieve goals.</li></ul><h3>II. Linear Regression</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HEGu8XbbsuFSuj35Fvnikg.jpeg" /><figcaption>Linear Regression</figcaption></figure><p>Linear Regression is the most basic algorithm in Machine Learning. It is a regression algorithm which means that it is useful when we are required to predict continuous values, that is, the output variable ‘y’ is continuous in nature. A few examples of the regression problem can be the following-</p><ol><li>“What is the market value of the house?”</li><li>“Stock price prediction”</li><li>“Sales of a shop”</li><li>“Predicting height of a person”</li></ol><h3>Terms to be used here:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*thCO2CWpVcLPrvrisXcG6A.jpeg" /><figcaption>Terms to be used</figcaption></figure><ol><li><strong>Features — </strong>These are the independent variables in any dataset represented by x1 , x2 , x3, x4,… xn for ’n’ features.</li><li><strong>Target / Output Variable —</strong> This is the dependent variable whose value depends the independent variable by a relation (given below) and is represented by ‘y’.</li><li><strong>Function or Hypothesis of Linear Regression is represented by —</strong> y = m1.x1 + m2.x2 + m3.x3 + … + mn.xn + b Note: Hypothesis is a function that tries to fit the data.</li><li><strong>Intercept —</strong> Here b is the intercept of the line. We usually include this ‘b’ in the equation of ‘m’ and take ‘x’ values for that ‘m’ to be 1. So modified form of above equation is as follows: y = mx Where mx = m1.x1 + m2.x2 + m3.x3 + … + mn.xn + mn+1.xn+1 Here mn+1 is b and xn+1 = 1</li><li><strong>Training Data —</strong> This data contains a set of dependent variables that is ‘x’ and a set of output variable, ‘y’. This data is given to the machine for it to learn or get trained on some function (here the function is the equation given above) so that in future on giving some new values of ‘x’ (called testing data), our machine is able to predict values of ‘y’ based on that function.</li></ol><h3><strong>Linear Regression with one variable or feature:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zaS-weBW2jSjmGHHr9dklA.jpeg" /><figcaption>Linear Regression with one variable or feature</figcaption></figure><p>To understand Linear Regression better and visualize the graphs, let us assume that there is only one feature in the dataset, that is, x. So the equation goes as follows:</p><p>Y = mX + b</p><p>Let’s say if we scatter the points (x,y) from our training data, then what linear regression tries to do is, it tries to find a line with (given m and b ) such that error of each data point (x,yactual) is minimum when compared with x, ypredicted. Error here means combined error. This line is also called *line of best fit* .</p><p>Look at the graph given below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*qSpCVP8pX7ViuTVyC18F2A.png" /></figure><p>Here it is difficult to find out the line of best fit just by looking at the different lines.</p><p>So our algorithm finds out the m and b for the line of best fit by calculating the combined error function and minimizing it. There can be three ways of calculating error function:</p><ol><li><strong>Sum of residuals (∑(Yactual — Ypredict)) —</strong> it might result in cancelling out of positive and negative errors.</li><li><strong>Sum of the absolute value of residuals (∑ | Yactual — Ypredict | ) — </strong>absolute value would prevent cancellation of errors</li><li><strong>Sum of square of residuals ( ∑ ( Yactual — Ypredict )²) — </strong>it’s the method mostly used in practice since here we penalize higher error value much more as compared to a smaller one, so that there is a significant difference between making big errors and small errors, which makes it easy to differentiate and select the best fit line.</li></ol><h3>III. Multivariable Regression</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RuqkSL6bqQQUgTdE34THxQ.jpeg" /></figure><p>Multivariable regression extends linear regression to include multiple independent variables, enabling the model to capture more complex relationships.</p><p><strong>Equation:</strong><br>y=β0+β1x1+β2x2+…+βnxn+ϵ</p><h3>IV. Gradient Descent</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GDPjwVjigIhJ8o5wNIo5_w.jpeg" /><figcaption>Gradient Descent</figcaption></figure><ul><li>Optimization is a big part of machine learning. Almost every machine learning algorithm has an optimization algorithm at its core.</li><li>Gradient descent is an optimization algorithm used to find the values of parameters (coefficients) of a function (f) that minimizes a cost function (cost).\</li><li>Gradient descent is best used when the parameters cannot be calculated analytically or when you need an optimized way to calculate those parameters.</li></ul><h3>Procedure:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NvptJd3m6iUj2q7Jru9HIg.jpeg" /><figcaption>Procedure:</figcaption></figure><p>Let the cost function be, f:</p><p>The procedure starts by assuming the initial values of coefficients. These could be 0.0 or some random value.</p><p>Coefficient, m = 0 Intercept, b = 0</p><p>The cost is evaluated by using these coefficients.</p><p>Cost = f (m, b)</p><p>Now derivative of cost is calculated with respect to the coefficients i.e. slope of the cost function is calculated. We need to know the slope to determine the direction to move the coefficient values to get lower cost at next iteration. The selection will be done based on slope at that point, whether it is positive or negative, just as in the case when you were on the mountain and your decision is based on the ground near you.</p><p>Delta = derivative(cost), i.e.</p><p>Now to update the coefficient values, a learning rate parameter must be specified that controls how much the coefficients can change on each iteration</p><p>New-coefficients = coefficient — (learning-rate*derivative)</p><p>The cost function, evaluated using the new coefficients will have a better(lower)/ worse(higher) cost depending upon the value of learning rate.</p><p>Repeating this process enough times will give the coefficients that will result in minimum cost. The process can be repeated either a specified number of times or till that point where change in cost is negligible.</p><p>Example, in case of Linear Regression with only one feature, cost function is given as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*IKYL3rBBBuPolyOX_ulj7w.png" /></figure><h3>V. Feature Scaling</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oCv18v-nBsA0ERyV6ESffw.jpeg" /><figcaption>Feature Scaling</figcaption></figure><ul><li>Feature Scaling is a data preprocessing technique. By preprocessing, we mean the transformations that are applied to the data before it is fed into some algorithm for some processing.</li><li>Feature scaling or re-scaling of the features is performed such that they have the properties of normal distribution (most of the time) where values have standard deviation = 1, and mean = 0.</li></ul><h3>How Feature Scaling is applied in sklearn?</h3><p>There are many ways by which we can apply feature scaling on the dataset: <strong>1.</strong> The easiest way of scaling is to use — preprocessing.scale() function A numpy array of values is given as input and output is numpy array with scaled values.</p><p>This will scale the values in such a way that mean of the values will be 0 and standard deviation will be 1.</p><p><strong>2.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*qE8OBrrg5MJYUr4sQY7T-A.png" /></figure><p><strong>3.</strong> Another method is to scale the features between given minimum and maximum values, generally between 0 and 1.</p><p><strong>Function -</strong>preprocessing.MinMaxScaler(feature_range=(0, 1), copy=True) <strong>Feature_range is given in the form of tuple —</strong> (min , max) Copy — True (default), set it to False if you want inplace transformation</p><p>Formula used -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*KtJOXv-nqXFTVGJd9HQg6g.png" /></figure><h3>VI. Logistic Regression</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QVMmrU-UrLSCYb5er84uLg.jpeg" /><figcaption>Logistic Regression</figcaption></figure><p>Logistic regression is used for binary classification, predicting the probability of an instance belonging to one of two classes.</p><h4>Key Concepts</h4><ul><li><strong>Binary Outcomes:</strong> Suitable for tasks with two possible outcomes, like spam detection (spam or not spam).</li><li><strong>Logistic Function:</strong> Uses the sigmoid function to map predicted values to probabilities between 0 and 1:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*-yG8XyxDPsLtJXqj92he2w.png" /></figure><ul><li><strong>Log-Odds:</strong> Models the log-odds of the probability, where the log-odds is the logarithm of the odds ratio.</li></ul><h4>Applications</h4><ul><li><strong>Spam Detection:</strong> Classifies emails as spam or not spam.</li><li><strong>Medical Diagnosis:</strong> Predicts disease presence based on patient data.</li><li><strong>Credit Scoring:</strong> Assesses the likelihood of loan default.</li></ul><h4>Advantages</h4><ul><li><strong>Simple and Interpretable:</strong> Easy to understand and implement.</li><li><strong>Efficient:</strong> Less computationally intensive than complex models.</li></ul><h4>Limitations</h4><ul><li><strong>Linearity Assumption:</strong> Assumes a linear relationship between features and log-odds.</li><li><strong>Sensitive to Imbalanced Data:</strong> Performance may degrade with imbalanced classes.</li></ul><p>Logistic regression is a powerful tool for binary classification, offering simplicity and interpretability, making it a popular choice for many applications.</p><h3>VII. Classification Measures</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-BdK2dgPlcYUKupzGv7eTA.jpeg" /><figcaption>Classification Measures</figcaption></figure><p>Classification measures are metrics used to evaluate the performance of classification models. They help assess how well a model predicts categorical outcomes.</p><h3>Confusion Matrix</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-QWb-YzRnU7vZnCEqookKg.jpeg" /><figcaption>Confusion Matrix</figcaption></figure><p>A confusion matrix is a table used to evaluate the performance of a classification model. It provides a detailed breakdown of correct and incorrect predictions.</p><h4>Structure of a Confusion Matrix</h4><p>For a binary classification problem, the confusion matrix is a 2x2 table consisting of:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*t2sWIqRkEevlOusqbD8WHw.png" /></figure><h4>Key Metrics Derived from the Confusion Matrix</h4><ul><li><strong>Accuracy:</strong> The proportion of total correct predictions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*jmWmFoJK0TDTlrJ4zYI_GQ.png" /></figure><ul><li><strong>Precision:</strong> The ratio of true positive predictions to the total predicted positives. Measures the accuracy of positive predictions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*z8turui9SQrUICdEjUFOvw.png" /></figure><ul><li><strong>Recall (Sensitivity):</strong> The ratio of true positive predictions to the actual positives. Measures the ability of the model to capture positive instances</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*S_wRrqhU2jiog-dg1-kTvg.png" /></figure><ul><li><strong>F1 Score:</strong> The harmonic mean of precision and recall, providing a balance between the two metrics.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*s7NhxbkMIkrpNpvPCQCh1A.png" /></figure><ul><li><strong>Specificity:</strong> The ratio of true negative predictions to the actual negatives. Measures the model’s ability to identify negative instances.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*JgvzcNXbXfwAuPhPz3yPzQ.png" /></figure><h3>VIII. Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hewZkJXP-uAKGYjSMFZuqw.jpeg" /><figcaption>Conclusion</figcaption></figure><p>Machine learning, through its core regression and classification techniques, provides powerful tools for solving diverse problems across industries. Understanding concepts like linear and logistic regression, along with evaluation metrics such as precision and recall, equips beginners to tackle both continuous and categorical data challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0624a1ecde3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-distributed-mind/demystifying-machine-learning-a-beginners-guide-to-regression-and-classification-techniques-a0624a1ecde3">Demystifying Machine Learning: A Beginner’s Guide to Regression and Classification Techniques</a> was originally published in <a href="https://medium.com/the-distributed-mind">The Distributed Mind</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>