<?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 Navod Dilshan on Medium]]></title>
        <description><![CDATA[Stories by Navod Dilshan on Medium]]></description>
        <link>https://medium.com/@navoddilshan9?source=rss-e8ce58d5f6d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*d_-kHjsoC1jIqkMasy27Eg.jpeg</url>
            <title>Stories by Navod Dilshan on Medium</title>
            <link>https://medium.com/@navoddilshan9?source=rss-e8ce58d5f6d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 19:54:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@navoddilshan9/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[Scaling Spring Apps — Episode 2: Improving Performance & Reliability of Connection-Pooled…]]></title>
            <link>https://navoddilshan9.medium.com/scaling-spring-apps-episode-2-improving-performance-reliability-of-connection-pooled-424b6023875e?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/424b6023875e</guid>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[database-design]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[oracle-database]]></category>
            <category><![CDATA[oracle]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Thu, 27 Aug 2026 15:04:24 GMT</pubDate>
            <atom:updated>2026-08-27T15:04:24.866Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scaling Spring Apps — Episode 2: Improving Performance &amp; Reliability of Connection-Pooled Applications</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-gIgMygWDFqfviMi.jpg" /></figure><p>Most Spring applications already use a connection pool. Once it’s wired up — whether that’s Oracle’s own Universal Connection Pool (UCP) or something more generic — nobody thinks twice about it: the pool exists, the app starts, queries run, and everyone moves on to the next feature.</p><p>The trouble starts later, and it rarely announces itself. A RAC instance fails over during patching. A load balancer drops a handful of TCP sessions during a network blip. Traffic doubles during a promotion. In all three cases, the pool itself doesn’t crash — it just quietly stops doing its job, and by the time anyone notices, it looks like a database problem, an application problem, or both at once.</p><p>What’s actually happening underneath is that a connection pool is a cache of stateful, long-lived TCP sessions to a database, and like any cache, it can hold stale entries, be sized for yesterday’s load, or leak entries it never returns. This article goes one level deeper than “here’s a config flag” — it explains <em>why</em> each of these three problems happens mechanically, how to prove which one you actually have using AWR and pool telemetry, and what the fix is actually doing under the hood.</p><h3>1. A Healthy Pool Is Not the Same as an Existing Pool</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*x5ZACuWBiGE9TeVZ.gif" /></figure><p>A connection pool’s entire value proposition is that establishing a TCP connection and negotiating an Oracle session is expensive — authentication, session memory allocation on the database side, network round trips for the handshake — so the pool amortizes that cost by keeping connections open and handing them out repeatedly instead of paying that cost per request.</p><p>The catch is that once a connection is handed out and reused dozens or thousands of times, the pool’s picture of that connection’s health is only as good as the last time it checked. If nothing forces a re-check, the pool is effectively trusting a connection object that may no longer correspond to anything alive on the wire. Combine that with a pool size chosen once under a specific load profile, and a JDBC contract that relies entirely on application code correctly returning connections in a finally block, and you have three independent ways for a &quot;working&quot; pool to quietly become an unhealthy one — without ever throwing an error until a request actually tries to use it.</p><h3>2. Diagnosing Before Tuning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*A3We5_NBqSLJIEPC.gif" /></figure><p>Changing pool configuration without first identifying which of the three problems you have is just moving levers and hoping. The two sources of truth are the database’s own workload history and the pool’s own runtime telemetry, and you need to read them together rather than in isolation.</p><p>On the database side, an AWR (Automatic Workload Repository) report gives you a window into what sessions were actually doing during a given interval. The wait event profile is the most useful part of it: a high proportion of time spent in SQL*Net message from client means sessions are open and idle, waiting on the application to send the next request — which usually points to the application holding connections open longer than it needs to, not a database-side problem. Wait events like enq: TX - row lock contention or enq: TM - contention, on the other hand, point to actual locking between transactions, which will look exactly like a stuck or &quot;leaked&quot; connection from the pool&#39;s point of view but has a completely different root cause and fix.</p><p>Because AWR reports are built from snapshots taken at an interval, short-lived spikes can get averaged into invisibility, which is where Active Session History (ASH) is more useful — it samples active sessions much more frequently and lets you reconstruct what was happening second by second during an incident rather than over an hour-long window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bKLqtMmgDyWm1xYxE98iEA.png" /></figure><p>On the application side, UCP exposes its own runtime state through JMX MBeans, and the same numbers are available programmatically through the oracle.ucp.jdbc.PoolDataSource interface itself, without needing a separate monitoring agent:</p><pre>PoolDataSource pds = (PoolDataSource) dataSource;</pre><pre>System.out.println(&quot;Active connections: &quot; + pds.getBorrowedConnectionsCount());<br>System.out.println(&quot;Available connections: &quot; + pds.getAvailableConnectionsCount());<br>System.out.println(&quot;Total connections: &quot; + pds.getTotalConnectionsCount());<br>System.out.println(&quot;Peak connections: &quot; + pds.getPeakConnectionsCount());<br>System.out.println(&quot;Connections created since start: &quot; + pds.getConnectionsCreatedCount());<br>System.out.println(&quot;Connections closed: &quot; + pds.getConnectionsClosedCount());</pre><p>The four numbers worth watching continuously rather than only during an incident are the count of borrowed versus available connections, the peak connection count relative to maxPoolSize, the cumulative connections-created count sampled over time to derive a creation <em>rate</em>, and — covered in section 5 — how often the abandoned-connection timeout fires. A rising connection-creation rate is a particularly good early warning sign, because a healthy pool creates connections rarely — it&#39;s supposed to reuse them — so a pool that&#39;s constantly creating new ones is telling you it&#39;s discarding old ones faster than expected, which usually traces back to exactly one of the three problems below.</p><h3>3. Why Connections Go Stale After Failover, and How Validation Actually Fixes It</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*Uf33gKjBSdMRRZWu.gif" /></figure><p>When a RAC instance goes down or a network device between the application and the database briefly drops a session, the failure happens at the TCP layer, underneath the JDBC driver. The Connection object sitting in the pool has no way of knowing this on its own — from the pool&#39;s perspective, that object is just a Java reference with no active monitoring of the socket underneath it. The pool will happily hand that connection to the next thread that asks for one, and only when that thread executes a query does the failure surface, typically as an IOException wrapped in a SQLException, in the middle of whatever transaction that thread was running.</p><p>Validation on borrow closes this gap by making the pool run a trivial round trip — SELECT 1 FROM DUAL — before handing the connection out, rather than trusting the connection object&#39;s last known state. If that round trip fails, the pool discards the connection and gets a fresh one before the application ever sees a failure. UCP exposes this directly on the PoolDataSource:</p><pre>PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();<br>pds.setValidateConnectionOnBorrow(true);</pre><p>The cost is a small amount of added latency on every checkout, since you’re paying for an extra network round trip you weren’t paying before; for most transactional workloads where a single request already makes several database calls, that added latency is negligible next to the cost of a mid-transaction failure surfacing in application code.</p><p>UCP takes a fundamentally different approach on top of validation, using FAN (Fast Application Notification). Instead of the pool discovering a dead node reactively, on the next checkout, Oracle RAC publishes an event through ONS (Oracle Notification Service) the moment an instance goes down or comes back up, and UCP subscribes to that event stream directly:</p><pre>pds.setFastConnectionFailoverEnabled(true);<br>pds.setONSConfiguration(&quot;nodes=racnode1:6200,racnode2:6200&quot;);</pre><p>This means connections tied to a failed instance get marked and evicted proactively, often before an application thread ever attempts to use one — the difference between detecting a failure on next use and detecting it the instant it occurs, which matters most during the first few seconds after a RAC failover when a generic pool would otherwise be handing out dead connections indiscriminately.</p><h3>4. Why Pool Size Drifts Out of Sync With Load</h3><p>Pool size is almost always chosen once, during initial load testing, based on the traffic and query latency observed at that time — and it’s rarely revisited because nothing about an undersized pool looks like a hard failure. Instead, it looks like requests taking slightly longer than they used to, because threads are queuing for a connection instead of failing outright. This is what makes it dangerous: it degrades gradually enough that “a bit slower than before” becomes the new normal long before anyone treats it as a regression.</p><p>The way to catch this before it becomes a perceived slowdown is to model expected concurrent database demand directly, rather than inferring it from symptoms. If your peak request rate is R requests per second, and each request holds a database connection for an average of D seconds, then the expected number of concurrently held connections at peak is approximately R multiplied by D — Little’s Law applied to a connection pool. If that number is consistently close to or above your configured maxPoolSize, threads will queue for a connection as a matter of course, not as an exception, and the pool&#39;s getBorrowedConnectionsCount() and getAvailableConnectionsCount() values from section 2 will show it clearly if you&#39;re watching them.</p><pre>pds.setInitialPoolSize(10);<br>pds.setMinPoolSize(10);<br>pds.setMaxPoolSize(50);<br>pds.setConnectionWaitTimeout(10); // seconds a thread will wait before timing out</pre><p>On a RAC-backed system there’s a second dimension to this that a generic pool can’t see at all: whether load is actually distributed evenly across instances. Because a plain JDBC connection pool treats every connection identically once it’s established, one RAC instance can end up serving a disproportionate share of traffic simply due to connection age and reuse patterns, while another instance sits comparatively idle. This is where Runtime Connection Load Balancing (RCLB) comes in — but it isn’t a separate setting to turn on. It rides on the same FCF and ONS configuration from section 3: once setFastConnectionFailoverEnabled(true) and setONSConfiguration(...) are in place, UCP starts receiving live load feedback from each RAC instance through that same notification channel and weights new connection requests toward whichever instance currently has more headroom. The one thing worth checking on the database side is that the RAC service itself is configured with a load-balancing goal (via srvctl or DBMS_SERVICE) — without that, UCP has nothing to weight against, no matter how the pool is configured.</p><h3>5. Why Leaks Are the Slowest Problem to Notice and How to Catch Them Early</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*s1K4RPOd2K4G5mF_.gif" /></figure><p>A connection leak happens when application code borrows a connection and, due to an exception path that skips the finally block or a forgotten close() call, never returns it to the pool. From the pool&#39;s perspective, that connection isn&#39;t broken and isn&#39;t idle — it&#39;s simply checked out indefinitely, occupying a slot that will never come back on its own. A single leaked connection is invisible; the pool has plenty of others to give out. The problem compounds specifically because leaks are rarely a single bug firing constantly — they&#39;re usually a rare exception path that fires occasionally, across enough requests over enough days, until the pool&#39;s available capacity has quietly eroded to nothing and every new request starts timing out at once.</p><p>The direct fix is enabling UCP’s abandoned-connection timeout, which tells the pool to reclaim (and log) a connection that’s been checked out longer than any legitimate query should take:</p><pre>pds.setAbandonedConnectionTimeout(120); // seconds<br>pds.setTimeToLiveConnectionTimeout(0);  // 0 = no forced max lifetime</pre><p>Pairing this with a query against V$SESSION from the database side confirms exactly which sessions are sitting open longest, and for how long:</p><pre>SELECT sid, serial#, username, status, last_call_et, sql_id<br>FROM v$session<br>WHERE username = &#39;YOUR_APP_USER&#39;<br>ORDER BY last_call_et DESC;</pre><p>last_call_et gives you the number of seconds since the session&#39;s last activity — a session sitting at several thousand seconds with status = &#39;INACTIVE&#39; is a strong candidate for a leaked connection.</p><p>There’s a second failure mode that looks identical to a leak from the pool’s point of view but has nothing to do with application code at all: a connection that’s correctly held by a thread, but that thread is blocked waiting on a database lock held by another session. Distinguishing the two means querying blocking chains directly:</p><pre>SELECT blocking_session, sid, serial#, wait_class, seconds_in_wait<br>FROM v$session<br>WHERE blocking_session IS NOT NULL;</pre><p>If you find genuine blocking sessions there, the fix is in transaction design or indexing, not in the connection pool at all, and no amount of pool tuning will resolve it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rdc6jIVwnAZ3FcRVUd0dDA.png" /></figure><h3>6. Configure Around Your Application, Not Around Best Practice Numbers</h3><p>None of the settings above have a universally correct value, and copying a number from a blog post — including this one — without checking it against your own application’s behavior tends to create a new problem while fixing another. The abandoned-connection timeout from section 5 is the clearest example: if a particular batch job or reporting query legitimately holds a connection for two minutes, setting that timeout to thirty seconds doesn’t catch a leak, it forcibly kills a connection that’s doing exactly what it’s supposed to do, and you’ll spend an afternoon debugging a “leak” that was never a leak at all. The same logic applies in the other direction — connectionWaitTimeout, maxPoolSize, and validation overhead all need to be set against what your application actually does, not against a number that worked for someone else&#39;s workload.</p><p>The practical way to get this right is to pull the real numbers first — how long connections are typically held, per endpoint if they vary widely, using the V$SESSION query from section 5 or your own request-timing metrics — and set thresholds a comfortable margin above that observed behavior, rather than picking a round number and hoping. Revisit these numbers periodically too, since application behavior drifts as features are added, and a timeout that was generous a year ago can quietly become too tight as query patterns change.</p><h3>7. Where This Leaves Us</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*lbM8Q4lhw9r5UmDl.gif" /></figure><p>Applying validation on borrow, sizing the pool against Little’s Law instead of a one-time guess, and enabling abandoned-connection detection alongside routine AWR review turns three of the most common causes of “unexplained” production instability into things that are visible well before they become an incident. Failover-related errors drop because dead connections are caught before they’re handed out. Latency creep from undersized pools becomes visible in the pool’s own metrics months before users notice it. Leaks surface within minutes of occurring instead of as a total pool exhaustion event days later.</p><p>The broader lesson is that a connection pool existing in your application tells you nothing about whether it’s healthy — health has to be actively verified, sized against real demand, and monitored on both the database side and the application side simultaneously, because either side alone gives you an incomplete picture. UCP’s validateConnectionOnBorrow, FAN, and RAC load balancing close gaps that a generic, Oracle-unaware pool has no way to perceive at all — a node failing over or one instance carrying more load than another simply aren&#39;t visible to a plain JDBC pool.</p><p>Happy coding!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=424b6023875e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stacked Diffs Explained: The Code Review Workflow Top Engineering Teams Swear By]]></title>
            <link>https://navoddilshan9.medium.com/stacked-diffs-explained-the-code-review-workflow-top-engineering-teams-swear-by-bb1d16b8ca21?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb1d16b8ca21</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[stackpr]]></category>
            <category><![CDATA[gitstackpr]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 09:20:43 GMT</pubDate>
            <atom:updated>2026-08-05T06:57:43.840Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/910/0*mla9qdhuFbNzTk9A.png" /></figure><p>You open a pull request. It touches 40 files, changes 1,800 lines, and the description just says “auth refactor.” Your reviewer skims it, leaves two comments, and approves it three days later because nobody has the time — or the courage — to actually read the whole thing.</p><p>If that sounds familiar, you’ve met the monolithic PR problem. And there’s a workflow that’s been quietly solving it at the biggest engineering orgs in the world for over a decade: <strong>stacked diffs</strong>, also known as <strong>stacked pull requests</strong>.</p><p>Here’s what it is, why it works, where it came from, and how you can start using it this week — no matter what Git host your team is on.</p><h3>What Are Stacked Diffs?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*rZ_vnPeEeHG_9s8f.gif" /></figure><p>A stacked diff is a small, self-contained code change that depends on the change directly below it, submitted as its own pull request for review. Instead of one giant PR for a feature, you get a <strong>chain of small PRs</strong>, each one building on the last, reviewed and merged roughly in order from the bottom up.</p><p>Picture a feature that would normally be one 1,500-line PR. Stacked, it becomes:</p><ol><li><strong>PR 1</strong> — Add the data model</li><li><strong>PR 2</strong> — Add the API endpoints (builds on PR 1)</li><li><strong>PR 3</strong> — Add the UI (builds on PR 2)</li></ol><p>Each one is reviewable in minutes, not hours. Each one can be approved and merged independently, in sequence, without waiting for the whole feature to be “done.”</p><h3>The Core Benefits</h3><ul><li><strong>Faster, higher-quality reviews.</strong> Reviewers can actually read a 150-line diff carefully instead of skimming an 1,800-line one.</li><li><strong>You’re never blocked.</strong> Keep building diff #3 while diff #1 is still waiting on review.</li><li><strong>Feedback stays contained.</strong> A requested change on diff #2 doesn’t force you to re-touch diff #3 or reopen the whole feature.</li><li><strong>Continuous merging.</strong> Approved work ships to the main branch immediately, instead of the whole feature waiting on one final sign-off.</li><li><strong>Easier rebasing.</strong> Working in small diffs eases the burden of rebasing against the trunk branch, compared to maintaining one large, long-lived feature branch.</li></ul><h3>How to Do It, With Real Commands</h3><p>You don’t need any special tool to try this — plain Git works. Let’s say you’re building a feature with three parts: a data model, an API endpoint, and a UI component.</p><h3>Step 1: Branch off main for the first small change</h3><pre>git checkout main<br>git pull</pre><pre>git checkout -b feature/1-data-model<br># ...make your changes...<br>git add .<br>git commit -m &quot;Add User data model&quot;<br>git push -u origin feature/1-data-model</pre><p>Now open a pull request: feature/1-data-model → main.</p><h3>Step 2: Branch again — off your new branch, not main</h3><p>This is the actual “stacking” step. Your second branch starts from the first one, so it includes those commits too.</p><pre>git checkout -b feature/2-api-endpoint<br># ...make your changes...<br>git add .<br>git commit -m &quot;Add API endpoint for user creation&quot;<br>git push -u origin feature/2-api-endpoint</pre><p>Open a second pull request: feature/2-api-endpoint → feature/1-data-model (not main).</p><h3>Step 3: Repeat for the next piece</h3><pre>git checkout -b feature/3-ui-component<br># ...make your changes...<br>git add .<br>git commit -m &quot;Add signup form UI&quot;<br>git push -u origin feature/3-ui-component</pre><p>PR #3: feature/3-ui-component → feature/2-api-endpoint.</p><p>You now have a stack: main → PR1 → PR2 → PR3.</p><h3>Step 4: Merge from the bottom up</h3><p>Once PR #1 is approved, merge it into main. Then retarget PR #2 so it points at main instead of the now-gone feature/1-data-model branch. Repeat for PR #3.</p><h3>Step 5: If feedback comes in on an earlier branch</h3><p>Say a reviewer asks for a change on feature/1-data-model, after you&#39;ve already built #2 and #3 on top of it.</p><pre>git checkout feature/1-data-model<br># ...make the fix...<br>git add .<br>git commit -m &quot;Address review feedback&quot;<br>git push</pre><pre># Now update everything above it in the stack<br>git checkout feature/2-api-endpoint<br>git rebase feature/1-data-model<br>git push --force-with-lease</pre><pre>git checkout feature/3-ui-component<br>git rebase feature/2-api-endpoint<br>git push --force-with-lease</pre><p>Each rebase pulls the fix down through the stack so every branch above it stays in sync.</p><p>That’s the whole mechanic. It’s just branches on branches, with pull requests chained the same way. Doing it by hand is fine for a 2–3 PR stack; once you’re doing this often, dedicated stacking tools can automate the rebasing and retargeting for you — but you don’t need one to get started.</p><h3>The Latest: Native Tooling Just Shipped (July 2026)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*afp6ASgkCh4YQNnR.gif" /></figure><p>Everything above works with plain Git, no extra tooling required. But it’s worth knowing that stacked PRs just went mainstream: GitHub’s own CLI extension for this, gh stack, entered public preview on <strong>July 30, 2026</strong>. It automates the branching, rebasing, and PR-linking steps above so you don&#39;t have to run them by hand.</p><p>Here’s the same 3-PR example from before, done with the real, current commands:</p><pre># Install the extension once<br>gh extension install github/gh-stack</pre><pre># 1. Start a new stack (creates and checks out the first branch)<br>gh stack init feature-data-model</pre><pre># ...write code for the data model...<br>gh stack add -Am &quot;Add User data model&quot;</pre><pre># 2. Add the next layer on top<br>gh stack add -Am &quot;Add API endpoint for user creation&quot; feature-api-endpoint</pre><pre># ...write code...</pre><pre># 3. Add the final layer<br>gh stack add -Am &quot;Add signup form UI&quot; feature-ui</pre><pre># 4. Push everything and open all three PRs, linked as a stack<br>gh stack submit</pre><p>gh stack submit pushes all three branches and opens a linked stack of pull requests in one shot, each one based on the branch below it.</p><p>When feedback comes in on the bottom layer:</p><pre># Jump to the bottom of the stack<br>gh stack bottom</pre><pre># ...make the fix, commit...</pre><pre># Rebase everything above it in the stack automatically<br>gh stack rebase</pre><pre># Push the updated branches<br>gh stack push</pre><p>And once the bottom PR merges:</p><pre># Sync the stack — fetches, rebases what&#39;s left, and offers to<br># delete the now-merged branch<br>gh stack sync --prune</pre><p>That’s the whole workflow, just with the manual git rebase/git push --force-with-lease steps automated for you. If you&#39;re doing this often enough that the plain-Git version gets tedious, this is the tool to reach for.</p><h3>A Fair Warning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*6cURIW_f5cQOBjhc" /></figure><p>Stacking isn’t free. Squash-merging breaks the commit references that downstream PRs in a stack depend on, which causes conflicts to cascade through the rest of the stack — so most teams use regular merge commits for every PR in the chain except the last one. And if your PRs are already small and mostly independent, you don’t need this workflow at all — just open separate PRs. Stacking earns its keep specifically when changes are <em>both</em> small <em>and</em> genuinely dependent on each other.</p><h3>Should Your Team Adopt It?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*p2RH8Xy-DC7AHfAB.gif" /></figure><p>If your PRs regularly creep past 500 lines, if reviews sit for days, or if engineers avoid giving feedback because “the diff is too big to properly reason about” — stacking is worth trying. Start small: pick one feature, break it into 2–3 diffs, and see how much faster it moves through review compared to your usual process.</p><p>The teams that build the fastest aren’t the ones writing the most code per PR. They’re the ones who’ve figured out how to make each individual change small enough that nobody’s afraid to actually read it.</p><p>Happy Coding !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb1d16b8ca21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Axios Supply Chain Attack: The Day JavaScript Developers Got Owned]]></title>
            <link>https://navoddilshan9.medium.com/axios-supply-chain-attack-the-day-javascript-developers-got-owned-3ebef3ca7ef4?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ebef3ca7ef4</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[axios]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 21:06:53 GMT</pubDate>
            <atom:updated>2026-04-01T21:06:53.451Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UteH2dnSkoCIIMZVWmgHuQ.png" /></figure><blockquote>A single <em>npm install</em>… and your machine could already be compromised.</blockquote><h3>What Happened?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*DO0_llIhE7QPQGH4.gif" /></figure><p>On March 31, 2026, the JavaScript ecosystem faced one of its most alarming security incidents.</p><p>The widely used HTTP client library <strong>Axios</strong>, with over <strong>100 million weekly downloads</strong>, became the target of a <strong>sophisticated supply chain attack</strong>.</p><p>Two malicious versions were published to npm not with obvious malware. but with something far more dangerous:</p><p>A <strong>Remote Access Trojan (RAT)</strong> delivered through a hidden dependency.</p><p>This wasn’t just another vulnerability.</p><p>This was <strong>a silent, precision-guided compromise of developer machines and CI/CD pipelines</strong>.</p><h3>Why This Attack Is Terrifying</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/0*7ger9fmLRRTPVI8H.gif" /></figure><p>Let’s be clear:</p><blockquote><strong>Axios itself was NOT compromised at the source code level.</strong></blockquote><p>Instead, attackers used a classic but highly evolved strategy:</p><h3>The Attack Chain</h3><ol><li>Compromise maintainer credentials (likely npm token theft)</li><li>Publish malicious versions of Axios</li><li>Inject a fake dependency: plain-crypto-js</li><li>Trigger a postinstall script during npm install</li><li>Download a RAT from a remote server</li><li>Execute it silently</li><li><strong>Erase all traces</strong></li></ol><h3>What Attackers Can Access</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*8xkr4uxfUNnJT4YQ.gif" /></figure><p>If infected, attackers may already have:</p><ul><li>AWS credentials</li><li>API keys (OpenAI, Stripe, etc.)</li><li>SSH keys</li><li>Environment variables</li><li>Source code</li><li>CI/CD secrets</li></ul><blockquote>In short: <strong>your entire digital infrastructure</strong></blockquote><h3>How to Check If You’re Affected</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*aO35elzSwVmERxj0.gif" /></figure><h3>Step 1: Check Your Axios Version</h3><p>Look in your package.json.</p><p>If you installed Axios recently, especially around the incident window , <strong>you might be at risk</strong>.</p><ul><li>axios@1.14.1</li><li>axios@0.30.4</li></ul><h3>Step 2: Look for Suspicious Dependency</h3><p>Search inside node_modules:</p><pre>plain-crypto-js</pre><p>If this exists: <strong>Red flag</strong></p><h3>Step 3: Detect the RAT</h3><p>Run system-level checks (based on OS) to detect malicious binaries.</p><p>If found:</p><blockquote><em>Deleting it is NOT enough<br>our system is already compromised</em></blockquote><h3>Immediate Actions</h3><ol><li><strong>Downgrade Axios immediately to a safe version:</strong></li></ol><pre>npm install axios@1.14.0<br><br>or<br><br>npm install axios@0.30.3</pre><p><strong>2. Rotate all credentials and secrets immediately:</strong></p><ul><li>API keys (OpenAI, Stripe, etc.)</li><li>Cloud credentials (AWS, GCP, Azure)</li><li>SSH keys</li><li>GitHub / CI/CD tokens</li></ul><p><strong>3. Pin Axios version and audit lockfiles:</strong></p><ul><li>Ensure your package-lock.json or yarn.lock has the pinned safe version</li><li>Do <strong>not upgrade</strong> until a safe patched version is officially released</li></ul><h3>Root Cause: A Broken Trust Model</h3><p>This attack exposes a fundamental issue in modern software development:</p><blockquote><strong><em>We trust third-party packages too much.</em></strong></blockquote><p>Even a trusted library like Axios can become a delivery vehicle for malware.</p><h3>The Bigger Problem: npm Supply Chain Risks</h3><p>Modern JavaScript apps:</p><ul><li>Depend on hundreds of packages</li><li>Which depend on thousands more</li></ul><blockquote>One compromised dependency = <strong>total system compromise</strong></blockquote><h3>Hard Truth: This Will Happen Again</h3><p>This isn’t the last attack. It’s a <strong>preview of the future</strong>.</p><p>Attackers are no longer targeting apps directly; they’re targeting the <strong>tools developers trust</strong>.</p><h3>Final Thoughts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*k4Qh7BR7XuMFnPcs.gif" /></figure><p>The Axios incident is a wake-up call.</p><blockquote><em>“Convenience is the enemy of security.”</em></blockquote><p>As developers, we optimized for:</p><ul><li>Speed</li><li>Developer Experience</li><li>Convenience</li></ul><p>But ignored:</p><ul><li>Trust boundaries</li><li>Supply chain risks</li></ul><p>Reference: <a href="https://securitylabs.datadoghq.com/articles/axios-npm-supply-chain-compromise/">https://securitylabs.datadoghq.com/articles/axios-npm-supply-chain-compromise/</a></p><p>Happy coding!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ebef3ca7ef4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling Spring Apps — Episode 1: Handling Oracle DB Connection Limit Exceeded with DRCP]]></title>
            <link>https://navoddilshan9.medium.com/scaling-spring-apps-episode-1-handling-oracle-db-connection-limit-exceeded-with-drcp-a2c6862aad5f?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2c6862aad5f</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[oracle-database]]></category>
            <category><![CDATA[scalable-applications]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Sun, 11 Jan 2026 18:16:59 GMT</pubDate>
            <atom:updated>2026-01-11T18:16:59.737Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scaling Spring Apps — Episode 1: Handling Oracle DB Connection Limit Exceeded with DRCP</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*ytIhqpmNwgBNrQgzZpg2Nw.png" /></figure><p>When building high-concurrency Spring applications, database connection management can easily become a bottleneck. One common problem is <strong>“ORA-00018: maximum number of sessions exceeded”</strong> — a situation many developers encounter when scaling their applications.</p><p>This article explains how <strong>Database Resident Connection Pooling (DRCP)</strong> can solve this problem efficiently and improve application scalability.</p><h3>1. Why Connection Limits Happen</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*Mzp2naR9zX94zzb2.gif" /></figure><p>Even with application-level connection pools (HikariCP, UCP), Oracle sessions can exceed limits because:</p><ul><li>Each connection corresponds to a <strong>dedicated DB session</strong></li><li>Short-lived requests still consume full sessions</li><li>Multiple instances/pods open simultaneous connections</li></ul><p>Increasing session limits is a temporary fix. The real solution is to <strong>share DB sessions efficiently</strong>, which is where DRCP comes in.</p><h3>2. What is DRCP?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*T1WyzVWAPWGGlyWX.gif" /></figure><p><strong>Database Resident Connection Pooling (DRCP)</strong> moves pooling <strong>inside the database</strong>:</p><ul><li>Application requests <strong>borrow a session</strong> from the DRCP pool</li><li>Sessions are <strong>reused across connections</strong>, reducing overhead</li><li>Prevents session storms under high concurrency</li></ul><p>Benefits of DRCP:</p><ul><li>Lower memory and process consumption</li><li>Increased stability under load</li><li>Works seamlessly with Spring applications</li></ul><h3>3. Enabling DRCP</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*9bZQ5uBn0OaRqbGW.gif" /></figure><p>Update Spring JDBC URL accordingly.</p><pre>jdbc:oracle:thin:@//localhost:5521/orcl:POOLED</pre><h3>4. Visual Concept</h3><p>Without DRCP:</p><pre>Application Connection → Dedicated DB Session<br>Multiple connections = multiple sessions = limit exceeded</pre><p>With DRCP:</p><pre>Application Connections<br>   \<br>    --&gt; Shared DB Session Pool (DRCP)</pre><p>Sessions are now <strong>reused efficiently</strong>, preventing connection limit errors.</p><h3>5. Results &amp; Takeaways</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/0*DcfEA1wIm28keZkH.gif" /></figure><p>After enabling DRCP:</p><ul><li>DB session usage dropped dramatically</li><li>“Maximum sessions exceeded” errors disappeared</li><li>Application scaled smoothly under load</li><li>Database resource usage became predictable</li></ul><p>Key Lessons:</p><ul><li>Application pools alone cannot solve DB-level session limits</li><li>DRCP is underutilized but highly effective for high-concurrency apps</li><li>Always consider <strong>both application and database pooling</strong> when scaling</li></ul><p>Reference: <a href="https://docs.oracle.com/en/database/oracle/oracle-database/18/jjdbc/database-resident-connection-pooling.html">https://docs.oracle.com/en/database/oracle/oracle-database/18/jjdbc/database-resident-connection-pooling.html</a></p><p>Happy coding!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2c6862aad5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Using Local Storage: 5 Reasons to Kick the Habit]]></title>
            <link>https://navoddilshan9.medium.com/stop-using-local-storage-5-reasons-to-kick-the-habit-360f274ce803?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/360f274ce803</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[indexdb]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[localstorage]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 19:32:18 GMT</pubDate>
            <atom:updated>2024-04-17T10:39:16.094Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avN8zJJKxMseUr9-LcsX6w.jpeg" /></figure><h3>What is Local Storage?</h3><p>Let’s start with the basics: local storage is a new feature of HTML5 that basically allows you (a web developer) to store any information you want in your user’s browser using JavaScript. Simple, right?</p><p>In practice, local storage is just one big old JavaScript object that you can attach data to (or remove data from). Here’s an example of some JavaScript code that stores some of my personal info in local storage, echoes it back to me, and then (optionally) removes it:</p><pre>// Storing personal info<br>localStorage.setItem(&#39;name&#39;, &#39;John&#39;);<br>localStorage.setItem(&#39;age&#39;, &#39;30&#39;);<br><br>// Retrieving and displaying stored info<br>const name = localStorage.getItem(&#39;name&#39;);<br>const age = localStorage.getItem(&#39;age&#39;);<br>alert(`${name} is ${age} years old.`);<br><br>// Optionally remove stored info<br>localStorage.removeItem(&#39;name&#39;);<br>localStorage.removeItem(&#39;age&#39;);</pre><p>If you run this code in your browser on a test HTML page, you’ll see an alert saying “John is 30 years old.” Neat, huh? Also, if you peek into your browser’s developer tools, you’ll find both ‘name’ and ‘age’ stored in local storage.</p><p>But wait, what if you don’t want to manually clean up stored data? Enter sessionStorage! It’s just like local storage, but data is automatically wiped when the user closes their browser tab. Huge shoutout to the HTML5 working group for this gem!</p><h3>What’s Cool About Local Storage?</h3><p>Now that we’ve got a handle on what local storage is, let’s delve into what makes it cool! Even though the main aim here is to steer you away from using local storage for session data, it still boasts some intriguing features.</p><p>First off, it’s all about JavaScript! Unlike cookies (the primary alternative), which require a web server for creation, local storage operates purely with JavaScript. No need to fuss with web servers — local storage lets your web pages function independently. If you’re crafting a static site like a single-page app, local storage empowers your pages to store data in the browser without relying on backend languages or server logic. That’s a game-changer and a big reason why developers love it.</p><p>Another perk? Local storage isn’t as cramped as cookies. It offers a minimum of 5MB data storage across all major browsers, a significant bump from the paltry 4KB limit imposed on cookies. This expanded capacity makes local storage ideal for caching application data in the browser for future use. With cookies maxing out at 4KB, local storage emerges as one of the few viable alternatives for handling larger datasets.</p><h3>What’s the Problem with Local Storage?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F24001727&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fso-which-part-is-the-problem-kanan-gill-so-whats-the-problem-tell-me-the-problem-what-part-of-it-is-the-problem-gif-24001727&amp;image=https%3A%2F%2Fmedia.tenor.com%2FhVXVq2i9-koAAAAF%2Fso-which-part-is-the-problem-kanan-gill.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/9454cfdf7c7d05b760d69aab24b19ce1/href">https://medium.com/media/9454cfdf7c7d05b760d69aab24b19ce1/href</a></iframe><p>Alright, time to address the downsides. Brace yourself for the bad news about local storage.</p><ol><li><strong>It’s Super Basic</strong>: Local storage is about as basic as it gets. It can only handle string data. Yup, you heard that right. So, anything even remotely complex? Forget about it. Serializing everything, including data types, just to fit it into local storage? Talk about an ugly workaround.</li><li><strong>Synchronous Operations</strong>: Local storage operates synchronously. That means each operation happens one at a time. For complex applications, this spells trouble, slowing down your app’s runtime significantly.</li><li><strong>No Love for Web Workers</strong>: Here’s a bummer — local storage can’t be accessed by web workers. So, if you’re eyeing background processing for performance boosts or fancy chrome extensions, tough luck. Local storage won’t play nice with those.</li><li><strong>Size Constraints</strong>: Sure, local storage gives you about 5MB of space across major browsers. But for data-intensive apps or those needing to function offline, that’s not much room to maneuver.</li><li><strong>Zero Data Protection</strong>: Buckle up for the security risk. Any JavaScript snippet on your page can tap into local storage without breaking a sweat. No data protection measures in sight. Security nightmare alert!</li></ol><p>To sum it up, only go for local storage if you’re storing public, non-sensitive info, not aiming for high-performance apps, staying under the 5MB limit, and dealing solely with string data.</p><p>If your app doesn’t fit the bill? Save yourself the headache and look elsewhere. We’ll dive into alternatives later.</p><h3>Why You Shouldn’t Trust Local Storage with Your Secrets</h3><p>Local storage may seem convenient, but when it comes to security, it’s like leaving your valuables in a cardboard box on the sidewalk. Here’s why you should never use local storage for sensitive data.</p><ol><li>Inherent Insecurity: Local storage wasn’t built with security in mind. It’s essentially an open book for any JavaScript code running on your website.</li><li>JavaScript, the Double-Edged Sword: JavaScript is incredibly powerful, but that also makes it dangerous. When you store sensitive info in local storage, you’re essentially trusting the most potent tool on the web to safeguard your secrets.</li><li>Cross-Site Scripting (XSS) Nightmare: XSS attacks are the stuff of web developers’ nightmares. If an attacker can execute JavaScript on your site (and trust me, they’ll find a way), they can easily access and steal all your local storage data, including sensitive stuff like user sessions or payment details.</li><li>Third-Party Risks: Even if your site itself is a fortress, third-party scripts are the chink in your armor. If any script from external sources (think ad networks, analytics tools, or even popular libraries like jQuery) gets compromised, your local storage becomes an open buffet for attackers.</li><li>Real-World Vulnerabilities: Let’s face it — in the real world, avoiding third-party scripts is easier said than done. Marketing teams often handle website content using various tools, opening the door to sneaky third-party JavaScript injections without your knowledge.</li></ol><p>To keep your users’ data safe and your sanity intact, steer clear of local storage for anything sensitive. It’s just not worth the risk.</p><h3>What is the Alternative?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F26220657&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fwhat-is-the-alternative-then-special-agent-in-charge-isobel-castille-fbi-whats-the-other-option-whats-next-gif-26220657&amp;image=https%3A%2F%2Fmedia.tenor.com%2FXY1d3fL68psAAAAF%2Fwhat-is-the-alternative-then-special-agent-in-charge-isobel-castille.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/7793766d079c554a8f1206c4c805e429/href">https://medium.com/media/7793766d079c554a8f1206c4c805e429/href</a></iframe><p>Given the vulnerabilities of local storage, it’s crucial to explore better alternatives. Let’s dive into what you should use instead.</p><h4>Sensitive Data</h4><p>For anything sensitive — like user IDs, session IDs, personal info, credit card details, API keys, or anything you wouldn’t want plastered on social media — always opt for a server-side session.</p><p>Here’s how:</p><ul><li>Upon user login, generate a session identifier and store it in a cryptographically signed cookie.</li><li>Ensure the cookie library sets the httpOnly flag (for secure server-side sessions), SameSite=strict flag (to thwart CSRF attacks), and secure=true flag (for encrypted connections).</li><li>Retrieve user account details using the session ID for every request, fetching data from a database or cache.</li><li>Keep it simple, secure, and scalable. Server-side sessions are the way to go, even for large websites.</li></ul><h4>Non-String Data</h4><p>If you need to store complex data in the browser — like integers, floats, etc. — look no further than IndexedDB. It provides a database-like object store, allowing you to define primary keys, handle indexing, and ensure data integrity.</p><h4>Offline Data</h4><p>When offline functionality is a must, combine IndexedDB with the Cache API, a part of Service Workers.</p><p>Here’s the breakdown:</p><ul><li>Use IndexedDB to store structured data.</li><li>Employ the Cache API to cache network resources your app needs to function offline.</li><li>Dive into Google’s tutorial on the Cache API for in-depth insights.</li></ul><p>By leveraging these alternatives, you can sidestep the pitfalls of local storage and ensure your data remains secure, structured, and accessible — without compromising on performance or user experience.</p><p>Remember, the security and performance of your application depend on making informed choices about data storage. So, steer clear of local storage when it’s not suitable, and opt for more secure and appropriate alternatives instead.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F25195359&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fgregzaj1-ln_strike-impressive-very-nice-add-lasers-impressive-very-nice-add-lasers-gif-25195359&amp;image=https%3A%2F%2Fmedia.tenor.com%2FiBe81vKzJpsAAAAF%2Fgregzaj1-ln_strike.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/b06d6059fdb1a8c4992412cc60496953/href">https://medium.com/media/b06d6059fdb1a8c4992412cc60496953/href</a></iframe><p>Happy coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=360f274ce803" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Virtual Threads in Springboot 3.2]]></title>
            <link>https://navoddilshan9.medium.com/virtual-threads-in-springboot-3-2-9a7250429809?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a7250429809</guid>
            <category><![CDATA[springboot-3]]></category>
            <category><![CDATA[virtual-threads]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java21]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Fri, 05 Jan 2024 21:58:11 GMT</pubDate>
            <atom:updated>2024-03-20T09:23:47.416Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*x7EF3mohhgJ0DXq0Jc-bMA.png" /></figure><p>With the recent launch of <a href="https://spring.io/blog/2023/11/23/spring-boot-3-2-0-available-now/">Spring Boot 3.2</a>, there’s a standout feature stealing the spotlight — virtual threads. The main focus is on boosting how the program runs, aligning with the broader goal of improving efficiency during runtime. This article dives into the significance of virtual threads, underlining their seamless integration with Java version 21 for a smoother development experience</p><h4>Spring MVC and Thread per Request Model</h4><p>Spring MVC applications traditionally operate on a thread per request model. When a client communicates with a Java application, a thread is spawned to handle the request. This thread, often referred to as a platform thread, represents a finite resource tied to the operating system thread. However, issues arise when blocking operations, such as database calls or HTTP service requests, tie up these threads, leading to decreased throughput and potential application slowdowns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gBwpdXUbtlh3o86l70cCig.png" /><figcaption>Thread per Request Model</figcaption></figure><h4>What is Virtual Threads?</h4><p>Virtual threads, introduced at the Java 21 JDK level, provide an innovative solution to the challenges posed by traditional threads. Unlike platform threads, virtual threads offer an illusion of infinite scalability. They are lightweight threads capable of performing tasks independently, eliminating the need to tie themselves to a platform thread. Virtual threads shine when handling blocking operations, such as HTTP service calls or database queries, as they don’t hang up the platform thread.</p><p>Here you can see how the JAVA thread and virtual threads connect with operating system threads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*Hsp56nXv6bUECo-bfvrePQ.png" /><figcaption>JAVA Threads</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*gzZ5CNk6uObgDU5g2QMt7Q.png" /><figcaption>Virtual Threads</figcaption></figure><h4><strong>Why we use Virtual Threads in Spring?</strong></h4><p>Virtual threads offer a scalable solution without the need for additional hardware. By decoupling from platform threads, applications can spawn thousands or even millions of virtual threads to perform tasks concurrently, significantly improving scalability.</p><p>Let’s create two Spring Boot applications together to explore how virtual threads work in practice.</p><p>01) The first application represents a blocking scenario, simulating HTTP communication with delays, highlighting the challenges of traditional threads in handling such operations.</p><p><strong>Spring Initializr</strong></p><p>Navigate to <a href="https://start.spring.io/">Spring Initializr</a> in your web browser.</p><p><strong>Project Configuration</strong></p><p>When initiating your Spring Boot project through Spring Initializr, opt for “<strong>Maven</strong>” as your project type. Choose Spring Boot version <strong>3.2</strong> to leverage the latest enhancements, and set the Java version to <strong>21 </strong>to ensure compatibility with contemporary Java features.After that add Spring Web dependency into your project.</p><p>Click on the “Generate” button to generate the project and open the project with your favorite code editor.</p><p><strong>Configuring Application Properties</strong></p><p>configure the server port as follows in “application.properties”</p><pre>server.port=8081</pre><p><strong>Creating a Controller</strong></p><p>Now, let’s create a new Java class named “BlockController” to set up blocking endpoints and run the program.</p><pre>package com.imnavod.virtual.thread;<br><br>import org.slf4j.Logger;<br>import org.slf4j.LoggerFactory;<br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.PathVariable;<br>import org.springframework.web.bind.annotation.RestController;<br><br>@RestController<br>public class BlockController {<br><br>    private static final Logger log = LoggerFactory.getLogger(BlockController.class);<br><br>    @GetMapping(&quot;/block/{seconds}&quot;)<br>    public void block(@PathVariable Integer seconds) throws InterruptedException{<br>        Thread.sleep(seconds*1000);<br>        log.info(&quot;Sleep for {} seconds &quot;,seconds);<br>    }<br>}</pre><p>Using <strong>Thread.sleep(seconds * 1000)</strong> adds a specified waiting time after calling the endpoint, where the desired duration is represented in seconds.<br>This application has just created an endpoint with a delay, simulating either network latency or processing delay. In real-world scenarios, when a client initiates an API request, the response is not instantaneous, and there is typically a delay before receiving the result.</p><p>02) In the second application, we’ll experience the enhanced capabilities of virtual threads by enabling them in Spring Boot 3.2.</p><p>Generate and open the project using the same approach as in the first application.</p><p><strong>Configuring Application Properties</strong></p><p>configure the server port as follows in “application.properties”</p><pre>server.port=8082</pre><p><strong>Creating a Controller</strong></p><p>Create a Java class named “HomeController” to define endpoints. Subsequently, implement a GET request to invoke another HTTP request from a separate service. This setup enables us to call our first application using this GET method.</p><p>Within this method, we utilize the <a href="https://www.baeldung.com/spring-boot-restclient">RestClient </a>in Spring Boot to make an HTTP call. This RestClient functions as a synchronous HTTP client, making it suitable for a multi-threaded program.</p><pre>package com.imnavod.virtual.thread;<br><br>import org.slf4j.Logger;<br>import org.slf4j.LoggerFactory;<br>import org.springframework.http.ResponseEntity;<br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.PathVariable;<br>import org.springframework.web.bind.annotation.RestController;<br>import org.springframework.web.client.RestClient;<br><br>@RestController<br>public class HomeController {<br><br>    private final static Logger logger = LoggerFactory.getLogger(HomeController.class);<br><br>    private final RestClient  restClient;<br>    public HomeController(RestClient.Builder builder){<br>        this.restClient=builder.baseUrl(&quot;http://localhost:8081&quot;).build();<br><br>    }<br>    @GetMapping(&quot;/block/{seconds}&quot;)<br>    public String home(@PathVariable Integer seconds){<br>        ResponseEntity&lt;Void&gt; result = restClient.get()<br>                .uri(&quot;/block/&quot;+seconds)<br>                .retrieve()<br>                .toBodilessEntity();<br><br>        logger.info(&quot;{} on {}&quot;,result.getStatusCode(),Thread.currentThread());<br>        return Thread.currentThread().toString();<br><br>    }<br><br><br>}</pre><p>In our machines, resources are limited, and we cannot allocate an unlimited amount to any application. Therefore, it is essential to impose restrictions on the resources accessible to the application. As a measure, we set a maximum limit of 10 threads for the server to utilize.</p><p>We are adding another configuration to the “application.properties”.</p><pre>server.port=8082<br>server.tomcat.threads.max=10</pre><p>I‘m using <a href="https://httpd.apache.org/docs/2.4/programs/ab.html">Apache Benchmark</a> to concurrently send requests to the server and obtain a performance benchmark. This is how we send 60 requests, 20 concurrently, with a 2-second delay for each request. We expect the execution of all 60 requests to take 12 seconds. This is because if we send 20 requests concurrently, the server can’t process all 20 requests at once. This limitation is due to restricting it to 10 threads.</p><pre>ab -n 60 -c 20 http://localhost:8082/httpbin/block/2</pre><p>You can see the following result in the IDE console for each reqeust.</p><pre>2024-01-06T02:34:49.410+05:30  INFO 8888 --- [nio-8082-exec-2] c.imnavod.virtual.thread.HomeController  : 200 OK on Thread[#38,http-nio-8082-exec-2,5,main]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*TJBSaxeFAxFVKTR1AgmqKw.png" /><figcaption>Benchmark test without enable virtual threads</figcaption></figure><p>Let’s enable virtual threads and observe the performance gain from this existing feature in Spring Boot 3.2. To do that, go to the “application.properties ” file and make the following changes.</p><pre>server.port=8082<br>spring.threads.virtual.enabled=true</pre><p>Run the same benchmark test as earlier. If your virtual threads are enabled successfully, you can see the log for each request in the IDE console as follows.</p><pre>2024-01-06T02:39:34.204+05:30  INFO 22348 --- [omcat-handler-0] c.imnavod.virtual.thread.HomeController  : 200 OK on VirtualThread[#40,tomcat-handler-0]/runnable@ForkJoinPool-1-worker-1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*50uXSfyWKjZThzhDG3Z5cg.png" /><figcaption>Benchmark test after enable virtual threads</figcaption></figure><p>You can clearly see the difference in how virtual threads enhance performance.</p><p><strong>Before enable virual threads — 14.286 seconds<br>After enable virual threads — 8.340 seconds</strong></p><h4>Conclusion</h4><p>Summing up, this artcel looks at how Virtual Threads in Java can boost Spring Boot application performance. However, they may not be the best choice for tasks that need a lot of processing power or if you’re already using asynchronous programming. The key takeaway is to know when to use Virtual Threads for the best results. By discussing challenges with asynchronous programming and showing real-world examples, the article aims to help you understand how to make the most of Virtual Threads and improve your Spring Boot applications.</p><p>code- <a href="https://github.com/navoddilshan9/spring-boot-virtual-threads.git">https://github.com/navoddilshan9/spring-boot-virtual-threads.git</a></p><p>Happy coding!!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a7250429809" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[All About Singleton Design Pattern]]></title>
            <link>https://navoddilshan9.medium.com/all-about-singleton-design-pattern-d14c350f4f37?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d14c350f4f37</guid>
            <category><![CDATA[singleton-design-pattern]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[good-practices]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Tue, 03 Jan 2023 15:18:21 GMT</pubDate>
            <atom:updated>2023-01-17T03:00:20.591Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*EiBcOCxPN721P90EF9-OqQ.jpeg" /></figure><h3><strong>What is a design pattern?</strong></h3><p>Design patterns are the pre-defined solution to commonly occurring problems in software designs. Design patterns are not the only solutions to problems. It’s a generalized description or template for how to address a problem.</p><h3>What is Singleton design pattern?</h3><p>As usual, the singleton design pattern is a type of creational design pattern. It lets you create only a single instance and gives you a single point of access to this instance from anywhere in the world.</p><h3>Why Singleton design pattern?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*pSPiekBRUw2nBrmOCP9gFA.gif" /></figure><p>It allows only one instance of a class to be created. But <strong>why do we need to allow creating a single instance from a class?</strong></p><p>Usually, the singleton design pattern controls access to shared resources. The most common example is controlling access to the database. If the object is created from the database, and after that, the user tries to create another object from the same database, instead of creating a new object, the program returns the object already created.</p><p>This is what happens in the singleton design pattern.</p><h3>Implementaion of Singleton design pattern?</h3><p>Singleton design pattern has two major steps to follow.</p><p>01) Multiple objects are avoided through private static object creation in the class.</p><p>02) Give the public a method for creating an object.</p><p>These are the two steps to putting the singleton design pattern into action. So you can&#39;t understand what they really mean. So I will go through Java code snippets.</p><p><strong>Database.java</strong></p><pre>public class Database {<br>    private static Database connection;<br>    private Database(){}<br>    public static Database createConnection(){<br>        if (connection==null){<br>            connection= new Database();<br>            System.out.println(&quot;New database connection created.&quot;);<br>        }else {<br>            System.out.println(&quot;Database connection is already created.&quot;);<br>        }<br>        return connection;<br>    }<br>}</pre><p>Client.java</p><pre>public class Client {<br>    public static void main(String[] args) {<br>        Database.createConnection();<br>    }<br>}</pre><blockquote><strong><em>Important !</em></strong></blockquote><p>In this code, we convert the constructor to a private constructor. Have you ever wondered why we used it? Because private constructors are avoiding the creation of multiple objects using <strong><em>new </em></strong>keyword .</p><h3>Is this code multithreaded?</h3><p>No. This code is not valid for the multi-thread program. This code is not appropriate when the two programs run concurrently with two threads. So what is this solution for that? This is the Java code snippet for the solution.</p><p>Using the synchronized keyword, we can implement the singleton design pattern in multiple threads in this version(<strong>Thread-Safe version</strong>)</p><p>Databse.java</p><pre>public class Database {<br>    private static Database connection;<br><br>    private Database() {<br><br>    }<br><br>    public static Database createConnection() {<br>        synchronized (Database.class) {<br>            if (connection == null) {<br>                connection = new Database();<br>                System.out.println(&quot;New database connection created!&quot;);<br>            } else {<br>                System.out.println(&quot;Database connection is already created&quot;);<br>            }<br>        }<br>        return connection;<br>    }<br>}</pre><p>Client.java</p><pre>public class Client implements Runnable {<br>    public static void main(String[] args) {<br>        Thread t1 = new Thread(new Client());<br>        t1.start();<br>        Thread t2 = new Thread(new Client());<br>        t2.start();<br>        Thread t3 = new Thread(new Client());<br>        t3.start();<br>    }<br><br>    @Override<br>    public void run() {<br>        Database connection01 = Database.createConnection();<br>    }<br>}</pre><h3><strong>Is this the best practice for singleton design pattern ?</strong></h3><p>Absoultly not. Because the synchronized method is computationally very expensive, that blocks many executes pararlly and decrease the performance.So this version is not the better way to implement for thread safe singleton design pattern.</p><h3>So, What is the better way?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*wSpBQoS9L9UJebEZpeHg0w.gif" /></figure><p>Finally, you can get a better and optimized version to implement the singleton design pattern. That version is named as <strong>Doubly checked Locking method</strong>. The only difference between the previous and this version is that in this version, before executing the synchronized method, we check to see if an instance has been created. So the program will not execute that method every time.</p><p>Database.java</p><pre>public class Database {<br>    private static Database connection;<br><br>    private Database() {<br><br>    }<br><br>    public static Database createConnection() {<br>        if (connection == null) { // check before synchronized method<br>            synchronized (Database.class) {<br>                if (connection == null) {<br>                    connection = new Database();<br>                    System.out.println(&quot;New database connection created!&quot;);<br>                } else {<br>                    System.out.println(&quot;Database connection is already created&quot;);<br>                }<br>            }<br>        } else {<br>            System.out.println(&quot;Database connection is already created&quot;);<br>        }<br><br>        return connection;<br>    }<br>}</pre><p>This is all about Singleton design pattern, and I really hope you learned anything new here. I’ll see you soon in the next blog. Happy coding!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d14c350f4f37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best 5 VsCode Extensions For a Full-Stack Developer]]></title>
            <link>https://navoddilshan9.medium.com/best-5-vscode-extensions-for-a-full-stack-developer-c4c88f39dff0?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4c88f39dff0</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[vscode-extension]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Wed, 07 Dec 2022 12:43:31 GMT</pubDate>
            <atom:updated>2022-12-16T06:31:30.686Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rZ8HiQcX1L1wte_txt9SqA.jpeg" /></figure><p><strong>Why should you use extensions?</strong></p><p>The main feature of the visual code is the benefits of extensions. That&#39;s why the VS code is widely used by developers. Extensions make the work super easy for any kind of developer. In this article, I recommend my top 5 extensions for VS Code.</p><p><a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode">05. Pretier</a></p><p>Don’t waste your time even formatting the code. Clearly, the formatted output is the result of using this extension. What’s crucial is that, when I save the code, it automatically formats itself. It was a time-saver, and it kept me from having to rewrite any faulty code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*N8uPPGwqGkziOrmB97moqw.gif" /></figure><p><a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer"><strong>04. Live server</strong></a></p><p>This extension is a super easy way to run a web application and get a live preview of the existing code. The running file should have been renamed as index.html and it’s necessary for this extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zbah9nplF4xzwCjZAmeWtg.gif" /></figure><p><a href="https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare"><strong>03. Live share</strong></a></p><p>Collaborative work is a very common and important thing these days for every programmer. So through this extension, we can share and edit the code at once from a different location. Trust me, use this extension and get enjoyment from this extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*65bEgL2VxssXULxfmT0hZg.gif" /></figure><p><a href="https://marketplace.visualstudio.com/items?itemName=GoBystrokReactJS.gobystrok"><strong>02. Snippets</strong></a></p><p>I believe this will make you super fast. It makes me 5 times faster than my previous coding speed. If you are a react developer, you know about the pain of typing the same thing over again like function or class components replica. So the solution is here. If you need a class component. simply type <strong><em>rse</em> </strong>and press enter. I know you will blow up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ujV4Ck4ZKR2yRB72SJ4SvQ.gif" /></figure><p><a href="https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.vscodeintellicode"><strong>01. IntelliCode</strong></a></p><p>My experience with IntelliCode has been nothing short of excellent. This is because, as a full-stack developer, we need to be conversant in a wide variety of syntaxes. However, this extension predicts what we’re going to type and provides completion suggestions as we type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bTcmJxOLDWm1gVGRKEqbgw.gif" /></figure><p>Those are the top 5 extensions that I use for my web development. I really hope you learned anything new here, and I&#39;ll see you soon in the next blog. Happy coding!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4c88f39dff0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s useState hook in React]]></title>
            <link>https://navoddilshan9.medium.com/whats-usestate-hook-in-react-ba8cca15ce64?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba8cca15ce64</guid>
            <category><![CDATA[jsx]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Tue, 23 Feb 2021 13:57:07 GMT</pubDate>
            <atom:updated>2022-12-25T16:17:57.074Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pCUJ13ODqLcx3na_" /></figure><p>Hello coders, In this article I’m going to explain the new technology which is using in web designing. As a web developer, this is a must for you if you are using react. Let’s start from the beginning……</p><blockquote>Do you ever use the state feature in react?</blockquote><p>Don’t worry. Let me show a simple example without using anything special. Sometimes you are familiar with this code. This is for application to increment and decrement the value of a variable called count when clicking the relevant button.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7f37bdddac68b65d3b09e5513fd9378/href">https://medium.com/media/e7f37bdddac68b65d3b09e5513fd9378/href</a></iframe><p>In this example, I use class base use state to change the value of the count. In this method, we use class base components. Normally we have to use jsx code segments into the render and return.</p><blockquote><strong><em>What’s hook ?</em></strong></blockquote><p>Hooks are the new feature introduced in the React 16.8 version. In react, It allows to use state, effects and other react features without using classes.</p><p>Hooks are not the class base component. It is a function base component. When we are using hooks, There are some rules to follow.</p><blockquote><em>Want to read this story later? </em><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text"><em>Save it in Journal.</em></a></blockquote><p>01)<strong><em>Only call Hooks at the top-level</em></strong> -Do not call Hooks inside loops, conditions, or nested functions.</p><p>02)<strong><em>Only call Hooks from React functions</em></strong> -You cannot call Hooks from regular JavaScript functions. Instead, you can call Hooks from React function components.</p><p>When we learning the react hooks, We can learn about useState, useEffect, UseRef, or we can build custom hooks in react components. In this article, I discuss only the useState react hook.</p><blockquote><strong><em>What’s the useState hook?</em></strong></blockquote><p>A Hook is a special function that lets you “hook into” React features. For example, useState is a Hook that lets you add React state to function components.</p><p>For your clarification, I get the above example and coded using react useState react hook.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2f7a9dd6868aae1ef4c425d9892cae3/href">https://medium.com/media/e2f7a9dd6868aae1ef4c425d9892cae3/href</a></iframe><p>Let’s compare those couple of code segments one by one. Then you can get more clarification about that to react hook.</p><h3><strong>Class </strong>VS Function</h3><p>This is an example of, class-based react component which I used in the first code segment(figure I).</p><pre>class App extends React.Component {</pre><pre>render() {<br>      return (<br>         //you can code what would you return<br>)<br>}<br>}</pre><p>As I say earlier, We use function base components in react hooks. Function base components like this.</p><pre>function App() {</pre><pre>     return (<br>           //you can code what would you return<br>     )<br>}</pre><h3>Declaring state variable</h3><p>When we using the state feature in react we have to declare variables to store the state.</p><p>In class components, we have to declare the count variable and store 0 by setting <strong>this.state</strong> to <strong>{count:0}</strong> in the constructer.</p><pre>class Example extends React.Component {<br>  constructor(props) {<br>    super(props);<br>    this.state = {     <br>     count: 0    <br>};  <br>}</pre><p>Then we can compare the difference between the function base react hook component and the class base react component. Before we use the <strong>useState </strong>hook, we should import useState dependency like this.</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function Example() {<br>       [count, setCount] = useState(0);<br>}</pre><h3>Why we pass an argument in the useState function</h3><p>It’s the initial value of the current value of the variable. If we code like this,</p><pre>[count, setCount] = useState(0);</pre><p>the initial value is 0,(count=0).</p><p>Another example,</p><pre>[name, setName] = useState(&quot;vickey&quot;);</pre><p>it is also the initial value of the name variable.</p><p>“vickey” is the initial value of the variable called name.</p><h3><strong>Why there are two variables as count &amp; setCount</strong></h3><p>Normally when we call useState function ,it returns <em>pair of values. </em>Therefore we declare 2 variables for store current value(count) and updated value(setCount).</p><h3>Updating State</h3><p>In the class-based component, this is the way, how to update the value of the variable(figure I).</p><pre>count: this.state.count + 1,//it&#39;s like count=count + 1</pre><p>Next there the way, how to update the value in a function-based component using react hook.</p><p>As an example,If we want to add 1 to the count. Then the code should be like this(figure II).</p><pre>setCount(count + 1)</pre><p>If the initial value of the count is 0, then after that code segment, the value of the count is 1.</p><p>Another example,</p><pre>setName(&quot;john&quot;)</pre><p>if the initial value of the name is “vickey”, then after the code segment,the value of the name is “john”.</p><p>For perfect and readable purpose coding,I did this updating process through the separate function as <strong>increamentHandler </strong>and <strong>increamentHandler </strong>for decrement and increment the value of count variable in my examples.</p><p>I think you have a better understanding about what is discussed.</p><blockquote><strong><em>What we discussed.</em></strong></blockquote><p>→ Coded the simple familer example without using any special technologies.</p><p>→develop that same code using react useState hook</p><p>→Comparism</p><p>1)Class vs Function in React</p><p>2)Declare the state variable for the both figures</p><p>3)Initalizing variables using useState</p><p>4)Update variables in react using hooks</p><p>In my next blog,I will teach about another react hook called “useEffect”.Keep in touch with my blogs.Happy cording……!!!!!</p><p>📝 Save this story in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text">Journal</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba8cca15ce64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Buildup circuit quickly with ATmega32]]></title>
            <link>https://navoddilshan9.medium.com/buildup-circuit-quickly-with-atmega32-babd0ad813ae?source=rss-e8ce58d5f6d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/babd0ad813ae</guid>
            <category><![CDATA[usbasp-programmer]]></category>
            <category><![CDATA[atmega32]]></category>
            <dc:creator><![CDATA[Navod Dilshan]]></dc:creator>
            <pubDate>Sun, 08 Nov 2020 01:58:20 GMT</pubDate>
            <atom:updated>2020-11-08T01:58:20.794Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fb_kzx3gjKBmsIwavOVCvQ.jpeg" /></figure><p>In this article, I’m going to tell you about how to buildup a demonstration module prior to our final project module, with some special components. Although demonstration module provide ease and flexibility for our final module, we can’t use all the special components in our demonstration module,for the final module.</p><p>I hope to discuss details under below -mentioned points here onwards.</p><p>01) what are the special component we need?</p><p>02)How to upload code into the microcontroller through the USBASP?</p><h3><strong>what are the special components we need?</strong></h3><p><em>→A development board that can connect to the ATmega32 chip</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*ZYnXrng6GSfDkU5RaHtgfg.png" /><figcaption>Development board</figcaption></figure><p>we use this only for our development board and for our final project we have to design a PCB(Printed Circuit Board).Therefore it is important for you to have the knowledge about the internal mechanism of this component. Using this board is not mandatory Although this gives you some facilities which are easy to use,it is not mandatory to use this. If you are not going to use this board you will have to assemble some components separately.</p><p>Refer to this link and add this module to your cart. &lt;<a href="https://scionelectronics.com/product/programmer-avr-minimum-system-board-atmega16-atmega32/"> <strong><em>LINK</em></strong></a> &gt;</p><p>→USB ASP cable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*wq0Wfo6TAuDG-EetywHj2A.png" /><figcaption>USB ASP Cable</figcaption></figure><p>When microcontroller and pc dealing with together, this module handy for us. If you use a development board, this module is very useful and makes perfect.</p><p>Refer to this link and add this module to your cart.&lt;<a href="https://www.microchip.lk/product/avr-programmer/">LINK</a>&gt;</p><h3><strong>How to upload code properly into the microcontroller through the USBASP?</strong></h3><p>I discuss this topic in 2 steps.</p><blockquote>01-How to install drivers</blockquote><p>First, you have to install drivers properly. Then you can install the uploader software and upload the code into your microcontroller.</p><p>First I discuss how to install drivers into your windows. I got two methods to install drivers.</p><p><strong>First method</strong></p><p>Here the link to download to drivers and special uploader software very easily.&lt;<a href="https://github.com/navoddilshan9/zadig-2.4.git">LINK</a>&gt;</p><p>step 01-</p><p>Extract the file downloaded file.</p><p>step 02 -</p><p>Plug the USBAsp cable into your machine.</p><p>step 03-</p><p>Open the downloaded software.</p><p>step 04-</p><p>Go to the <strong>options</strong> tab and <strong>select List All Devices</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*ejDxTOuT_Mt3f5Yk2tQQ2Q.png" /></figure><p>step 05 -</p><p>Drop down the list and select <strong>usbasp.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*8OX1vM0Fdbju4HAmmwM9_A.png" /></figure><p>step 06-</p><p>Select libusb-win(v1.2.6.0) and make sure these changes correctly. Click the <strong>Replace Driver</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*53IOs7kDGVJP1YiSaGLv8A.png" /></figure><p>After you can these steps. You can move to the uploading step.</p><p><strong>Second method.</strong></p><p>If you are unable to install drivers&#39; first method you can try out this method also.</p><p>Here the link to download the drivers.&lt;<a href="https://github.com/navoddilshan9/win-driver.git">LINK</a>&gt;</p><p>step 01- Open the Device Manager on your computer.</p><p>step 02 -Find the icon of <strong>USBasp</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*Ltt2mQqgM3cnPOmzf2idvA.png" /></figure><p>step 03- Right-click on that icon and then click on the <strong>update driver.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*vpqtXGsYVtfiY2gTv9ZIMA.png" /></figure><p>step 04- Click on the <strong>Browse my computer for drivers</strong> then browse the file which you downloaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*_wEI5rMA1eRDWH1mU1hUGw.png" /></figure><p>step 03- Then select the <strong>libusb_0.1.12.1</strong> file and click ok. Then click next to install that driver into your windows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*sq4tisHbnO-HNC0d1AXtng.png" /></figure><blockquote>02- How to upload the hex file</blockquote><p>After installing the drivers properly you can download and open the uploader software. This software named Progisp.After open that software you can see the interface window like this.</p><p>Here the link to download the software.&lt;<a href="https://github.com/navoddilshan9/progisp.git">LINK</a>&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*BmmVM0VYHgqApl3a1fFo9w.png" /></figure><p>The next step is to upload the code to our microcontroller. Actually, we don&#39;t upload the code in the chip. we upload the hex file which generates after the compile the code in Atmel studio. To upload that hex file, there are several steps to follow in the software.</p><p>step 01-</p><p>Click <strong>load flash </strong>button and browse the hex file.(This hex file is in your Atmel project file&gt;debug)</p><p>step 02- Click <strong>Auto</strong> button to upload the code into the chip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*bZcLFBR8PyUzyHBO2m5M9A.png" /></figure><p>This is the procedure of how to install drivers and upload the hex file through progisp software. I think you get a proper understanding of these points.</p><p>Happy learning and be safe. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=babd0ad813ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>