<?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 Ayush Shukla on Medium]]></title>
        <description><![CDATA[Stories by Ayush Shukla on Medium]]></description>
        <link>https://medium.com/@ayush.shukla.connect?source=rss-7c8d15c99c89------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iOvt8QnkwCMHLKUx2cj_tg.jpeg</url>
            <title>Stories by Ayush Shukla on Medium</title>
            <link>https://medium.com/@ayush.shukla.connect?source=rss-7c8d15c99c89------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 06:00:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ayush.shukla.connect/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[Design Patterns Every Java Developer Should Know — Lessons Learned from Real Interviews]]></title>
            <link>https://medium.com/@ayush.shukla.connect/design-patterns-every-java-developer-should-know-lessons-learned-from-real-interviews-24587034035a?source=rss-7c8d15c99c89------2</link>
            <guid isPermaLink="false">https://medium.com/p/24587034035a</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Ayush Shukla]]></dc:creator>
            <pubDate>Sat, 06 Dec 2025 08:32:35 GMT</pubDate>
            <atom:updated>2025-12-06T08:32:35.463Z</atom:updated>
            <content:encoded><![CDATA[<h3>Design Patterns Every Java Developer Should Know — Lessons Learned from Real Interviews</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z6fEftuyKU2iPU4SxRldxw.png" /></figure><p>I still remember the day I bombed a technical interview.</p><p>The interviewer asked me to explain the <strong>Strategy Pattern</strong>.<br> I confidently said, <em>“It’s used for different algorithms,”</em> and waited for the next question.<br> Instead, he asked:</p><blockquote><em>“Great. Now implement it for a payment processing system.”</em></blockquote><p>I froze.</p><p>That moment forced me to stop memorizing definitions and actually understand design patterns — not just <em>what</em> they are, but <em>why</em> they exist, <em>when</em> they help, and <em>how</em> they show up in real architectures.</p><p>After working across microservices, refactoring legacy modules, and facing multiple product-company interviews, I realized something important:</p><blockquote><strong><em>Interviewers don’t want theory. They want clarity of thought.<br> They want to see if you recognize the problem a pattern solves.</em></strong></blockquote><p>So here are the <strong>seven design patterns</strong> that repeatedly appear in interviews for Java developers with 3–5 years of experience — rewritten in a way I wish someone explained them to me.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>1. Singleton Pattern — Useful, Powerful, and Dangerous</h3><p><strong>What it is:</strong> Ensures only <strong>one instance</strong> of a class exists in the application.<br> <strong>Where I use it:</strong> DB connections, configuration loaders, logging frameworks.</p><p>One of my interview questions was:</p><blockquote><strong><em>“Implement a thread-safe Singleton. Also explain the drawbacks.</em></strong></blockquote><p>That’s when I learned that most developers implement Singletons incorrectly.</p><h3>⚠️ Basic Singleton (NOT Thread-Safe)</h3><pre>public class DatabaseConnection {<br>    private static DatabaseConnection instance;<br>    <br>    private DatabaseConnection() {}<br>    <br>    public static DatabaseConnection getInstance() {<br>        if (instance == null) {<br>            instance = new DatabaseConnection();<br>        }<br>        return instance;<br>    }<br>}</pre><p>Two threads can easily create two different instances.</p><h3>✔️ Double-Checked Locking (Thread-Safe)</h3><pre>public class DatabaseConnection {<br>    private static volatile DatabaseConnection instance;<br>    <br>    private DatabaseConnection() {}<br>    <br>    public static DatabaseConnection getInstance() {<br>        if (instance == null) {<br>            synchronized (DatabaseConnection.class) {<br>                if (instance == null) {<br>                    instance = new DatabaseConnection();<br>                }<br>            }<br>        }<br>        return instance;<br>    }<br>}</pre><h3>⭐ Enum Singleton — The Best Modern Approach</h3><pre>public enum DatabaseConnection {<br>    INSTANCE;<br>    <br>    public void connect() {<br>        // connection logic<br>    }<br>}</pre><pre>// Usage<br>DatabaseConnection.INSTANCE.connect();</pre><p>Enum-based Singletons avoid reflection, serialization issues, and are thread-safe by default.</p><p><strong>Where I used it:</strong><br> In a digital wallet platform, our configuration loader needed to initialize exactly once across services — Singleton fit perfectly.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>2. Factory Pattern — When Object Creation Becomes a Mess</h3><p>Factories shine the moment you catch yourself writing:</p><blockquote><em>“If type is A, create X. If type is B, create Y…”</em></blockquote><p>This is where the Open-Closed Principle screams for help.</p><h3>❌ Without Factory Pattern</h3><pre>if (type.equals(&quot;email&quot;)) {<br>    notification = new EmailNotification();<br>} else if (type.equals(&quot;sms&quot;)) {<br>    notification = new SmsNotification();<br>} else if (type.equals(&quot;push&quot;)) {<br>    notification = new PushNotification();<br>}</pre><p>Every time you add a new notification type, you must modify existing code — a design smell.</p><h3>✔️ With Factory Pattern</h3><pre>public interface Notification {<br>    void send(String message);<br>}</pre><pre>public class EmailNotification implements Notification {<br>    @Override<br>    public void send(String message) {<br>        System.out.println(&quot;Sending email: &quot; + message);<br>    }<br>}</pre><pre>public class SmsNotification implements Notification {<br>    @Override<br>    public void send(String message) {<br>        System.out.println(&quot;Sending SMS: &quot; + message);<br>    }<br>}</pre><pre>public class NotificationFactory {<br>    public static Notification createNotification(String channel) {<br>        switch (channel.toLowerCase()) {<br>            case &quot;email&quot;:<br>                return new EmailNotification();<br>            case &quot;sms&quot;:<br>                return new SmsNotification();<br>            case &quot;push&quot;:<br>                return new PushNotification();<br>            default:<br>                throw new IllegalArgumentException(&quot;Unknown channel: &quot; + channel);<br>        }<br>    }<br>}</pre><pre>// Usage<br>Notification notification = NotificationFactory.createNotification(&quot;email&quot;);<br>notification.send(&quot;Welcome to our platform!&quot;);</pre><p><strong>Real-world usage:</strong><br> In my MovieHub microservices project, I used Factory to generate dynamic movie filters (genre, rating, year). Adding new filters became effortless.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>3. Strategy Pattern — When Behavior Must Be Swappable at Runtime</h3><p>This is the pattern that caught me off guard in interviews — until I truly understood it.</p><p><strong>What it is:</strong><br> A clean way to encapsulate interchangeable algorithms or behaviors.</p><p><strong>Where I use it:</strong><br> Payment methods, pricing rules, sorting strategies, validation logic.</p><h3>✔️ Strategy Pattern Implementation</h3><pre>public interface PaymentStrategy {<br>    void pay(double amount);<br>}</pre><pre>public class CreditCardPayment implements PaymentStrategy {<br>    private String cardNumber;<br>    private String cvv;<br>    <br>    public CreditCardPayment(String cardNumber, String cvv) {<br>        this.cardNumber = cardNumber;<br>        this.cvv = cvv;<br>    }<br>    <br>    @Override<br>    public void pay(double amount) {<br>        System.out.println(&quot;Paid &quot; + amount + &quot; using Credit Card&quot;);<br>        // Actual payment processing logic<br>    }<br>}</pre><pre>public class PayPalPayment implements PaymentStrategy {<br>    private String email;<br>    <br>    public PayPalPayment(String email) {<br>        this.email = email;<br>    }<br>    <br>    @Override<br>    public void pay(double amount) {<br>        System.out.println(&quot;Paid &quot; + amount + &quot; using PayPal&quot;);<br>    }<br>}</pre><pre>public class ShoppingCart {<br>    private PaymentStrategy paymentStrategy;<br>    <br>    public void setPaymentStrategy(PaymentStrategy strategy) {<br>        this.paymentStrategy = strategy;<br>    }<br>    <br>    public void checkout(double amount) {<br>        paymentStrategy.pay(amount);<br>    }<br>}</pre><p>Now switching payment methods becomes trivial — exactly what interviewers look for.</p><h3>📌 Real Usage</h3><p>In my digital wallet system, Strategy handled <strong>different fee calculation rules</strong> based on user tiers (basic, premium, enterprise). No if-else, no clutter.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>4. Observer Pattern — Notify Everyone When Something Changes</h3><p>If you’ve ever built a dashboard that needs live updates, you’ve probably reinvented Observer without realizing it.</p><p><strong>What it is:</strong> A one-to-many dependency where subscribers react automatically to state changes.</p><h3>✔️ Observer Pattern Implementation</h3><pre>import java.util.ArrayList;<br>import java.util.List;</pre><pre>public interface Observer {<br>    void update(String stockSymbol, double price);<br>}</pre><pre>public interface Subject {<br>    void attach(Observer observer);<br>    void detach(Observer observer);<br>    void notifyObservers();<br>}</pre><pre>public class StockMarket implements Subject {<br>    private List&lt;Observer&gt; observers = new ArrayList&lt;&gt;();<br>    private String stockSymbol;<br>    private double stockPrice;<br>    <br>    @Override<br>    public void attach(Observer observer) {<br>        observers.add(observer);<br>    }<br>    <br>    @Override<br>    public void detach(Observer observer) {<br>        observers.remove(observer);<br>    }<br>    <br>    @Override<br>    public void notifyObservers() {<br>        for (Observer observer : observers) {<br>            observer.update(stockSymbol, stockPrice);<br>        }<br>    }<br>    <br>    public void setStockPrice(String symbol, double price) {<br>        this.stockSymbol = symbol;<br>        this.stockPrice = price;<br>        notifyObservers();<br>    }<br>}</pre><pre>public class MobileApp implements Observer {<br>    private String appName;<br>    <br>    public MobileApp(String appName) {<br>        this.appName = appName;<br>    }<br>    <br>    @Override<br>    public void update(String stockSymbol, double price) {<br>        System.out.println(appName + &quot; received update: &quot; + stockSymbol + &quot; = $&quot; + price);<br>    }<br>}</pre><h3>💡 Real-World Note</h3><p>Spring’s ApplicationEvent system is built using this pattern.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>5. Decorator Pattern — Add Features Without Touching Existing Code</h3><p>This pattern is a lifesaver when you want to “enhance” objects dynamically.</p><p><strong>Classic example:</strong> Coffee with optional milk, sugar, whipped cream…<br> Without Decorator, you’d need dozens of subclasses.</p><h3>✔️ Decorator Pattern Implementation</h3><pre>public interface Coffee {<br>    String getDescription();<br>    double getCost();<br>}</pre><pre>public class SimpleCoffee implements Coffee {<br>    @Override<br>    public String getDescription() {<br>        return &quot;Simple Coffee&quot;;<br>    }<br>    <br>    @Override<br>    public double getCost() {<br>        return 5.0;<br>    }<br>}</pre><pre>public abstract class CoffeeDecorator implements Coffee {<br>    protected Coffee decoratedCoffee;<br>    <br>    public CoffeeDecorator(Coffee coffee) {<br>        this.decoratedCoffee = coffee;<br>    }<br>    <br>    public String getDescription() {<br>        return decoratedCoffee.getDescription();<br>    }<br>    <br>    public double getCost() {<br>        return decoratedCoffee.getCost();<br>    }<br>}</pre><h3>📌 Real Usage</h3><p>Java I/O streams are Decorator incarnate:</p><pre>InputStream input = new BufferedInputStream(<br>    new FileInputStream(&quot;file.txt&quot;)<br>);</pre><p>In my movie API, Decorator helped add <em>caching</em>, <em>logging</em>, and <em>validation</em> without rewriting core business logic.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>6. Adapter Pattern — When Two Systems Speak Different Languages</h3><p>This one saved me during a legacy integration.</p><p>We had a payment gateway that only returned <strong>XML</strong>, while our system only understood <strong>JSON</strong>.<br> Rewriting the gateway logic was impossible.</p><p>Enter: Adapter.</p><h3>✔️ Adapter Pattern Implementation</h3><pre>// Third-party payment gateway (we can&#39;t modify this)<br>public class LegacyPaymentGateway {<br>    public String processPaymentXml(String xmlData) {<br>        System.out.println(&quot;Processing XML payment: &quot; + xmlData);<br>        return &quot;&lt;response&gt;success&lt;/response&gt;&quot;;<br>    }<br>}</pre><pre>// Our system expects this interface<br>public interface ModernPaymentProcessor {<br>    String processPayment(PaymentRequest request);<br>}</pre><pre>public class PaymentRequest {<br>    private String cardNumber;<br>    private double amount;<br>    <br>    // constructor, getters, setters<br>    public PaymentRequest(String cardNumber, double amount) {<br>        this.cardNumber = cardNumber;<br>        this.amount = amount;<br>    }<br>    <br>    public String toJson() {<br>        return &quot;{\&quot;cardNumber\&quot;:\&quot;&quot; + cardNumber + &quot;\&quot;, \&quot;amount\&quot;:&quot; + amount + &quot;}&quot;;<br>    }<br>}</pre><pre>// Adapter that bridges the gap<br>public class PaymentGatewayAdapter implements ModernPaymentProcessor {<br>    private LegacyPaymentGateway legacyGateway;<br>    <br>    public PaymentGatewayAdapter(LegacyPaymentGateway legacyGateway) {<br>        this.legacyGateway = legacyGateway;<br>    }<br>    <br>    @Override<br>    public String processPayment(PaymentRequest request) {<br>        // Convert JSON to XML<br>        String xmlData = convertJsonToXml(request.toJson());<br>        <br>        // Call legacy system<br>        String xmlResponse = legacyGateway.processPaymentXml(xmlData);<br>        <br>        // Convert XML response back to JSON<br>        return convertXmlToJson(xmlResponse);<br>    }<br>    <br>    private String convertJsonToXml(String json) {<br>        // Conversion logic<br>        return &quot;&lt;payment&gt;&quot; + json + &quot;&lt;/payment&gt;&quot;;<br>    }<br>    <br>    private String convertXmlToJson(String xml) {<br>        // Conversion logic<br>        return &quot;{\&quot;status\&quot;:\&quot;success\&quot;}&quot;;<br>    }<br>}</pre><h3>💡 Real World</h3><p>Spring’s JdbcTemplate is essentially an Adapter for JDBC — simplifying a low-level API into an easy one.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>7. Builder Pattern — Because Long Constructors Are a Crime</h3><p>We’ve all done this once:</p><pre>// This is terrible<br>User user = new User(&quot;John&quot;, &quot;Doe&quot;, &quot;john@email.com&quot;, &quot;1234567890&quot;, <br>    &quot;123 Street&quot;, &quot;City&quot;, &quot;State&quot;, &quot;12345&quot;, &quot;USA&quot;, 30);</pre><p>No one knows what each parameter means.<br> Changing order breaks everything.</p><h3>✔️ Builder Pattern Implementation</h3><pre>public class User {<br>    // Required parameters<br>    private final String firstName;<br>    private final String lastName;<br>    <br>    // Optional parameters<br>    private final String email;<br>    private final String phone;<br>    private final String address;<br>    private final String city;<br>    private final String state;<br>    private final int age;<br>    <br>    private User(UserBuilder builder) {<br>        this.firstName = builder.firstName;<br>        this.lastName = builder.lastName;<br>        this.email = builder.email;<br>        this.phone = builder.phone;<br>        this.address = builder.address;<br>        this.city = builder.city;<br>        this.state = builder.state;<br>        this.age = builder.age;<br>    }<br>    <br>    public static class UserBuilder {<br>        private final String firstName;<br>        private final String lastName;<br>        <br>        private String email = &quot;&quot;;<br>        private String phone = &quot;&quot;;<br>        private String address = &quot;&quot;;<br>        private String city = &quot;&quot;;<br>        private String state = &quot;&quot;;<br>        private int age = 0;<br>        <br>        public UserBuilder(String firstName, String lastName) {<br>            this.firstName = firstName;<br>            this.lastName = lastName;<br>        }<br>        <br>        public UserBuilder email(String email) {<br>            this.email = email;<br>            return this;<br>        }<br>        <br>        public UserBuilder phone(String phone) {<br>            this.phone = phone;<br>            return this;<br>        }<br>        <br>        public UserBuilder address(String address) {<br>            this.address = address;<br>            return this;<br>        }<br>        <br>        public UserBuilder city(String city) {<br>            this.city = city;<br>            return this;<br>        }<br>        <br>        public UserBuilder state(String state) {<br>            this.state = state;<br>            return this;<br>        }<br>        <br>        public UserBuilder age(int age) {<br>            this.age = age;<br>            return this;<br>        }<br>        <br>        public User build() {<br>            return new User(this);<br>        }<br>    }<br>}</pre><h3>⭐ Bonus: Lombok Builder</h3><pre>import lombok.Builder;<br>import lombok.Getter;</pre><pre>@Getter<br>@Builder<br>public class User {<br>    private String firstName;<br>    private String lastName;<br>    private String email;<br>    private String phone;<br>    private int age;<br>}</pre><p>Builder removes ambiguity and makes objects readable, safe, and maintainable.</p><h3>Key Takeaways From Real Interviews</h3><h3>🔹 1. Interviewers care more about when than how.</h3><p>Patterns are useless unless you know why you’d use them.</p><h3>🔹 2. Every pattern has drawbacks. Know them.</h3><p>Singleton → Testing issues<br> Observer → Memory leaks<br> Builder → Boilerplate</p><h3>🔹 3. Spring is full of design patterns.</h3><p>Recognizing them elevates your architecture skills.</p><h3>🔹 4. Use diagrams.</h3><p>A quick sketch communicates faster than words.</p><h3>🔹 5. Tie patterns to your real projects.</h3><p>Interviewers remember stories, not definitions.</p><h3>Final Thoughts</h3><p>Design patterns are not about quoting definitions — they are about solving problems elegantly.</p><p>When I tell my team, <em>“Let’s use Strategy here,”</em> the conversation becomes instantly clearer.<br> That’s the real power of patterns: <strong>shared understanding</strong>.</p><p>Master these seven patterns.<br> Know when to apply them — and when not to.<br> And your interviews (and your codebases) will look very different.</p><h3>About Me</h3><p>I’m a backend developer working with Java, Spring Boot, and microservices.<br> Currently exploring system design and scalable architectures.<br> Always learning. Always sharing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24587034035a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Your Salary Smarter Than a 5th Grader? Decode Your Pay Like a Pro in India!]]></title>
            <link>https://medium.com/@ayush.shukla.connect/is-your-salary-smarter-than-a-5th-grader-decode-your-pay-like-a-pro-in-india-c7ef36d53eb0?source=rss-7c8d15c99c89------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7ef36d53eb0</guid>
            <category><![CDATA[salary-negotiations]]></category>
            <category><![CDATA[indian-workplace]]></category>
            <category><![CDATA[professional-growth]]></category>
            <category><![CDATA[career-advice]]></category>
            <category><![CDATA[personal-finance]]></category>
            <dc:creator><![CDATA[Ayush Shukla]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 18:36:20 GMT</pubDate>
            <atom:updated>2025-07-31T18:36:20.967Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B-i6FCpHRgcGJM_zOJ9pDg.png" /></figure><h3>☕ It All Started During a Chai Break…</h3><p>There I was — <strong>staring into my coffee cup</strong>, pretending to work while secretly wondering:</p><blockquote>“Is my salary growing… or just getting older with me?”</blockquote><p>The office Wi-Fi was crawling, but my doubts were on a <strong>5G sprint</strong>.<br> <strong>Should I finally ask for that raise?</strong><br> Are others with the same experience actually earning more — or just better at choosing LinkedIn filters?</p><p>If you’ve ever secretly typed <em>“</em><strong><em>am I underpaid in India?</em></strong><em>”</em> while hiding behind a spreadsheet, <em>I’ve been there</em>.<br> This post is <strong>my story</strong> — but it might just help you <strong>rewrite yours</strong> too.</p><h3>🎯 Stop Guessing, Start Knowing</h3><p>Let’s be real — <strong>talking about salary in India is more awkward than explaining your job to relatives during weddings</strong>.</p><p>But then I found a <strong>simple, no-jargon</strong> way to finally figure out where I stand.</p><blockquote><em>It’s called the </em><strong><em>Salary-to-Experience Ratio</em></strong><em>, and trust me — </em>once you calculate yours, you’ll never see your paycheck the same way again.</blockquote><h3>❗ The Ratio HR Doesn’t Want You to Know</h3><p>When I first heard about it, I thought it was some fancy MBA thing.</p><p>But it’s <strong>not</strong>. It’s <strong>simple</strong>. It’s <strong>free</strong>.<br>And it became my <strong>go-to cheat code</strong> during job offers, appraisals, and even those <em>late-night “what-am-I-doing-with-my-life” moments</em>.</p><h3>🍱 Bullet-Point Buffet of Value</h3><h3>✅ How to Calculate Your Salary Ratio:</h3><ul><li>Take your <strong>annual CTC (Cost to Company)</strong> in <em>lakhs</em>.</li><li>Divide it by your <strong>total years of full-time experience</strong>.</li></ul><blockquote><strong><em>That’s it.</em></strong><em> That’s the magic number.</em></blockquote><h3>🧮 Example:</h3><p>₹15 LPA with 5 years of experience<br> → 15 ÷ 5 = 3.0<em><br> </em><strong>Your Ratio = 3.0</strong></p><h3>📊 What Your Salary Ratio Means:</h3><p>Here’s what I learned when I ran the numbers (and checked with friends across industries):</p><ul><li><strong>Less than 2.0:</strong><br> ⚠️ <em>Red flag alert</em>. Might be time to upskill, switch lanes, or have <em>“the talk”</em> with HR.</li><li><strong>Between 2.0–3.0:</strong><br> ✅ <em>You’re on solid ground.</em> Maybe not viral on LinkedIn — but definitely not behind.</li><li><strong>Between 3.0–4.0:</strong><br> 🏆 <em>Elite zone.</em> Your college buddies probably zoom in on your Goa trip photos.</li><li><strong>Above 4.0:</strong></li><li>💎 <em>You’ve either mastered niche skills, negotiated like a boss, or… you’re living in a salary simulation.</em><br> <strong>Respect.</strong></li></ul><h3>🧘‍♂️ Rules for Salary Zen</h3><ul><li><strong>Don’t compare blindly.</strong><br> My friend in Bangalore tech earns differently than someone in Kolkata finance.<br> <em>Sector, role, and city matter — a lot.</em></li><li><strong>Skills depreciate faster than milk in May.</strong><br> Keep learning. Stay relevant.</li><li><strong>Low ratio? Don’t panic.</strong><br> Salary isn’t the only measure of success (<em>just ask anyone in core engineering!</em>)</li><li><strong>Negotiate like a pro</strong>,</li></ul><p>but remember:</p><blockquote><em>Gratitude + Growth &gt; Greed.</em><br> It’s a long game.</blockquote><blockquote><em>📷 </em><strong><em>Suggested Image Placement:</em></strong><em><br> </em>A visual infographic showing how to calculate Salary-to-Experience Ratio and the 4 result tiers (under 2, 2–3, 3–4, above 4).</blockquote><h3>✅ Your Salary Glow-Up Starts Now</h3><p>Think of the salary ratio as your <strong>career Fitbit</strong> — a <em>checkpoint</em>, not a <em>verdict</em>.</p><p><strong>Next chai break</strong>, ask yourself:</p><blockquote>“Am I growing faster than my CTC?”</blockquote><h3>🔁 Your Action Steps:</h3><ul><li>✅ <strong>Calculate your ratio</strong></li><li>✅ <strong>Share it with a friend or mentor you trust</strong></li><li>✅ <strong>Plan your next career move</strong></li></ul><p>💡 <em>Upskill. Network. Negotiate. Repeat.</em><br> <strong>Your bank balance will catch up with your potential — trust the process.</strong></p><h3>🛎️ Final Sip:</h3><p>Your <strong>salary is just one number. But an important one.</strong><br> Your <em>skills, attitude, and vision</em>?</p><blockquote><strong><em>That’s your real income.</em></strong></blockquote><p>So next time you’re stuck in traffic or sipping chai at 4 PM, ask yourself:</p><blockquote>“Is my salary working as hard as I am?”</blockquote><p>If not, let’s change that — <strong>one skill, one step, one ratio at a time.</strong></p><h3>💬 Bonus:</h3><p><strong>Want me to build a tool that calculates this for you?</strong><br> 👇 Drop a “<strong>YES</strong>” in the comments!</p><p>💬 <strong>Bonus:</strong> Want me to build a tool that calculates this for you? Drop a “YES” in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7ef36d53eb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Java Threads: A Beginner-Friendly Guide]]></title>
            <link>https://medium.com/@ayush.shukla.connect/mastering-java-threads-a-beginner-friendly-guide-88376ac29f0e?source=rss-7c8d15c99c89------2</link>
            <guid isPermaLink="false">https://medium.com/p/88376ac29f0e</guid>
            <category><![CDATA[java-system-design]]></category>
            <category><![CDATA[threadpoolexecutor]]></category>
            <category><![CDATA[java-thread]]></category>
            <category><![CDATA[java-developer]]></category>
            <category><![CDATA[multithreading-in-java]]></category>
            <dc:creator><![CDATA[Ayush Shukla]]></dc:creator>
            <pubDate>Fri, 02 May 2025 12:42:21 GMT</pubDate>
            <atom:updated>2025-05-02T12:42:21.526Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*FIchiM6tX2c8jmFkbz66gw.jpeg" /></figure><p>Whether you’re building a billing module for an e-commerce site or processing transactions in a fintech app, you will eventually face the need to do multiple things <em>at once</em>. That’s where <strong>threads</strong> and <strong>executors</strong> come in.</p><p>This guide simplifies the core concepts of <strong>Thread lifecycle</strong>, <strong>implementing threads</strong>, <strong>ThreadPoolExecutor</strong>, and the difference between execute() and submit(). No jargon, just clear examples — <em>especially tailored for Indian devs</em> working with Spring Boot or Java-based backends.</p><h3>What is a Thread?</h3><p>A <strong>Thread</strong> is a lightweight sub-process — the smallest unit of execution in Java. Think of it as a worker who can perform a task separately without disturbing others.</p><blockquote><em>🛵 Real-Life Analogy:<br> Imagine you’re running a food delivery app like Swiggy. You (main thread) take new orders, but each delivery guy (thread) goes out to fulfill one order. This helps you handle </em><strong><em>multiple orders</em></strong><em> at the same time — faster and efficiently.</em></blockquote><h3>Thread Lifecycle in Java</h3><p>A thread goes through different phases — just like a person’s life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/0*z5GGPcJlztW3-K3U.png" /></figure><h3>📌 1. New</h3><p>Thread is created but not started.<br> Thread t = new Thread();</p><h3>📌 2. Runnable</h3><p>After calling start(), thread is ready to run.<br> t.start();</p><h3>📌 3. Running</h3><p>Thread scheduler picks it, and now it’s <em>actually</em> executing.</p><h3>📌 4. Blocked / Waiting / Timed Waiting</h3><p>Thread is temporarily inactive, maybe waiting for some I/O or time delay.</p><h3>📌 5. Terminated</h3><p>Thread finishes or crashes.</p><blockquote><em>📦 Use Case:<br> In a railway booking system like IRCTC, threads are used to handle multiple booking requests. If one thread is waiting for payment confirmation, others continue processing.</em></blockquote><h3>How to Implement a Thread?</h3><p>There are <strong>three ways</strong> to implement a thread. Let’s break them down with examples you can relate to.</p><p>1. <strong>Extending the Thread class</strong></p><pre>class OrderProcessor extends Thread {<br>    public void run() {<br>        System.out.println(&quot;Processing order in thread: &quot; + Thread.currentThread().getName());<br>    }<br>}</pre><pre>public class Main {<br>    public static void main(String[] args) {<br>        OrderProcessor t1 = new OrderProcessor();<br>        t1.start();<br>    }<br>}</pre><p>🪛 When to use: Rarely. This limits you because Java doesn’t allow multiple inheritance.</p><p>2. <strong>Implementing Runnable</strong></p><pre>class OrderProcessor implements Runnable {<br>    public void run() {<br>        System.out.println(&quot;Order processed by: &quot; + Thread.currentThread().getName());<br>    }<br>}</pre><pre>public class Main {<br>    public static void main(String[] args) {<br>        Thread t = new Thread(new OrderProcessor());<br>        t.start();<br>    }<br>}</pre><p>💡 Better choice. Allows multiple inheritance since you’re not extending the Thread class.</p><p>3. <strong>Using Lambda Expression</strong></p><pre>public class Main {<br>    public static void main(String[] args) {<br>        Runnable task = () -&gt; System.out.println(&quot;Lambda thread: &quot; + Thread.currentThread().getName());<br>        new Thread(task).start();<br>    }<br>}</pre><p>⚡ Best for short, anonymous tasks. Cleaner and modern.</p><h3>🧵 But Threads Are Costly… What Now?</h3><p>Creating many threads manually is like hiring a new delivery guy for every single order — overhead!</p><p><strong>Enter ThreadPoolExecutor</strong> — a factory of worker threads that reuses a pool of existing threads.</p><h3>⚙️ ThreadPoolExecutor Explained Simply</h3><p>In Java, we manage threads efficiently using:</p><h3>1. Executor</h3><p>Basic interface with a single method: execute(Runnable command)</p><h3>2. ExecutorService</h3><p>A more advanced interface with submit(), invokeAll(), shutdown options, etc.</p><h3>3. ThreadPoolExecutor</h3><p>The actual implementation. You can use it directly or via helpers like Executors.newFixedThreadPool().</p><p>🧑‍💻 Example: Fixed Thread Pool</p><pre>import java.util.concurrent.*;<br><br>public class Main {<br>    public static void main(String[] args) {<br>        ExecutorService pool = Executors.newFixedThreadPool(3); // 3 delivery boys<br><br>        for (int i = 1; i &lt;= 5; i++) {<br>            int orderId = i;<br>            pool.execute(() -&gt; System.out.println(&quot;Delivering order #&quot; + orderId + &quot; by &quot; + Thread.currentThread().getName()));<br>        }<br><br>        pool.shutdown(); // no new tasks<br>    }<br>}</pre><p>💡 Imagine Zomato has only 3 delivery boys available. They’ll take turns picking the 5 orders.</p><h3>🌐 Real Life Use Case</h3><h3>Scenario: Tax Filing System for Govt Portal</h3><ul><li>Users upload tax documents (heavy parsing).</li><li>Each document is parsed in a separate thread using submit().</li><li>Parsed results are sent to the assessment engine.</li><li>Logs are updated using execute() (fire and forget).</li><li>This combo of thread handling ensures fast processing without overwhelming the server.</li></ul><h3>🚀 Pro Tips for Production</h3><ul><li>Always <strong>shutdown</strong> your thread pool (shutdown() or shutdownNow()).</li><li>Handle exceptions inside threads to avoid silent failures.</li><li>Monitor your pools using Spring Boot Actuator + Micrometer if you use Spring.</li><li>Use <strong>custom thread factories</strong> to give meaningful thread names.</li></ul><h3>🎯 Summary</h3><p>ConceptWhat It MeansThreadSmall unit of executionThread lifecycleNew → Runnable → Running → Waiting → TerminatedImplement threadsVia Thread, Runnable, or LambdaThreadPoolExecutorEfficient thread managerexecute() vs submit()void vs Future, simple vs trackable task</p><pre>+--------------------------------+-------------------------------------------------+<br>|            Concept             |                  What It Means                  |<br>+--------------------------------+-------------------------------------------------+<br>| Thread Small unit of execution |                                                 |<br>| Thread lifecycle               | New → Runnable → Running → Waiting → Terminated |<br>| Implement threads              | Via `Thread`, `Runnable`, or `Lambda`           |<br>| ThreadPoolExecutor             | Efficient thread manager                        |<br>| execute() vs submit()          | `void` vs `Future`, simple vs trackable task    |<br>+--------------------------------+-------------------------------------------------+</pre><h3>🔚 Final Words</h3><p>Multithreading is the backbone of modern Java apps — whether you’re building a stock trading platform, GST billing software, or a ridesharing app.</p><p>Understanding it well not only improves your app performance but also makes you stand out in interviews and on the job.</p><p><strong>Now go on, and multithread like a pro! 🧠🔥</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88376ac29f0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>