<?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 Sandesh Gaonkar on Medium]]></title>
        <description><![CDATA[Stories by Sandesh Gaonkar on Medium]]></description>
        <link>https://medium.com/@sandy619g?source=rss-9d5bbf410182------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Q11hfYqJooOCW3TIp03EJw.png</url>
            <title>Stories by Sandesh Gaonkar on Medium</title>
            <link>https://medium.com/@sandy619g?source=rss-9d5bbf410182------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 02:50:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sandy619g/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[The New HTTP QUERY Method: The Answer to the GET vs POST Debate]]></title>
            <link>https://medium.com/@sandy619g/the-new-http-query-method-the-answer-to-the-get-vs-post-debate-9f183b56551c?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f183b56551c</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[rest-api]]></category>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Fri, 03 Jul 2026 08:00:11 GMT</pubDate>
            <atom:updated>2026-07-03T08:00:11.694Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1gkD1o3ikJUBQJOhFCJD7Q.png" /></figure><p>One of the recurring debates in API design has always been: <strong>Which HTTP method should be used for complex queries?</strong></p><p>Simple filtering works perfectly with GET:</p><pre>GET /products?category=laptop&amp;brand=apple</pre><p>But as applications become more sophisticated, search endpoints often require dozens of filters, sorting rules, pagination options, nested criteria, and aggregations. That’s where the traditional HTTP methods start showing their limitations.</p><h3>The Problem with GET</h3><p>GET is the natural choice because it is safe and cacheable.</p><p>However, it has practical drawbacks:</p><ul><li>Query strings become excessively long.</li><li>URLs become difficult to read and maintain.</li><li>Some servers, proxies, and browsers impose URL length limits.</li><li>Complex objects have to be flattened into awkward query parameters.</li></ul><p>For example:</p><pre>GET /products?category=laptop&amp;brand=apple&amp;priceMin=1000&amp;priceMax=3000&amp;memory=32&amp;storage=1tb&amp;sort=price,-rating&amp;page=5&amp;availability=in-stock...</pre><p>As filtering grows, the URL quickly becomes unwieldy.</p><h3>Why Not Send a Body with GET?</h3><p>Some developers attempt to solve this by sending a request body with GET:</p><pre>GET /products</pre><pre>{<br>  &quot;category&quot;: &quot;laptop&quot;,<br>  &quot;filters&quot;: {<br>    &quot;memory&quot;: 32,<br>    &quot;storage&quot;: &quot;1TB&quot;<br>  }<br>}</pre><p>While the HTTP specification does not explicitly forbid a body on a GET request, it also doesn&#39;t define any semantics for it.</p><p>In practice:</p><ul><li>many HTTP clients don’t support it,</li><li>some proxies discard it,</li><li>various frameworks ignore it,</li><li>caches typically don’t consider the request body.</li></ul><p>This leads to inconsistent behavior across the ecosystem.</p><h3>Why POST Isn&#39;t Ideal</h3><p>The common workaround is to use POST:</p><pre>POST /products/search</pre><pre>{<br>  &quot;category&quot;: &quot;laptop&quot;,<br>  &quot;filters&quot;: {<br>    &quot;memory&quot;: 32,<br>    &quot;storage&quot;: &quot;1TB&quot;<br>  }<br>}</pre><p>This certainly works.</p><p>However, it introduces a semantic mismatch.</p><p>POST is primarily intended for creating resources or triggering server-side processing.</p><p>Using it purely for querying data makes it harder to distinguish between:</p><ul><li>commands that change state</li><li>requests that simply retrieve information</li></ul><p>It also affects caching behavior and can make APIs less intuitive.</p><h3>Enter the QUERY Method</h3><p>The HTTP QUERY method was introduced to address exactly this gap.</p><p>It provides a way to perform <strong>safe, read-only requests while allowing a request body</strong>.</p><p>Example:</p><pre>QUERY /products</pre><pre>{<br>  &quot;category&quot;: &quot;laptop&quot;,<br>  &quot;filters&quot;: {<br>    &quot;memory&quot;: 32,<br>    &quot;storage&quot;: &quot;1TB&quot;,<br>    &quot;price&quot;: {<br>      &quot;min&quot;: 1000,<br>      &quot;max&quot;: 3000<br>    }<br>  },<br>  &quot;sort&quot;: [<br>    &quot;price&quot;,<br>    &quot;-rating&quot;<br>  ],<br>  &quot;page&quot;: 5<br>}</pre><p>This combines the best aspects of both approaches:</p><ul><li>expressive JSON request bodies,</li><li>clear read-only semantics,</li><li>no oversized URLs,</li><li>no misuse of POST.</li></ul><h3>Benefits</h3><p>Using QUERY provides several advantages:</p><ul><li><strong>Safe by design</strong> — it does not modify server state.</li><li><strong>Supports complex request bodies</strong> without URL limitations.</li><li><strong>Clear intent</strong> — clients know this is a retrieval operation.</li><li><strong>Better API consistency</strong> by separating reads from writes.</li><li><strong>More future-friendly</strong> than relying on non-standard GET bodies.</li></ul><h3>When Should You Use QUERY?</h3><p>QUERY is an excellent fit for:</p><ul><li>advanced search APIs,</li><li>reporting endpoints,</li><li>analytics queries,</li><li>filtering large datasets,</li><li>faceted search,</li><li>graph-style queries,</li><li>complex sorting and pagination.</li></ul><p>Simple resource retrieval should still use GET:</p><pre>GET /users/42</pre><p>Complex searches become much cleaner:</p><pre>QUERY /users/search</pre><pre>{<br>  &quot;department&quot;: &quot;Engineering&quot;,<br>  &quot;skills&quot;: [<br>    &quot;Java&quot;,<br>    &quot;Kubernetes&quot;<br>  ],<br>  &quot;experience&quot;: {<br>    &quot;min&quot;: 5<br>  },<br>  &quot;sort&quot;: &quot;-salary&quot;<br>}</pre><h3>Final Thoughts</h3><p>For years, API developers had to choose between three imperfect options:</p><ul><li>very long GET URLs,</li><li>non-standard GET requests with bodies,</li><li>or semantically overloaded POST endpoints.</li></ul><p>The QUERY method offers a cleaner alternative by preserving the read-only nature of data retrieval while allowing rich request bodies.</p><p>As support across HTTP clients, servers, and frameworks grows, QUERY has the potential to become the preferred choice for complex search and retrieval APIs, giving developers a standardized solution to a problem that has existed since the early days of RESTful API design.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f183b56551c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[45 Minutes That Almost Killed a Company]]></title>
            <link>https://medium.com/@sandy619g/45-minutes-that-almost-killed-a-company-0b4aeea7a5a2?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b4aeea7a5a2</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Sat, 28 Feb 2026 14:07:49 GMT</pubDate>
            <atom:updated>2026-02-28T14:07:49.395Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMgUCPNB9xudlU99MWTXnA.png" /></figure><p>At 9:30 a.m., the stock market opened as usual.</p><p>By 10:15 a.m., one of America’s largest trading firms had lost <strong>$440 million</strong>.</p><p>No hackers.<br>No market crash.<br>Just a software deployment.</p><p>Knight Capital had pushed new trading code to its servers.<br>But not all of them.</p><p>Some machines ran the new logic.<br>Others quietly ran <strong>old, forgotten code</strong> that should never have been active.</p><p>The result?<br>The system started buying and selling stocks at insane speed. Humans watched helplessly as losses stacked up faster than anyone could react. Forty-five minutes later, the damage was done. The company never recovered.</p><p>This wasn’t a “bad programmer” problem.<br>It was a <strong>deployment problem</strong>.</p><h3>Why This Still Matters Today</h3><p>Modern systems are:</p><ul><li>automated</li><li>fast</li><li>distributed</li></ul><p>That means <strong>partial failure is the most dangerous failure</strong>.</p><p>If half your servers behave one way and half another, your system is already broken — you just don’t know it yet.</p><h3>How We Actually Do This Today</h3><p>Modern tools make this problem solvable.</p><h3>1. Immutable infrastructure</h3><p>Servers are not updated by hand.<br>They are <strong>replaced</strong>.</p><ul><li>Same image</li><li>Same config</li><li>Same version</li></ul><p>If it’s different, it doesn’t exist.</p><h3>2. Automated deployments</h3><p>Tools like:</p><ul><li>AWS CodeDeploy</li><li>Kubernetes</li><li>Spinnaker</li></ul><p>know exactly:</p><ul><li>which instances succeeded</li><li>which failed</li></ul><p>One failure → <strong>automatic rollback</strong>.</p><h3>3. Health checks that mean something</h3><p>If a server:</p><ul><li>runs the wrong version</li><li>fails a startup test</li><li>behaves strangely</li></ul><p>Traffic never reaches it.</p><h3>4. Blue/Green deployments</h3><p>New code goes live <strong>only after</strong> it proves it works.<br>If it doesn’t, users never notice.</p><h3>5. Kill switches and limits</h3><p>If something still goes wrong:</p><ul><li>one button stops everything</li><li>loss limits trigger shutdowns automatically</li></ul><p>Humans stay in control.</p><h3>Lesson Learned</h3><p>The bug wasn’t expensive because the code was complex.<br>It was expensive because <strong>failure wasn’t contained</strong>.<br>Modern engineering assumes: <em>code will fail — but systems must survive.<br></em>That’s the difference between a bad day…<br>and a company-ending morning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b4aeea7a5a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bloom Filters: The Secret Trick for Instant Username Checks]]></title>
            <link>https://medium.com/@sandy619g/bloom-filters-the-secret-trick-for-instant-username-checks-62f16a49843e?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/62f16a49843e</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Sun, 25 Jan 2026 09:02:15 GMT</pubDate>
            <atom:updated>2026-01-25T09:10:16.255Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever wondered how Instagram can instantly tell you that a username is already taken? Or how Gmail seems to know if an email address exists without breaking a sweat? Most engineers would instinctively reach for a database or an in-memory cache like Redis. But there’s a secret trick in the high-speed, high-scale world of tech — one that’s faster, lighter, and surprisingly clever. Meet the <strong>Bloom Filter</strong>.</p><h3>What is a Bloom Filter?</h3><p>Think of a Bloom Filter as a “memory ninja.” It doesn’t store the data itself but remembers <em>enough</em> to tell you:</p><ul><li>✅ “Definitely not here”</li><li>⚠️ “Maybe here”</li></ul><p>It’s a probabilistic data structure — fancy words for “sometimes it might lie, but never in the wrong direction.”<br>At its heart, it’s just:</p><ul><li>A <strong>bit array</strong> (a row of 0s and 1s)</li><li><strong>Multiple hash functions</strong></li></ul><p>With these, it can answer existence questions lightning fast <strong>without storing all the actual data</strong>.</p><h3>How Does It Work?</h3><p>Imagine you’re trying to register the username &quot;Loki&quot;:</p><ol><li>Start with a bit array of size m (all bits = 0).</li></ol><pre>Index: 0 1 2 3 4 5 6 7 8 9<br>Bits:  0 0 0 0 0 0 0 0 0 0</pre><p>2. Use k = 3 hash functions to hash &quot;Loki&quot; → say they produce positions <strong>2, 4, 7</strong>.</p><p>3. Flip those bits to 1.</p><pre>Index: 0 1 2 3 4 5 6 7 8 9<br>Bits:  0 0 1 0 1 0 0 1 0 0</pre><h3>Step 2: Check if someone is already registered</h3><h4>Case 1: Check &quot;Loki&quot;</h4><ul><li>Hash &quot;Loki&quot; → positions <strong>2, 4, 7</strong></li><li>Look at the bit array: bits <strong>2, 4, 7</strong> are all 1 → <strong>Loki might exist</strong> ✅</li></ul><h4>Case 2: Check &quot;Thor&quot;</h4><ul><li>Hash &quot;Thor&quot; → positions <strong>1, 3, 7</strong></li><li>Look at the bit array: bits <strong>1, 3, 7</strong></li><li>Bit <strong>1 = 0</strong> → <strong>Thor definitely does NOT exist</strong> ❌</li></ul><pre>Bit Array (size 10):<br>0 1 2 3 4 5 6 7 8 9<br>0 0 1 0 1 0 0 1 0 0<br><br>Check Loki: hash -&gt; 2,4,7 → 1 1 1 → Might exist<br>Check Thor: hash -&gt; 1,3,7 → 0 0 1 → Definitely not</pre><p>So basically:</p><ul><li><strong>Insertion:</strong> Hash the name → flip bits → store <strong>no actual name</strong>.</li><li><strong>Checking:</strong> Hash the name → check bits → if any 0 → definitely not; all 1 → maybe exists.</li></ul><h3>Why Not Just Use a Database?</h3><p>Databases are reliable, sure, but:</p><ul><li>Millions of queries per second? That’s expensive and slow.</li><li>Disk access is a bottleneck; memory-heavy queries can choke performance.</li></ul><p>Bloom filters answer the question <strong>without touching your database</strong> — in O(k) time. Perfect for:</p><ul><li>Instagram username checks</li><li>Email deduplication</li><li>Cache filtering</li></ul><h3>Why Not Just Use Redis?</h3><p>Caches store the full data. Bloom filters store <strong>bits</strong>. Big difference:</p><ul><li>Redis: 100 million emails → gigabytes of memory</li><li>Bloom filter: 100 million emails → a few <strong>megabytes</strong></li></ul><p>Your server breathes easy, your users get instant responses.</p><h3>Real-World Uses</h3><ul><li><strong>Username/email availability</strong> — Instagram, Gmail</li><li><strong>Web crawlers</strong> — Avoid visiting the same URL twice</li><li><strong>Spam filters</strong> — Quick “maybe spam” checks</li></ul><h3>Limitations</h3><ul><li>❌ False positives: Might say an element exists when it doesn’t</li><li>❌ No deletion in standard Bloom filters</li><li>⚙️ Requires careful tuning: bit array size and number of hash functions matter</li></ul><h3>Pro Tip</h3><p>Combine Bloom filters with a database or cache:</p><ol><li>Check the Bloom filter first.</li><li>If it says “might exist,” query the database to be sure.</li></ol><p>This gives you the <strong>best of both worlds: speed + reliability</strong>.</p><h3>Conclusion</h3><p>Bloom filters are the <strong>unsung heroes</strong> of high-speed systems. They’re lightweight, lightning-fast, and incredibly memory-efficient for existence checks.</p><p>⚠️ <strong>Not perfect, not magical</strong> — they trade a tiny bit of accuracy for huge gains in speed and space. But in systems that handle millions of queries per second, that trade-off is often a game-changer.</p><p>If you’re building:</p><ul><li><strong>Username availability checks</strong> like Instagram</li><li><strong>Email deduplication</strong></li><li><strong>Web crawlers</strong> that need to avoid revisiting the same URL</li></ul><p>Want to see it in action? Check out the full project on GitHub: <a href="https://github.com/sandy619g/bloom-filter.git">Bloom Filter Username Checker</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62f16a49843e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Lombok’s @Data Almost Broke My Codebase]]></title>
            <link>https://medium.com/@sandy619g/why-lomboks-data-almost-broke-my-codebase-feab28c8bd33?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/feab28c8bd33</guid>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Sun, 18 Jan 2026 23:50:40 GMT</pubDate>
            <atom:updated>2026-01-18T23:50:40.562Z</atom:updated>
            <content:encoded><![CDATA[<p>I thought I was writing clean code. I was proud of my neat, boilerplate-free classes, all thanks to Lombok’s @Dataannotation. <br>Then reality hit. Subtle bugs started creeping in, collections broke in ways I couldn’t explain, and important business logic disappeared into invisible methods. That little “shortcut” I trusted to save time was quietly eroding the design of my codebase and teaching me some hard lessons about what clean code really means.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KHhPJA7QtY0IqGtdzG7RTw.png" /></figure><pre>@Data<br>public class User {<br>    private Long id;<br>    private String email;<br>}</pre><p>One annotation. No boilerplate. Everyone’s happy until your codebase grows, your domain becomes complex, and you start noticing its behavior.</p><p>Let’s break down <em>why</em> @Data is a bad idea for serious projects.<br>@Data is not one thing. It’s <strong>six behaviors hidden behind one annotation</strong>:</p><ul><li>@Getter</li><li>@Setter</li><li>@ToString</li><li>@EqualsAndHashCode</li><li>@RequiredArgsConstructor</li></ul><p>When you use @Data, you are <strong>implicitly accepting defaults</strong> for:</p><ul><li>Equality semantics</li><li>Mutability</li><li>String representation</li><li>Constructor behavior</li></ul><p>Most of the time, you <em>don’t actually want all of these</em>.</p><h3>2. It Makes Your Domain Model Accidentally Mutable</h3><p>@Data generates setters for <em>all</em> fields.</p><pre>@Data<br>public class Employee {<br>    private String name;<br>    private int age;<br>}</pre><h3>3. equals() and hashCode() Are Generated Blindly</h3><p>By default, @Data includes <strong>all fields</strong> in equals() and hashCode().</p><pre>@Data<br>public class User {<br>    private Long id;<br>    private String email;<br>    private Instant lastLogin;<br>}</pre><h4>What happens:</h4><ul><li>Every field (id, email, lastLogin) is included in equality checks and hash code calculations.</li><li>If any of these fields <strong>change after the object is added to a collection</strong> (like HashSet or used as a HashMap key), the object’s hash code changes.</li><li>Collections rely on a consistent hash code to locate objects. If the hash changes, the object can <strong>no longer be found</strong>, even though it’s still in the collection.</li><li><strong>Objects “disappear” from collections</strong> — Looking up or removing an object may fail unexpectedly.</li></ul><h3>4. toString() Can Leak Sensitive Data</h3><p>@Data generates toString() including <strong>every field</strong>.</p><pre>@Data<br>public class UserCredentials {<br>    private String username;<br>    private String password;<br>}</pre><p>Now imagine this in logs:</p><pre>log.info(&quot;Login attempt: {}&quot;, userCredentials);</pre><h3>5. It Breaks Encapsulation by Default</h3><p>Encapsulation is not optional. It’s foundational.</p><p>@Data:</p><ul><li>Exposes all fields via getters</li><li>Allows mutation via setters</li><li>Removes control over object lifecycle</li></ul><p>You lose the ability to:</p><ul><li>Enforce invariants</li><li>Control state transitions</li><li>Change internals safely later</li></ul><h3>What to Do Instead</h3><h3>1. Use Lombok surgically, not blindly</h3><p>If you must use Lombok:</p><pre>@Getter<br>@ToString<br>public class User {<br>    private final Long id;<br>    private final String email;<br>}</pre><h3>2. Separate DTOs from Domain Models</h3><p>DTO and Domain serve different purposes.</p><pre>@Getter @Setter<br>public class UserDto {<br>    private String email;<br>}</pre><pre>public class User {<br>    private final Email email;<br><br>    public User(Email email) {<br>        this.email = email;<br>    }<br>}</pre><h3>3. Prefer Records (Java 16+)</h3><p>If your class truly <em>is</em> just data use Records<br>Records are:</p><ul><li>Explicit</li><li>Immutable</li><li>Language-level</li><li>Honest about intent</li></ul><pre>public record User(Long id, String email) {}</pre><h3>Conclusion :</h3><p>@Data teaches developers: <br>“All objects are DTOs” <br>“All fields should be mutable” <br>“Equality is always structural” <br>“Boilerplate is the real enemy” <br>In reality: Wrong abstractions are the real enemy Boilerplate is often a design signal, not a problem</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=feab28c8bd33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[McHire Data Breach: What Happened and How Gitleaks Could Have Helped Prevent It]]></title>
            <link>https://medium.com/@sandy619g/mchire-data-breach-what-happened-and-how-gitleaks-could-have-helped-prevent-it-de94d667dcba?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/de94d667dcba</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Fri, 11 Jul 2025 15:32:05 GMT</pubDate>
            <atom:updated>2025-07-11T15:32:05.070Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TLx8m2JTnSUXNaVDKgLNLA.png" /></figure><p>Recently security researchers discovered a critical vulnerability in <strong>McHire</strong> — McDonald’s AI-powered job application platform — exposing the personal data of over <strong>60 million job applicants</strong> worldwide.</p><p>At the heart of the breach?<br>A painfully simple admin login:</p><pre>Username: admin  <br>Password: 123456</pre><p>Yes, that’s it. The same password that tops every “Worst Passwords” list each year.</p><p>This was no elite cyberattack. It was a <strong>default credential</strong> left active in a production system, tied to an admin account with access to massive volumes of sensitive data — including full names, email addresses, phone numbers, work history, and more.</p><h3>⚠️ What Went Wrong?</h3><p>Security researcher discovered that the McHire backend had:</p><ul><li>A <strong>publicly accessible admin panel</strong></li><li>A <strong>default password still in place</strong></li><li>An <strong>IDOR (Insecure Direct Object Reference)</strong> flaw that allowed enumeration of user data</li></ul><p>The researchers responsibly disclosed the issue to McDonald’s and Paradox.ai (the vendor behind McHire), who patched it quickly.</p><h3>🔍 Could Gitleaks Have Helped Prevent This?</h3><p>Yes — and here’s how.</p><h3>🧰 What is Gitleaks?</h3><p><strong>Gitleaks</strong> is a lightweight, open-source tool that scans Git repositories for <strong>hardcoded secrets</strong>, such as:</p><ul><li>Passwords (like 123456)</li><li>API keys</li><li>Tokens</li><li>Database credentials</li><li>Slack webhooks</li><li>AWS/GCP/GitHub keys</li></ul><p>It helps teams <strong>catch sensitive data before it ever leaves their local machine</strong>, enters Git history, or gets deployed to production.</p><h3>🔐 Scenario: Catching Default Credentials with Gitleaks</h3><p>Let’s say an engineer created a test account in development with:</p><pre>const adminUsername = &quot;admin&quot;;<br>const adminPassword = &quot;123456&quot;;</pre><p>They committed it to the repo with a comment like:</p><pre># TODO: change this before going live</pre><p>That’s exactly the kind of code that <strong>Gitleaks would flag</strong>.</p><h3>Example Output:</h3><pre>{<br>  &quot;RuleID&quot;: &quot;generic-password&quot;,<br>  &quot;File&quot;: &quot;src/config.js&quot;,<br>  &quot;Line&quot;: 12,<br>  &quot;Secret&quot;: &quot;123456&quot;,<br>  &quot;Commit&quot;: &quot;4f3a2cd&quot;,<br>  &quot;Author&quot;: &quot;dev@example.com&quot;,<br>  &quot;Message&quot;: &quot;added temp admin creds&quot;<br>}</pre><p>Even if the developer <strong>deleted the file later</strong>, Gitleaks can scan <strong>full Git history</strong> and detect past commits with secrets still buried inside.</p><h3>🛡️ How Gitleaks Helps Prevent Incidents Like McHire</h3><p>RiskHow Gitleaks HelpsDefault passwordsFlags obvious values like 123456Hardcoded admin credsScans config files and secretsForgotten TODOsDetects secrets left in Git historyHuman errorPrevents secrets from being pushedCI/CD exposureStops secrets from entering pipelines</p><h3>🛠️ How to Use Gitleaks (Step by Step)</h3><h3>✅ 1. Install Gitleaks</h3><h4>macOS (via Homebrew):</h4><pre>brew install gitleaks</pre><h4>Windows:</h4><ul><li>Download binary from <a href="https://github.com/gitleaks/gitleaks/releases">Gitleaks releases</a></li></ul><h3>✅ 2. Scan a Local Repository</h3><pre>gitleaks detect --source .</pre><p>This scans the current Git repo using built-in rules and prints any secrets it finds.</p><h3>✅ 3. Scan Git History (All Commits)</h3><pre>gitleaks detect --source . --log-opts=&quot;--all&quot;</pre><p>This finds secrets even if they were deleted in later commits.</p><h3>✅ 4. Generate a Report</h3><pre>gitleaks detect --source . --report-format sarif --report-path report.sarif</pre><p>Formats supported:</p><ul><li>json</li><li>csv</li><li>sarif (great for GitHub Actions)</li></ul><h3>✅ 5. Ignore Known False Positives</h3><p>Create a .gitleaksignore or .gitleaks.toml config file to:</p><ul><li>Allow certain patterns</li><li>Skip files or paths</li><li>Customize rules for your stack</li></ul><p>Example:</p><pre>[[rules]]<br>description = &quot;Ignore local dev secret&quot;<br>regex = &#39;&#39;&#39;my_dev_secret&#39;&#39;&#39;</pre><h3>✅ 6. CI/CD Integration (e.g., GitHub Actions)</h3><p>Add a simple GitHub Action to fail a build if secrets are found</p><pre>name: Gitleaks Scan</pre><pre>on: [push, pull_request]</pre><pre>jobs:<br>  scan:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v3<br>      - name: Run Gitleaks<br>        uses: gitleaks/gitleaks-action@v2<br>        with:<br>          args: detect --source . --verbose --redact</pre><h3>✅ Security Isn’t Optional</h3><p>This breach reminds us that <strong>security isn’t about complexity — it’s about consistency</strong>.</p><p>Leaving a default password in production is a failure of process, not technology. And it’s preventable.</p><p>With tools like <strong>Gitleaks</strong>, teams can:</p><ul><li>Enforce secure coding practices</li><li>Scan repos automatically</li><li>Catch mistakes <em>before</em> they ship</li></ul><h3>🧠 Takeaways</h3><ol><li><strong>Never use default credentials in production.</strong></li><li><strong>Automate secrets scanning with Gitleaks.</strong></li><li><strong>Audit your codebase and Git history regularly.</strong></li><li><strong>Educate teams about secure development.</strong></li><li><strong>Always assume your repo might go public. Build accordingly.</strong></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de94d667dcba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID Principles In Real World]]></title>
            <link>https://medium.com/@sandy619g/solid-principles-in-real-world-6a99e57d4230?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a99e57d4230</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[solid-principles-in-java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Sun, 20 Apr 2025 18:44:41 GMT</pubDate>
            <atom:updated>2025-04-20T18:44:41.077Z</atom:updated>
            <content:encoded><![CDATA[<p>When explaining complex software design principles, using a relatable analogy makes learning easier and more enjoyable. And what’s more universally loved than Biryani?</p><p>Biryani is not just a dish — it’s an orchestrated process that requires careful planning, role separation, and adaptability, just like software development. Every element, from selecting the right spices to layering ingredients, contributes to the final masterpiece. Similarly, in software engineering, the SOLID principles ensure a structured and efficient approach to building scalable applications.</p><p>By comparing software design principles to Biryani preparation, we can make technical concepts feel intuitive and practical. Just as a chef follows a method to make perfect Biryani, developers follow SOLID principles to create robust and maintainable code.<br>So, let’s explore how each SOLID principle aligns with the art of cooking Biryani!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_Msc4oBIF5Beli8lLq2Iw.png" /></figure><ol><li><strong>Single Responsibility Principle<br></strong>A class should have only single responsibility and nothing more.</li></ol><p>Incorrect Approach<br>👨‍🍳🍽️💰 One person is cooking, taking orders, and handling payments — that’s too much on one plate!</p><pre>class BiryaniChef {<br>    void cookBiryani() {<br>        System.out.println(&quot;Cooking biryani...&quot;);<br>    }<br>    void takeOrder() {<br>        System.out.println(&quot;Taking customer order...&quot;);<br>    }<br>    void processPayment() {<br>        System.out.println(&quot;Processing payment...&quot;);<br>    }<br>}</pre><p>Correct Approach <br>👨‍🍳 One person cooks the biryani<br> 🧾 Another person takes orders<br> 💳 Another person handles payment</p><pre>class BiryaniChef {<br>    void cookBiryani() {<br>        System.out.println(&quot;Cooking biryani...&quot;);<br>    }<br>}<br><br>class OrderManager {<br>    void takeOrder() {<br>        System.out.println(&quot;Taking customer order...&quot;);<br>    }<br>}<br><br>class Cashier {<br>    void processPayment() {<br>        System.out.println(&quot;Processing payment...&quot;);<br>    }<br>}</pre><p><strong>2. Open/Closed Principle<br></strong>A class should be open for extension but closed for modification, We should be able to introduce new variations of Biryani without disturbing the existing process.</p><p>Incorrect Approach<br>👨‍🍳 Keeps going back to the recipe book and editing it every time a new Biryani type is added.</p><pre>class Biryani {<br>    void prepareBiryani(String type) {<br>        if (type.equals(&quot;Chicken&quot;)) {<br>            System.out.println(&quot;Preparing Chicken Biryani...&quot;);<br>        } else if (type.equals(&quot;Veg&quot;)) {<br>            System.out.println(&quot;Preparing Veg Biryani...&quot;);<br>        }<br>    }<br>}</pre><p>Correct Approach<br>📦 Add new Biryani types like plug-ins — <strong>no changes to existing code</strong>.<br> 🧩 Just implement a new class and you’re good to go!</p><pre>interface Biryani {<br>    void prepare();<br>}<br><br>class ChickenBiryani implements Biryani {<br>    @Override<br>    void prepare() {<br>        System.out.println(&quot;Preparing Chicken Biryani...&quot;);<br>    }<br>}<br><br>class VegBiryani implements Biryani {<br>    @Override<br>    void prepare() {<br>        System.out.println(&quot;Preparing Veg Biryani...&quot;);<br>    }<br>}</pre><p><strong>3. Liskov Substitution Principle<br></strong>Objects of a superclass should be replaceable with objects of a subclass without breaking the functionality of the program.</p><p>Incorrect Approach<br>📦🔄👎 Replacing Biryani with InstantBiryani causes a break in behavior it throws an error when preparing, and doesn&#39;t follow the same flow. Not all Biryani is cooked the same way!</p><pre>public class Biryani {<br>    public void prepare() {<br>        System.out.println(&quot;Preparing basic biryani...&quot;);<br>    }<br><br>    public void serve() {<br>        System.out.println(&quot;Serving with salad.&quot;);<br>    }<br>}<br><br>public class InstantBiryani extends Biryani {<br>    @Override<br>    public void prepare() {<br>        throw new UnsupportedOperationException(&quot;Instant Biryani does not support traditional cooking.&quot;);<br>    }<br><br>    @Override<br>    public void serve() {<br>        System.out.println(&quot;Serving cold instant biryani from a packet.&quot;);<br>    }<br>}</pre><p>Correct Approach<br>🔄 Substitution works perfectly! We can trust any Biryani subclass to behave correctly.</p><pre>public class Biryani {<br>    public void prepare() {<br>        System.out.println(&quot;Preparing basic biryani...&quot;);<br>    }<br><br>    public void serve() {<br>        System.out.println(&quot;Serving with salad.&quot;);<br>    }<br>}<br><br>public class ChickenBiryani extends Biryani {<br>    @Override<br>    public void prepare() {<br>        System.out.println(&quot;Preparing Chicken Biryani with spices and chicken.&quot;);<br>    }<br>}</pre><p><strong>4. Interface Segregation Principle<br></strong>Clients should not be forced to depend on methods they don’t use.</p><p>Incorrect Approach<br>👨‍🍳 Forced to also serve food, even though it’s not part of the chef’s job — leads to errors!</p><pre>interface RestaurantWorker {<br>    void cook();<br>    void serve();<br>}<br><br>class Chef implements RestaurantWorker {<br>    public void cook() {<br>        System.out.println(&quot;Cooking Biryani...&quot;);<br>    }<br><br>    public void serve() {<br>        throw new UnsupportedOperationException(&quot;Chef does not serve food!&quot;);<br>    }<br>}</pre><p>Correct Approach</p><p>👨‍🍳 Chef only cooks<br> 🤵 Waiter only serves</p><pre>interface Cook {<br>    void cook();<br>}<br><br>interface Server {<br>    void serve();<br>}<br><br>class BiryaniChef implements Cook {<br>    public void cook() {<br>        System.out.println(&quot;Cooking Biryani...&quot;);<br>    }<br>}<br><br>class Waiter implements Server {<br>    public void serve() {<br>        System.out.println(&quot;Serving Biryani...&quot;);<br>    }<br>}</pre><p><strong>5. Dependency Inversion Principle<br></strong>High level modules should not depend on low level modules.</p><p>Incorrect Approach<br>🏪 Restaurant is tightly coupled with ChickenBiryani — wants VegBiryani? Gotta change code!</p><pre>class BiryaniRestaurant {<br>    private ChickenBiryani biryani = new ChickenBiryani();<br><br>    void serveBiryani() {<br>        biryani.prepare();<br>    }<br>}</pre><p>Correct Approach<br>🔌 Plug-and-play Biryani types — just inject what you need<br> 🍽️ Restaurant depends on Biryani interface, not specific recipes</p><pre>class BiryaniRestaurant {<br>    private Biryani biryani;<br><br>    // Injecting dependency via constructor<br>    BiryaniRestaurant(Biryani biryani) {<br>        this.biryani = biryani;<br>    }<br><br>    void serveBiryani() {<br>        biryani.prepare();<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        BiryaniRestaurant restaurant = new BiryaniRestaurant(new ChickenBiryani());<br>        restaurant.serveBiryani();<br><br>        BiryaniRestaurant vegRestaurant = new BiryaniRestaurant(new VegBiryani());<br>        vegRestaurant.serveBiryani();<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a99e57d4230" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Conduct Meaningful Code Reviews?]]></title>
            <link>https://medium.com/@sandy619g/how-to-conduct-meaningful-code-reviews-6f8002267a50?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f8002267a50</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 18:08:58 GMT</pubDate>
            <atom:updated>2025-02-10T18:08:58.283Z</atom:updated>
            <content:encoded><![CDATA[<p>Code reviews are a crucial part of software development, ensuring code quality, knowledge sharing, and long-term maintainability. However, to make them truly effective, teams must measure their impact, set clear objectives, and avoid common pitfalls. In this blog, we’ll explore how to measure code reviews, define clear objectives, and highlight what not to do during the review process.</p><h3>How to Measure Team Code Review Effectiveness</h3><p>To ensure that code reviews are adding value to the development process, consider tracking the following metrics:</p><h3>1. Review Time</h3><p>How long does it take for a pull request (PR) to be reviewed and merged? A high review time might indicate bottlenecks in the process. Keeping review times reasonable helps maintain development velocity.</p><h3>2. Review Coverage</h3><p>Are all code changes being reviewed, or do some get overlooked? Every piece of code should be reviewed to maintain high standards and catch potential issues early.</p><h3>3. Number of Comments per Review</h3><p>Tracking the number of comments per review can indicate how thorough and engaged reviewers are. Zero comments indicate rubber-stamp code reviews, too few comments might suggest superficial reviews, while excessive comments may point to unclear code or inconsistent standards.</p><h3>4. Number of Participants in Reviews</h3><p>Monitoring how many team members participate in code reviews helps assess team engagement and collaboration. A diverse set of reviewers ensures broader knowledge sharing and more robust code quality checks.</p><h3>4. Defects Found in Reviews</h3><p>Tracking how many issues are caught during code review helps measure the effectiveness of the review process. If too many defects slip through, it may indicate a need for better review strategies.</p><h3>5. Code Quality Post-Review</h3><p>If bugs persist after code reviews, it might indicate superficial reviews or the need for stricter review guidelines.</p><h3>6. Developer Satisfaction</h3><p>Surveys or feedback from developers can reveal if the review process is helping them improve or becoming a bottleneck.</p><h3>Identifying the Objectives of Code Review</h3><p>A successful code review process should align with the following objectives:</p><h3>1. Ensure Code Quality</h3><p>Reviews should identify potential bugs, security vulnerabilities, and areas for optimization to maintain high code quality.</p><h3>2. Maintain Consistency</h3><p>Code reviews help enforce coding standards and best practices across the team, ensuring a uniform codebase.</p><h3>3. Enhance Collaboration</h3><p>Code reviews foster knowledge sharing among developers, improving overall team competency and cohesion.</p><h3>4. Reduce Technical Debt</h3><p>Addressing issues early prevents the accumulation of unmanageable problems, saving time and effort in the long run.</p><h3>5. Improve Performance &amp; Scalability</h3><p>Encouraging efficient and scalable coding practices ensures long-term success and maintainability.</p><h3>What NOT to Do in Code Reviews</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*spAd1S903CHmQt9gBnOREw.jpeg" /></figure><h3>1. Nitpicking Minor Issues</h3><p>Pointing out trivial formatting issues when automated tools (e.g., linters) can handle them wastes time. Focus on design, logic, and maintainability instead.</p><h3>2. Overlooking Code Readability</h3><p>If a piece of code is difficult to understand, request clarification rather than assuming it’s fine. Readability is key to maintainability.</p><h3>3. Rushing Through Reviews</h3><p>A quick “Looks good to me” (LGTM) without properly analyzing the changes can lead to undetected bugs and future issues.</p><h3>4. Ignoring Test Coverage</h3><p>Make sure tests are included and validate edge cases, rather than assuming the code works as expected.</p><h3>5. Being Harsh or Unconstructive</h3><p>Reviews should be respectful and supportive. Instead of saying, “This is wrong,” suggest, “Consider this approach for better performance.”</p><h3>6. Not Following Up</h3><p>If requested changes aren’t addressed, ensure there’s a process to verify fixes before approving the PR.</p><h3>Writing Better Code Review Comments</h3><p>Avoid comments that kill motivation:</p><p>❌ <strong>“This makes no sense.”</strong><br>❌ <strong>“Rewrite this entire thing.”</strong><br>❌ <strong>“What were you thinking?”</strong><br>❌ <strong>“I don’t like this variable name.”</strong><br>❌ <strong>“This is not how we do things here.”</strong></p><p>Instead, use comments that help teams grow:</p><p>✅ <strong>“What if we restructured this part to…”</strong><br>✅ <strong>“Our team pattern for this is… because…”</strong><br>✅ <strong>“This part was unclear to me, could we…”</strong><br>✅ <strong>“Help me understand the reasoning behind…”</strong><br>✅ <strong>“Could we make the name more descriptive by…”</strong></p><h3>Keep in Mind:</h3><p>When feedback is focused on the <strong>code</strong> rather than the <strong>person</strong>, developers feel less defensive and more open to discussions. The goal is to <strong>improve the codebase together</strong>, not to critique individuals.</p><p>🔹 Be objective, not personal.<br>🔹 Ask questions instead of making assumptions.<br>🔹 Offer suggestions, not just problems.<br>🔹 Remember: Every PR is an opportunity to learn!</p><h3>Final Thoughts</h3><p>An effective code review process helps teams improve code quality, share knowledge, and collaborate better. By tracking meaningful metrics, setting clear objectives, and avoiding common pitfalls, teams can turn code reviews into a productive and positive experience.</p><p>Want to improve your team’s code review culture? Start by focusing on constructive feedback, actionable suggestions, and a mindset of growth. Happy reviewing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f8002267a50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Anti Patterns of Software Engineering]]></title>
            <link>https://medium.com/@sandy619g/understanding-anti-patterns-of-software-engineering-7cc1353abd1d?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cc1353abd1d</guid>
            <category><![CDATA[software-craftsmanship]]></category>
            <category><![CDATA[engineering-excellence]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Sat, 20 Apr 2024 18:00:18 GMT</pubDate>
            <atom:updated>2024-04-20T18:00:18.974Z</atom:updated>
            <content:encoded><![CDATA[<p>Improving our grasp of design patterns and best coding practices is crucial. However, it’s equally important to recognize the existence of counterproductive coding practices, commonly known as anti-patterns. Anti-patterns, also referred to as anti-design patterns, are solutions to common challenges in software development that ultimately prove to be ineffective and harmful. Despite initially appearing beneficial, these practices often lead to problems like code duplication, decreased ease of maintenance, and lower software quality. Some common anti-patterns in software development include:</p><ol><li><strong>Spaghetti Code:</strong> <br>This anti-pattern refers to code that is poorly structured, with tangled and interwoven logic. Code with multiple for/ if statements is deeply nested and repetitive, making it difficult to understand, maintain, and modify.</li><li><strong>God Object: <br></strong>A single class that performs too many responsibilities, violating the Single Responsibility Principle (SRP) and leading to code that is difficult to maintain and test. God leads to low cohesion, high coupling, difficult to test and maintenance will be a nightmare as code grows.</li><li><strong>Magic Numbers:</strong> <br>Magic numbers are hard-coded numeric values scattered throughout the code without explanation or context, making the code less readable and maintainable. Code containing magic numbers is hard to reuse since the hard-coded numbers are specific to particular implementation. Better approach is to create meaningful constants, enumerations or store them into configuration files.</li><li><strong>Copy-Paste Programming: <br></strong>Repeatedly copying and pasting code instead of creating reusable functions or classes, leading to code duplication and maintenance nightmares.</li><li><strong>Big Ball of Mud: <br></strong>This term refers to a system that lacks a clear structure or architecture, with tangled dependencies and no separation of concerns, making it difficult to understand and modify. The reason for such code is mainly due to lack of boundary definitions for the responsibilities and accumulated technical depth, leading to modules with mixed concerns and functionality.</li><li><strong>Golden Hammer: <br></strong>Over-reliance on a single technology, tool, or design pattern for all problems, even when it’s not the best fit, leading to suboptimal solutions and missed opportunities for improvement. The best example for Golden hammer is nowadays teams embrace micro-services without considering simpler options like monoliths, it can result in unnecessary complexity.</li><li><strong>Not Invented Here :</strong> <br>Reinventing solutions to common problems instead of leveraging existing libraries, frameworks, or best practices, resulting in wasted time and resources. For instance, when developing an e-commerce website, investing resources in crafting a custom logging system instead of leveraging pre-existing solutions like log4j.</li><li><strong>Accidental Complexity: <br></strong>Adding unnecessary complexity to the codebase without providing corresponding benefits, making the system harder to understand and maintain.</li><li><strong>Bikeshedding:</strong> <br>Bikeshedding refers to the phenomenon where disproportionate time and resources are allocated to trivial or cosmetic details, yielding minimal return on investment (ROI), while neglecting more critical aspects of the project that could significantly impact its success and value proposition.</li><li><strong>Cargo Cult Programming:</strong> <br>Blindly applying code or practices without understanding the underlying principles or reasons behind them, leading to ineffective solutions and wasted effort.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cc1353abd1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embracing FIRST Testing Principles]]></title>
            <link>https://medium.com/@sandy619g/embracing-first-testing-principles-58a1c133781c?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/58a1c133781c</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[software-craftsmanship]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Wed, 13 Mar 2024 17:21:54 GMT</pubDate>
            <atom:updated>2024-03-13T17:21:54.412Z</atom:updated>
            <content:encoded><![CDATA[<p>“Clean code is more than just good practice, it’s a philosophy that fosters maintainability, readability, and collaboration within software development teams.”<br> In pursuit of clean code, it’s essential to extend our principles to testing. Following the FIRST principle ensures that tests are Fast, Independent, Repeatable, Self-Validating, and Timely, contributing to overall code cleanliness and reliability.</p><p><strong>Fast :</strong> <br>The speed of running unit tests is vital in software development. Fast tests give developers quick feedback, helping them spot and fix problems faster. <br>When unit tests are fast, developers can make small, gradual changes to code knowing that the test suite will quickly catch any errors. <br>Utilize features provided by testing frameworks such as JUnit to run tests in parallel, leveraging multiple CPU cores for faster execution. Running tests concurrently can significantly reduce overall test execution time, especially for large test suites.</p><pre>@Test<br>public void testAddPerformance() {<br>    // Arrange<br>    Calculator calculator = new Calculator();<br>    int a = 5;<br>    int b = 7;<br><br>    // Act<br>    long startTime = System.nanoTime();<br>    int result = calculator.add(a, b);<br>    long endTime = System.nanoTime();<br>    long durationInNano = endTime - startTime;<br>    double durationInMilli = durationInNano / 1_000_000.0;<br><br>    // Assert<br>    assertTrue(durationInMilli &lt; 10);<br>}</pre><h4>Independent :</h4><p>Unit tests must operate autonomously, free from interdependencies with other tests. This autonomy prevents cascading failures and encourages parallel execution, enhancing efficiency and reliability.</p><pre>import org.junit.jupiter.api.BeforeEach;<br>import org.junit.jupiter.api.Test;<br><br>public class CalculatorTest {<br>    private Calculator calculator;<br><br>    @BeforeEach<br>    public void setUp() {<br>        calculator = new Calculator();<br>    }<br><br>    @Test<br>    public void add_WhenAddingTwoNumbers_ReturnsSum() {<br>        int a = 5;<br>        int b = 7;<br><br>        int result = calculator.add(a, b);<br><br>        assertEquals(12, result);<br>    }<br><br>    @Test<br>    public void subtract_WhenSubtractingTwoNumbers_ReturnsDifference() {<br>        int a = 10;<br>        int b = 3;<br><br>        int result = calculator.subtract(a, b);<br><br>        assertEquals(7, result);<br>    }<br>}</pre><p><strong>Repeatable:</strong></p><p>Unit tests should yield consistent results when executed repeatedly, regardless of environmental variables. Repeatable tests increases the confidence in the test suite’s reliability and expedite the detection of regressions.</p><pre>@Test<br>public void add_WhenAddingTwoNumbers_ReturnsSum() {<br>   Calculator calculator = new Calculator();<br>   int a = 5;<br>   int b = 7;<br>  <br>   int result1 = calculator.add(a, b);<br>   int result2 = calculator.add(a, b);<br>  <br>   assertEquals(result1, result2);<br>}</pre><p><strong>Self Validating:</strong></p><p>A self-validating test ensures that the test can automatically determine whether the code under test is working correctly. This means that the test should use assertions to verify the output of the code, eliminating the need for manual interpretation. The test should be fully automated, including setup, method invocation, and result validation. No manual configuration should be necessary to run the test and validate the results. All necessary data should be provided in advance to allow the test to perform self-validation.</p><pre>@Test<br>public void divide_WhenDividingByZero_ThrowsException() {<br> Calculator calculator = new Calculator();<br> int a = 10;<br> int b = 0;<br><br> assertThrows(ArithmeticException.class, () -&gt; calculator.divide(a, b));<br>}</pre><p><strong>Timely:</strong></p><p>There should be no delay between writing tests and production code. The best way to achieve is to adhere to the test-driven development (TDD) approach. The test for the multiply method is written before implementing the method itself, this ensures timely test coverage and drives the implementation of features.</p><pre>@Test<br>public void multiply_WhenMultiplyingTwoNumbers_ReturnsProduct() {<br> Calculator calculator = new Calculator();<br> int a = 3;<br> int b = 4;<br> int result = calculator.multiply(a, b);<br> assertEquals(12, result);<br>}</pre><p><strong>Conclusion:</strong></p><p>By following the principles of First, Independent, Repeatable, self-verifying, and timely testing (FIRST), teams can create strong testing habits. This approach leads to clean and reliable code. FIRST principles ensure tests are not just functional, but also easy to understand, update, and run on time. By applying the clean code approach to testing, teams can work together more effectively to create better software.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58a1c133781c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Redis Rediscover: Escaping the ‘Just Another MySQL’ Trap!”]]></title>
            <link>https://medium.com/@sandy619g/redis-rediscover-escaping-the-just-another-mysql-trap-c62da36b84d0?source=rss-9d5bbf410182------2</link>
            <guid isPermaLink="false">https://medium.com/p/c62da36b84d0</guid>
            <category><![CDATA[cache-memory]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Sandesh Gaonkar]]></dc:creator>
            <pubDate>Mon, 12 Feb 2024 17:01:06 GMT</pubDate>
            <atom:updated>2024-02-12T17:01:06.775Z</atom:updated>
            <content:encoded><![CDATA[<p>Redis is an open-source, in-memory data structure store that serves as a high-performance and versatile database, cache, and message broker. It is often referred to as a “data structure server” because it primarily stores data in the form of key-value pairs, but it goes beyond simple key-value storage</p><p>However, the true potential of Redis can only be harnessed when developers break free from the notion that it’s just another MySQL. In this article, we’ll explore Redis unique strengths, common pitfalls to avoid, and outline strategies for leveraging its capabilities effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*ide_hkgsnQrY1kEuQjr0XA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2EaWJQLrPlFIWdKDMBtz6Q.png" /></figure><h3>Strategies for Effective Redis Utilization</h3><ol><li>Avoiding Relational Thinking:<br>· Redis is not a relational database, and trying to model your data with a relational mindset might not be the most efficient approach.<br>· Instead of normalizing data into multiple tables, consider de-normalization for faster access.</li><li>Exploit Redis Data Structures:<br>· Redis offers a range of powerful data structures like Lists, Sets, and Hashes.<br>· Understand their applications and use them judiciously for optimal results.<br>· Use List when order matters for efficient Push and Pop Operations.<br>· Use Set when uniqueness is crucial.<br>· Use Hashes when multiple fields per Entity.</li><li>Mindful Key Design:<br>· Keys in Redis play a vital role. Ensure they are intelligently designed, reflecting the nature of the data they represent.<br>· Resist the temptation to use generic keys that might compromise performance.</li><li>Memory Efficiency Matters:<br>· Redis operates in-memory, making memory usage critical. <br>· Design data structures with an awareness of their impact on system resources.<br>· Implement techniques like data partitioning to distribute load and optimize memory utilization.</li><li>Time-To-Live (TTL) for Key Expiry: <br>· Redis allows setting Time-To-Live (TTL) for keys, enabling automatic expiry of data after a certain period. <br>· Use TTL to manage cache expiration and prevent stale data accumulation.</li><li>Redis as a Complementary Cache:<br>· Rather than viewing Redis as a MySQL replacement, consider it as a complementary cache layer.<br>· Cache frequently accessed data in Redis to reduce the load on MySQL, enhancing overall system performance.</li></ol><h3>Conclusion: Redis, Unshackled!</h3><p>Breaking free from the ‘Just Another MySQL’ mindset allows developers to fully embrace the strengths of Redis. By understanding its unique features, strategically designing data models, and leveraging its native structures, Redis becomes a powerful ally in crafting efficient, high-performance applications. Redis is not just another database; it’s a revolutionary force when used purposefully, contributing to a paradigm shift in the way we approach data storage and retrieval.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c62da36b84d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>