<?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 Heshan Umayanga on Medium]]></title>
        <description><![CDATA[Stories by Heshan Umayanga on Medium]]></description>
        <link>https://medium.com/@heshanu97?source=rss-dce3d674c0d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JTF8Y1XPTz5cFT6LC6R8ZA.png</url>
            <title>Stories by Heshan Umayanga on Medium</title>
            <link>https://medium.com/@heshanu97?source=rss-dce3d674c0d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 10:35:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@heshanu97/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[Handling Database Errors in RPG IV Logic on IBM i.]]></title>
            <link>https://heshanu97.medium.com/handling-database-errors-in-rpg-iv-logic-on-ibm-i-2e482be7a991?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e482be7a991</guid>
            <category><![CDATA[rpg]]></category>
            <category><![CDATA[sqlcode]]></category>
            <category><![CDATA[cobol-programming]]></category>
            <category><![CDATA[ibm-db2]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 06:06:14 GMT</pubDate>
            <atom:updated>2026-11-17T06:06:14.374Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi All.</p><p>I’m learning COBOL, DB2, and the RPG programming language these days out of passion; in other words, you already consider them legacy systems. But they still matter and handle and solve business problems, and their downtime is roughly 99.9999999%<strong>~3 milliseconds to 30 seconds </strong>per year.</p><p>In Free-Format RPG, **Free Db2 is a lot more chill—almost <em>too</em> chill. It doesn’t throw exceptions that blow up your call stack. Instead, it quietly hands you a 4-byte integer called SQLCode and expects you to check it.</p><p>At first, it feels a bit old-school. But once you get used to it, SQLCode becomes your most reliable radar for knowing exactly what your database query just did. Let’s break down how to live with it without losing your mind.</p><p>So I wish to share my findings with you for your knowledge. I think this technology is on a different level. Those stack is old and they are robust and battleproof and handle many conflicts and provide solutions still existing and still handle most of backbones in enterprise systems. So I dig into their environments and ecosystems out of my passion to learn how large enterprises handle and manage business problems and provide solutions through them. I’m not against vibe coding and other modern stacks; they are tools, and we must find ways to increase our productivity while using them and improve together. Strong backend and its infrastructure, combined with modern technolgies makes softwares more robust and more reliable.</p><p>So let’s begin. In Free-Format RPG, **Free Db2 is a lot more chill — almost <em>too</em> chill. It doesn’t throw exceptions that blow up your call stack. Instead, it quietly hands you a 4-byte integer called SQLCODE and expects you to check it.</p><p>Frequent SQL codes you can find while you are getting your hands dirty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*XVQQKeCaokrdbTw9kbevhA.png" /></figure><p>We can divide them into a few sets for understanding: SQLCODEs like</p><ul><li>0</li><li>100</li><li>and negative numbers.</li></ul><h4><strong>0 stands for smooth sailing, successful, and all went according to plan.</strong></h4><h4><strong>100 stands for not found; in other words, the record doesn’t exist.</strong></h4><h4><strong>Negative numbers indicate some problems.</strong></h4><p>I think this content is enough for an article. I think you get the idea. Using them with proper understanding will make your system more maintainable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e482be7a991" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Always Cap Your Retries.]]></title>
            <link>https://heshanu97.medium.com/always-cap-your-retries-88e5fbe07f5c?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/88e5fbe07f5c</guid>
            <category><![CDATA[jitter]]></category>
            <category><![CDATA[exponential-backoff]]></category>
            <category><![CDATA[retry-mechanism]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Sun, 08 Nov 2026 17:22:05 GMT</pubDate>
            <atom:updated>2026-11-09T18:27:36.941Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Teb6WspYJWdDZDDcoYuLNw.png" /><figcaption>from systemic stack</figcaption></figure><p>This article is all about sharing my findings and how I clarified my understanding of retries with resiliency in distributed System architecture. I recently came to know retry strategies for every scenario. But this is a totally wrong understanding, and it causes decreased productivity in the system and its business logic.</p><p>I found a video by <a href="https://medium.com/u/5fd249e0a326">Manoj Fernando</a> on YouTube that describes these concepts in a very interesting way, so I referred to it, and the time was really worth it for such a system design video. He was describing concepts focusing on AWS technologies. But these system designs don&#39;t depend on market vendors; they use computer science concepts to develop their services. So I got a basic idea from his video, and I referred to another video from a YouTube channel. I will mention all resources at the end of my articles; you should refer to those items and get an idea of the concepts.</p><p>Apps configured to retry immediately send the same failed requests back to the database instantly. Because the database is already struggling, receiving the original traffic plus a flood of immediate retries causes it to fall further behind, leading to more timeouts and more retries.</p><p>This situation is amplified by multi-layer architecture. If an app, its API, and a downstream service like Lambda all have their own independent retry logic, a single user request can multiply exponentially (for example, 3 layers each with 3 attempts can result in 27 total calls). At scale, this creates a ‘retry storm’ where the system is overwhelmed by redundant requests exactly when it needs relief the most.</p><p><strong>For this issue, we can overcome it in the following ways,<br>Retry Strategies: Backoff, Jitter and Safe Retries.</strong></p><p><strong>Exponential Backoff simply means that, instead of retrying instantly, the application waits, and the wait time increases with each failure (e.g., waiting 100ms, then 200ms, then 400ms). This technique gives the struggling service or database necessary “breathing room” to recover.</strong></p><p><strong>And jitter means that, instead of retrying instantly, the application waits, and the wait time increases with each failure (e.g., waiting 100ms, then 200ms, then 400ms). This technique gives the struggling service or database necessary “breathing room” to recover.</strong></p><p>I usually know you use a retry request when the request is not successful. I know it is the only way, but we cannot use the retry mechanism every time. We must check logs, understand the scenario and take action according to it without using the same retry for every unsuccessful attempt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Teb6WspYJWdDZDDcoYuLNw.png" /><figcaption>from systemic stack</figcaption></figure><p>So, to prevent these kinds of scenarios, we can classify received errors by 2 parts. Transient (retryable) and permanent (fail fast). I will give a video overview of the contents because images make me more comfortable than paragraphs.</p><p>So, in REST architecture, we use status codes to understand client-server details like 200,201,500,400 etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*mp7Vq3waA4nScUAwXFzEIQ.png" /><figcaption>from systemic stack</figcaption></figure><p>For temporary issues, we can try the backoff and jitter mechanism. But we use backoff and jitter for permanent errors. Because it&#39;s an error on the user side or auth, if we retry again and again, we cannot change its behaviour. So be careful to use jitter and backoff for transient or retryable error requests.</p><p>It is useless to solve issues related to 400,401,403 using the above strategies. For these, we need to change their request bodies and their contents.</p><p>Let&#39;s see some scenarios for retryable scenarios,</p><ul><li>Network congestion</li><li>Connection resets</li><li>Service unavailability</li><li>throttling etc..</li></ul><p>So we must be aware of the thundering herd problem in jitter; for this, we can use full jitter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*CuR3zReIBirNjrXtlhB7EA.png" /><figcaption>from systemic stack</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*xKmujkzl1XA7bdqji-TgCQ.png" /><figcaption>from systemic stack</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*a5c7fo_h_ojDByc1V-IcZg.png" /><figcaption>from systemic stack</figcaption></figure><p>And Guardrails,Implementing retry limits and time budgets to ensure retries respect the overall operation’s deadline, and using idempotency keys to safely handle state-changing operations (like payments) without the risk of duplicate actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*y0Jvq3jWfMTyp4YF-cA_Yg.png" /><figcaption>from systemic stack</figcaption></figure><p>Architectural Integration: Connecting retries with circuit breakers, concurrency limits, and proper placement within the stack to prevent cascading failure.</p><p>We can use both synchronous and asynchronous ways.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*XPvF3QV1tuCkmrNT-46vMQ.png" /><figcaption>from systemic stack</figcaption></figure><p>The next article is about the dead letter queue or dead l queue.</p><p>I think this content is enough for an article. I think you get some idea about Retry methods and scenarios and how to use them. Using them with proper understanding will make your system more maintainable.</p><p>Happy learning…!</p><p>References-</p><ul><li><a href="https://youtu.be/igUE4q93DtY?si=Z_Wz4C8tONP_DVOf">https://youtu.be/igUE4q93DtY?si=Z_Wz4C8tONP_DVOf</a></li><li><a href="https://youtu.be/4lIlickO_0c?si=ZtCC0cMhX4_qFkUE">https://youtu.be/4lIlickO_0c?si=ZtCC0cMhX4_qFkUE</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88e5fbe07f5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Green Screens: Why Enterprise Engineers Still Demand…]]></title>
            <link>https://heshanu97.medium.com/green-screens-why-enterprise-engineers-still-demand-3e0b60ad61ac?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e0b60ad61ac</guid>
            <category><![CDATA[ibm-db2]]></category>
            <category><![CDATA[as400]]></category>
            <category><![CDATA[ibm-i]]></category>
            <category><![CDATA[enterprise-technology]]></category>
            <category><![CDATA[rpg]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 05:59:18 GMT</pubDate>
            <atom:updated>2026-10-23T05:59:18.511Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5uTQXEYtpKJSmticSa2WKw.jpeg" /><figcaption>pic from Reddit</figcaption></figure><p>Hi all,</p><p>This article is all about AS400 systems, which I saw in a job description at an enterprise company. They required both legacy and modern tech stacks, like AS400, RPG, DB2, and modern software stacks.</p><p>So I did R&amp;D stuff for this fintech company’s job descriptions. I also knew about these legacy systems, but these old systems are not legacy systems according to a book called “Working Effectively with Legacy Code” by Michael C Feathers.<strong> A legacy system is a system without proper tests.</strong></p><p>I’m not against agentic AI or vibe coding developments. But I’m also interested in maintaining legacy systems. I crawled YouTube and LLMs to find those systems; they are old-fashioned but have complete documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMWdYVgJ06ZyiJBA7RObEg.png" /></figure><p>There are so many documents online with huge user manuals. I use an LLM to summarise them and configure the AS400 system using a simulator software called MochaSoftTN5250.Those technologies are still used worldwide in enterprises domains like Fintech, insurance,foods and supply chains even governments arround world,even SriLanka and USA. They are still being managed and are struggling with maintenance. It is highly secure and has high uptime according to data, and it is also not vulnerable to cybersecurity attacks.</p><ul><li><strong>Everything is an Object (OBJ):</strong> In IBM i, files, compiled programs, user profiles, and queues are all treated as structured objects. Every object has a type—such as PGM(Program), FILE(File), or LIB(Library).</li><li><strong>Libraries (LIB):</strong> Instead of nested directories (e.g., /user/bin/heshan), IBM i uses flat containers called <strong>Libraries</strong>. A library cannot contain another library; it holds objects directly.</li><li><strong>Source Physical Files (FILE):</strong> Unlike standard OS files, source code on IBM i is stored inside special tables called Source Physical Files (e.g., QCBLSRC for COBOL).</li><li><strong>Source Members (MBR):</strong> Inside a Source Physical File, individual programs exist as <strong>Members</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*yM38jpo3gA82WZAs1fuekw.jpeg" /></figure><p>IBM has its own environments like,</p><ul><li>IFS,</li><li>Data Queues,</li><li>Object-Level Security &amp; Authorisation Lists,</li><li>Built-In Backup &amp; Recovery,</li><li>DB2 databases.</li></ul><p>Of the above points, I know only DB2; it is an SQL database for these systems so far, and all are included with this system.</p><p>I’m a noob in this stack, and enterprises need experienced developers/maintainers for maintaining critical systems. But in the world, previous maintainer leads or seniors are retiring, but there is no next batch of people who can maintain systems; that is the bottleneck, and it is a huge problem for company owners. Some are integrated coding agents like IBM BOB to mitigate this issue.</p><p>There are so many other challenges related to IBM I systems, such as,</p><ul><li>IBM i is deeply tied to proprietary hardware (IBM POWER systems) and closed-source operating microcode (SLIC/TIMI).</li><li>Traditional IBM i development relied heavily on direct green-screen editing (SEU/PDM) and library-based object locking, rather than modern distributed source control.</li><li>To developers trained purely in modern web stacks (Node.js, React, Python), the classic 5250 green screen looks ancient and intimidating.</li><li>The operating model of IBM i — featuring Single-Level Storage, object-based security, libraries instead of directories, and library lists *LIBS—is completely different from Linux or Windows.</li></ul><p>I tried to log in to an AS400 system; you don&#39;t need to have physical access to learn it. You can easily create an account in IBM Cloud, and they give a default username and password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMWdYVgJ06ZyiJBA7RObEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vamySHtNVOXhaFe6YZzLgw.png" /></figure><p>And modern IDEs like VS Code have an extension called IBM I and you can easily login by username and password you created at IBM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*4lUycv06gmBNnTjoem8n7A.png" /></figure><p>I think this content is enough for this article, and I’m still curious and learning how this system works and its abilities for enterprises worldwide. Companies need seasoned developers who have deep knowledge of concepts with practicals. This is just the beginning of it.</p><p>Thanks for reading!. Stay curious, stay learning!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e0b60ad61ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Health Level 7(HL7) Part One.]]></title>
            <link>https://heshanu97.medium.com/health-level-7-hl7-part-one-eb1623cac034?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb1623cac034</guid>
            <category><![CDATA[data-interoperability]]></category>
            <category><![CDATA[hl7-standards]]></category>
            <category><![CDATA[healthcare-domain]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Tue, 20 Oct 2026 12:31:01 GMT</pubDate>
            <atom:updated>2026-10-20T12:31:01.749Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi all,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YwTt7PbiRQx2BNq97mjq4Q.png" /><figcaption>pic from <a href="https://www.gatewatcher.com/wp-content/uploads/2024/08/Image1-Diagram-of-HL7-capabilities-extracted-from-CodeIT.png">https://www.gatewatcher.com/wp-content</a></figcaption></figure><p>This is part one of the HL7 series. I recently came to know about this standard in the healthcare domain. I actually saw in the SSE vacancy that they were looking for a candidate who was comfortable with and familiar with HL7 standards. So I did some R&amp;D regarding these concepts, which is very odd and new for me. So I wish to share my findings from my R&amp;D journey for HL7. I came to know they even have exams for these standards, and they are more expensive, and I think they are not suitable for noob who are just following and starter.</p><p>In my words, Health Level Seven is a standard protocol where all healthcare domains are integrated with each other without collapsing each other&#39;s different systems to achieve a common goal.</p><p>Modern healthcare facilities are very advanced and we can even get our reports from another country&#39;s laboratory within seconds, like X-rays, etc…Even in one hospital, many areas of the hospital different different rooms and facilities- are separated and isolated from others. So, to get full prescriptions and patient reports, we need to use a common method of transferring sensitive data interoperability across different software vendors.</p><p>For example, X-ray vendors, radiology, and lab information system they use different types of language to talk to each other.<strong>HL7 is an international healthcare standard to communicate seamlessly, ensuring patients&#39; data follow them accurately across every care setting.</strong></p><p>History of HL7: It was founded in 1987 profit, ANSI-accredited Standards Development Organization. HL7 takes its name from a key networking concept. At this level, 7 refers to the application layer in the OSI model. I think you already heard about it; it was basic 101 in networking.;).</p><p>HL7 does not govern how cables, routers, or TCP/IP connections move data. Instead, it dictates the <strong>structure, syntax, and semantic meaning</strong> of the clinical payload delivered at the application layer.</p><p>I was able to find HL7 has different versions, like the FHIR protocol you already heard about in the modern ERA. It is mostly used in REST APIs, and its format is JSON.</p><ul><li>HL7 v2, it was the first version. Extremely lightweight, event-driven, and highly backwards-compatible. However, it permits extensive customisation, which can lead to implementation variations between vendors. Format is plain text using |,^ and ~.</li><li>HL7 Version 3 (v3.x) — The Over-Engineered Standard,xml format.</li><li>Clinical Document Architecture (CDA / C-CDA),xml format document exchange.</li><li>FHIR, Fast Healthcare Interoperability Resources.Modern protocol,easy to use and understand.</li></ul><p><strong>Anatomy of an HL7 v2 Message.</strong></p><p>Example,</p><pre>MSH|^~\&amp;|EPIC|HOSPITAL_A|LAB_SYS|HOSPITAL_A|20261015193000||ADT^A01|MSG00001|P|2.3<br>PID|1||10045678^^^HOSPITAL_A^MR||DOE^JOHN^MIDDLE||19850412|M|||123 MAIN ST^^CITY^STATE^12345<br>PV1|1|I|3NW^302^1||||1234^SMITH^JANE^MD|||SUR|||||ADM|20261015192500</pre><p>MSH- message Header and inside this, values are separated by special characters like and ~, etc…</p><p>| used to separate values. And there are trigger events for this header, like HTTP status code, A01, etc. This article is for basic understand HL7. So I didnt expalin each one of code, they are many codes: ADT(Admission, Discharge, and Transfer), will share another article for them.</p><p>There are common message type like, i saw many diagrams to explain their activities, like,</p><ul><li><strong>ADT:</strong> Admit, Discharge, Transfer.</li><li><strong>ORM:</strong> Order Entry (e.g., lab or radiology request).</li><li><strong>ORU:</strong> Observational Results Unsolicited (e.g., returning lab results).</li><li><strong>DFT:</strong> Detailed Financial Transaction (billing).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*FotdSHW60KNRDOnhRkuprw.jpeg" /><figcaption>pic from <a href="https://www.saravanansubramanian.com/assets/images/hl7/hapihl7tutorial/hl7messagingarchitecture.jpg">https://www.saravanansubramanian.com/assets/images/hl7/hapihl7tutorial/hl7messagingarchitecture.jpg</a></figcaption></figure><p>Modern softwares used HL7 FHIR standard, which is easy to read and understand using JSON format. <strong>More readable than the older version and faster.</strong></p><pre>{<br>  &quot;resourceType&quot;: &quot;Patient&quot;,<br>  &quot;id&quot;: &quot;10045678&quot;,<br>  &quot;name&quot;: [{<br>    &quot;use&quot;: &quot;official&quot;,<br>    &quot;family&quot;: &quot;Doe&quot;,<br>    &quot;given&quot;: [&quot;John&quot;, &quot;Middle&quot;]<br>  }],<br>  &quot;gender&quot;: &quot;male&quot;,<br>  &quot;birthDate&quot;: &quot;1985-04-12&quot;<br>}</pre><p>This is not easy in real-world applications, and when it harder when we implemention phases migration phases.</p><p>I think this article is enough for part one of HL7 series. All I want to share finding of my R&amp;D with you. When you are in the healthcare domain, HL7 is a must to know its concepts and its theories in your day-to-day development.</p><p>Happy learning!</p><p><strong>Refereneces,</strong></p><ul><li>Reference book, HL7 for busy professionals</li><li><a href="https://www.gatewatcher.com/wp-content/uploads/2024/08/Image1-Diagram-of-HL7-capabilities-extracted-from-CodeIT.png">https://www.gatewatcher.com/wp-content/uploads/2024/08/Image1-Diagram-of-HL7-capabilities-extracted-from-CodeIT.png</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb1623cac034" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Concurrent Collections in Java PART TWO(Compare and Contrast HashMap, HashTable and…]]></title>
            <link>https://heshanu97.medium.com/concurrent-collections-in-java-part-two-hashmap-hashtable-and-concurrenthashmap-0165b131f021?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/0165b131f021</guid>
            <category><![CDATA[hash-table]]></category>
            <category><![CDATA[concurrenthashmap]]></category>
            <category><![CDATA[hashmap-in-java]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Sat, 06 Jun 2026 17:49:00 GMT</pubDate>
            <atom:updated>2026-06-06T17:52:50.798Z</atom:updated>
            <content:encoded><![CDATA[<h3>Concurrent Collections in Java PART TWO(Compare and Contrast HashMap, HashTable and ConcurrentHashMap)</h3><p>Hi All,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EQLjG5uyMgfT6-aCxCKjiw.jpeg" /><figcaption>pic from pexel.com</figcaption></figure><p>This is part two of the concurrency collection series. In this article, I hope to share my knowledge related to one of the popular interview<strong> “questions called compare and contract HashMap, Hashtable and our new topic called ConcurrentHashMap.</strong></p><p>You already know HashMap is not thread-safe, but Hashtable is thread-safe, and ConcurrentHashMap is thread-safe and higher-performance than the others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*1MTMcQC6FP7xeSJ6VsKBrA.png" /></figure><p>And compare with ConcurrentHashMap and Hashtable,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*aNz_tXe5ggCv6QnjOaQPMQ.png" /></figure><p>In a HashTable, suppose we want to modify the value in 1. It locks the whole structure and avoids a deadlock situation. It allows modifying values at one thread at a time. At the end of the modification process, it unlocks access to the resource for the thread. So and on. But you can read without disturbing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*NiS1I38LjNNEbOwxN3m3Rw.png" /></figure><p>But in Concurrent HashMap, it has segment locking mechanism. Each segment has a lock, so others can do their business without interrupting or locking the whole structure. This way helps to increase the performance of ConcurrentHashMap.</p><p>In other words, one thread can access one segment, and the other segment works fine as it is, and when each segment modifies a value, it uses its own lock, avoiding accessing other threads at the same time and maintaining mutual exclusivity to avoid a deadlock situation in the data structure. You can read any number of times, but when you modify the value, it locks itself with only one thread, and after the modification process, it unlock segement and allows other threads to access the shared resource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*00yMsSwQNQ_EYxPezMQPfQ.png" /></figure><p>So this segment locking is very useful, and it has another feature called the concurrency level. Which means the number of segments in HashMap, by default, is 16 segments and 16 concurrency levels.</p><p>I think this content is enough for part two.</p><p>Happy learning !!!!!</p><p>References-</p><ul><li>Java Documentation</li><li><a href="https://www.youtube.com/watch?v=aAvnT3L6Mlo&amp;list=PLd3UqWTnYXOlrFicu7spv8Z772MgGbXfQ">https://www.youtube.com/watch?v=aAvnT3L6Mlo&amp;list=PLd3UqWTnYXOlrFicu7spv8Z772MgGbXfQ</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8SluSBc4JeikkEmBVNgrJQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0165b131f021" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Concurrent Collections in Java PART ONE.]]></title>
            <link>https://heshanu97.medium.com/concurrent-collections-in-java-part-one-1315a07c1743?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1315a07c1743</guid>
            <category><![CDATA[concurrentmodification]]></category>
            <category><![CDATA[java-concurrency]]></category>
            <category><![CDATA[java-thread-safety]]></category>
            <category><![CDATA[java-collection]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Mon, 01 Jun 2026 06:22:17 GMT</pubDate>
            <atom:updated>2026-06-06T17:53:18.255Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi All,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EQLjG5uyMgfT6-aCxCKjiw.jpeg" /><figcaption>from pexel.com</figcaption></figure><p>In this article, I wish to share my own experience with famous interview questions and concepts in the Java language called Concurrent Collection. This package is in java.util.concurrent package.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*FZq8N9CYniF9OmKejiXV0g.jpeg" /></figure><p>I had several experiences with collections and concurrent collections during interviews. Among them, concurrent collections-related questions are more attractive, so I wish to share my experiences with you.</p><p>I assume you already know the collections framework in Java; it is a common and vital question in interviews.</p><h3><strong>First, we find out the necessity of Concurrent Collections. We already have a collection framework. Why do we actually want them in our code?.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*QqAltzyBK82L0yZ7gp3iQA.png" /></figure><p>Collections framework already has a thread-safe and synchronised implementation of the collection interface, like Vector, Hashtable, etc. Not all collections are thread-safe.</p><p>Thread-safe means it only allows access to the shared resource one thread at a time, by avoiding deadlocks. Normally, we address this issue using synchronized key word. But in collections, Java already handle deadlock situations using concurrent collections.</p><p>Concurrent collection is also an interface-like collection; it is a typical solution for a collection framework to handle concurrency. <strong>And concurrent collections are extended with serializable, callable, and runnable interfaces.</strong></p><p>There are major implementations of concurrent collection, such as</p><ul><li>ConcurrentHashMap</li><li>CopyOnWriteArrayList</li><li>CopyOnWriteArraySet</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fD0Xodj1_KSMD0OVaqiWig.jpeg" /><figcaption>pic from pexel.com</figcaption></figure><p>Let’s get started with Concurrent Map.</p><p><strong>Concurrent HashMap</strong> is an implementation of ConcurrentMap and the Map interface, but a map is not a collection interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*biozmBYKZ-Eifc3rZfAW0g.png" /></figure><p>And you already know a map is a pair data structure like a key-value pair structure, so it has features from both the Map interface and concurrentMap interface via inheritance.</p><p>ConcurrentHashMap has methods called</p><ul><li>putIfAbsent(Object key,Object value);</li><li>boolean remove(Object key,Object value);</li><li>boolean replace(Object key,Object oldvalue,Object newValue);</li></ul><p>If you remember the collections framework,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*FYYE37bphiWMMajrxNfphw.png" /></figure><p>You can easily look and get an idea about how ConcurrentHashMap is synchronised.</p><p>In the putIfAbsent() method, it is used.</p><pre>Object putIfAbsent(Object Key,Object value){<br>  if(!map.containKey(key)){<br>    	map.put(key,value);<br>  }else{<br>        return map.get(key);<br>  }<br>}</pre><p>In a normal HashMap, it puts the value directly and changes the value related to the key, without considering the existing value.</p><pre>import java.util.concurrent.ConcurrentMap;<br>import java.util.concurrent.ConcurrentHashMap;<br><br>class Main {<br><br>public static void main(String[] args) {<br>// Creating ConcurrentMap using ConcurrentHashMap<br>Map&lt;String, Integer&gt; numbers = new HashMap&lt;&gt;();<br><br>// Insert elements to map<br>numbers.put(&quot;Two&quot;, 2);<br>numbers.put(&quot;One&quot;, 1);<br>numbers.put(&quot;Three&quot;, 3);<br>System.out.println(&quot;Map: &quot; + numbers);<br><br>//it will display like a dictionary<br>what if I add value for key called One,<br>numbers.put(&quot;One&quot;, 10);<br><br>//it shows update value for key<br>System.out.println(&quot;Map: &quot; + numbers);<br>[{&quot;One&quot;:10},{&quot;Two&quot;:2},{&quot;Three&quot;:10}]<br></pre><p>In a normal HashMap, it doesn&#39;t care about existing values in the Map. So this is enough and works fine in local and simple scenarios, but in the real world, this will raise ConcurrentModificationException.</p><pre>import java.util.concurrent.ConcurrentHashMap;<br>import java.util.concurrent.ConcurrentMap;<br><br>public class ConcurrentMapDemo {<br>    public static void main(String[] args) {<br>        // Instantiate a concurrent map<br>        ConcurrentMap&lt;String, Integer&gt; numberConcurrentMap= new ConcurrentHashMap&lt;&gt;();<br>       <br>        numberConcurrentMap.put(&quot;One&quot;, 1);<br>        numberConcurrentMap.put(&quot;Two&quot;, 2);<br>        numberConcurrentMap.put(&quot;Three&quot;, 3);<br><br>        // Atomic operation: Add only if missing<br>        numberConcurrentMap.putIfAbsent(&quot;One&quot;, 101);<br>        numberConcurrentMap.putIfAbsent(&quot;Two&quot;, 102);<br>        numberConcurrentMap.putIfAbsent(&quot;Three&quot;, 103);<br>        System.out.println(&quot;Final Inventory: &quot; +numberConcurrentMap ); <br>        // Output: { One0=1, Two=2, Three=3}<br>    }<br>}</pre><p>But we can change the values of the key using the replace method like this,</p><pre>boolean success1 =numberConcurrentMap.replace(&quot;One&quot;, 1, 101);<br>System.out.println(&quot;Final Inventory: &quot; +numberConcurrentMap ); <br>        // Output: { One0=101, Two=2, Three=3}<br><br>//syntax for replace method is<br>// boolean success1 =numberConcurrentMap.replace(Object key, Object existingvalue, Object newValue); </pre><pre>// We can remove entry because 101 key<br>// is associated with For value<br>numberConcurrentMap.remove(101, &quot;Geeks&quot;);<br>numberConcurrentMap.remove(101); //also possible</pre><p>What if more than one thread tries to change the value from one key? It will raise an exception, and this issue will be solved using ConcurrentHashMap’s concurrency level. Usually, it has 16 concurrency levels by default.</p><p>And each segment has its own lock instead of one lock for the whole structure, like a HashMap.Will explain this by contrasting HashMap, hashTable and ConcurrentHashMap.</p><p>I think this content is enough for PART One of Concurrent Collections in Java Series.</p><p>Happy coding…</p><p>References-</p><ul><li>Java Documentation</li><li><a href="https://www.youtube.com/watch?v=aAvnT3L6Mlo&amp;list=PLd3UqWTnYXOlrFicu7spv8Z772MgGbXfQ">https://www.youtube.com/watch?v=aAvnT3L6Mlo&amp;list=PLd3UqWTnYXOlrFicu7spv8Z772MgGbXfQ</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8SluSBc4JeikkEmBVNgrJQ.jpeg" /><figcaption>pic from pexel.com</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1315a07c1743" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What can be learned from Chapter Two of the “Working Effectively with Legacy Code” book?]]></title>
            <link>https://heshanu97.medium.com/what-can-be-learned-from-chapter-two-of-the-working-effectively-with-legacy-code-book-6eead4a40b9d?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6eead4a40b9d</guid>
            <category><![CDATA[legacy-code-modernization]]></category>
            <category><![CDATA[working-with-legacy-code]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Thu, 30 Apr 2026 19:21:50 GMT</pubDate>
            <atom:updated>2026-04-30T19:21:50.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*jdqNUmkvu4HlEWy1oJJ6dQ.png" /></figure><p>Hi All,<br>In this article, I wish to share what I learned by referring to the book called “Working Effectively with Legacy Code. So let’s get started.</p><p>I’m on chapter 2, and I came to know a term called “Edit and pray”, which I’ve not heard before, and it has a meaning change and pray for the best.</p><p>In the fast-paced world of software engineering, we often obsess over “clean code,” “architecture,” and the latest frameworks. But Michael Feathers, in his seminal work <em>Working Effectively with Legacy Code</em>, argues that there is something far more fundamental that determines the long-term survival of a project: <strong>The Feedback Loop.</strong></p><p>Specifically, in Chapter 2, titled “The Feedback Loop,” Feathers explores the mechanics of how we change software. If you’ve ever pushed code and then sat there with a knot in your stomach, hoping nothing breaks, this chapter was written for you.</p><p><strong>The Two Worlds of Software Change</strong></p><p>Feathers categorises the way we approach code modifications into two distinct philosophies. Understanding which one you inhabit is the first step toward professional growth.</p><h3>1. Edit and Pray</h3><p>This is, unfortunately, the industry standard. In this world, you plan your change carefully, you write the code, and then you “pray” that it works. You might do some manual smoke testing or wait for a QA report, but the actual feedback is slow and disconnected.</p><ul><li><strong>The Trap:</strong> It relies on human perfection. As the system grows, the “prayer” gets longer because the ripple effects of a single change become impossible to predict mentally.</li><li><strong>The Cost:</strong> It leads to <strong>Fear-Driven Development</strong>. When you are afraid to touch a piece of code, that code begins to rot.</li></ul><h3>2. Cover and Modify</h3><p>This is the professional’s path. Before you touch a single line of functional code, you “cover” it with a <strong>test harness</strong>.</p><ul><li><strong>The Goal:</strong> To get a notification within seconds if your change broke existing behaviour.</li><li><strong>The Result:</strong> You move from a state of anxiety to a state of confidence. You aren’t guessing anymore; you are observing facts.</li></ul><h3>Redefining “Legacy Code”</h3><p>Perhaps the most disruptive insight from Feathers is his functional definition of legacy code. He moves away from age, language, or “clunky” syntax and focuses entirely on safety:</p><blockquote><strong><em>“Legacy code is simply code without tests.”</em></strong></blockquote><p>I already mentioned this in chapter one. This is a wake-up call for many. It doesn’t matter if you wrote a microservice yesterday using the latest Spring Boot or Angular features; if you cannot change it and get immediate feedback on whether it’s broken, you are working with legacy code. Without tests, the code is “dead” because it cannot be safely evolved — it can only be patched.</p><h3>The Power of the “Sub-Second” Feedback Loop</h3><p>Why are automated tests so vital? It isn’t just about finding bugs; it’s about <strong>cognitive load</strong>.</p><p>Imagine you make a logic error in a complex algorithm:</p><ul><li><strong>In an “Edit and Pray” environment,</strong> you might find out in 3 days when a bug report comes from production. By then, you’ve lost the context. You have to spend hours re-learning that part of the system just to fix your own mistake.</li><li><strong>In a “Cover and Modify” environment,</strong> your unit tests tell you in <strong>seconds</strong>. Since the change is fresh in your mind, the fix takes moments.</li></ul><p>This speed changes your relationship with the code. When feedback is instant, you are willing to refactor and clean up “smelly” code. When feedback is slow, you become a “feature-adder” who is terrified of cleaning up the mess.</p><h3>Sensing and Separation: The Mechanics of Testing</h3><p>Feathers explains that to get code under a test harness, you need two things:</p><ol><li><strong>Sensing:</strong> The ability to see the effects of your code (values, state changes) that aren’t usually visible.</li><li><strong>Separation:</strong> The ability to take a piece of code out of its production environment (away from the real database or live API) and run it in a test environment.</li></ol><p>This leads to the <strong>Legacy Code Dilemma</strong>: To put tests in place, you often have to change code. But to change code safely, you need tests. The rest of the book provides the “breaking dependency” patterns to solve this catch.</p><p>As developers, our job isn’t just to write features; it’s to manage the evolution of a system. If your primary strategy for change is “Edit and Pray,” you are building a house of cards.</p><p>By shifting to a <strong>“Cover and Modify”</strong> mindset, you aren’t just writing tests — you are building a feedback loop that allows your software to live, grow, and improve without the constant shadow of fear.</p><p>I think this content is enough for chapter 2, what I gained from the book. I learn a lot, and I wish you too. I personally think reading a book related to Software Engineering is a much better option than LLM-generated code or YouTube tutorials.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6eead4a40b9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What can be learned from Chapter One of the “Working Effectively with Legacy Code” book?]]></title>
            <link>https://heshanu97.medium.com/what-can-be-learned-from-chapter-one-of-the-working-effectively-with-legacy-code-book-204e7ec495ec?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/204e7ec495ec</guid>
            <category><![CDATA[code-refactoring]]></category>
            <category><![CDATA[working-with-legacy-code]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Sat, 25 Apr 2026 20:26:53 GMT</pubDate>
            <atom:updated>2026-04-25T21:14:08.193Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*jdqNUmkvu4HlEWy1oJJ6dQ.png" /></figure><p>Hi All,</p><p>This article focuses on the area from “Working Effectively with Legacy Code”. I recently came across this book on LinkedIn and read a few chapters, which gave me another perspective on Legacy code and helped me understand it better.</p><p>“In my understanding, legacy code is existing code that is often old or poorly structured, making it difficult to maintain or modify safely while meeting evolving business requirements.”But the issue is the frequent changes in requirements, and it is unable to adapt to new business requirements. And I know legacy means like Cobol code, BUT</p><h3>Huge BUT,</h3><p>According to the book, legacy code is a codebase without proper tests.</p><pre>Legacy code = code without tests</pre><p>The author’s logic is that if you have tests, you can change the code and know immediately if you broke something. If you don’t have tests, you’re just guessing. Changing untested code is like performing surgery in the dark.</p><p>And the book shows 4 reasons for changing the software in the existing code,</p><ul><li>Adding a feature, making something new</li><li>Fixing a bug, making the software supposed to do</li><li>Improving the design, refactoring the existing code structure</li><li>Optimising resource usage, making it faster.</li></ul><p>Sometimes we have to work with such kind of codebases, but we didn&#39;t know it was a kind of legacy system. And we have some idea about legacy systems and how they change and update without breaking existing functionalities because this Systems are may be very critical systems.</p><p>Adding a new feature to the system may affect the system’s functionalities. And also fixing an existing bug, causing a change to the existing codebase.</p><blockquote>Adding a method doesn’t change behavior unless the method is called somehow.</blockquote><p>The book gives a simple example,</p><pre>public class CDPlayer<br>{<br> public void addTrackListing(Track track) {<br> ...<br> }<br> ...<br>}</pre><p>After we add the replaceTrackListing method,</p><pre>public class CDPlayer<br>{<br> public void addTrackListing(Track track) {<br> ...<br> }<br> public void replaceTrackListing(String name, Track track) {<br> ...<br> }<br> ...<br>}</pre><blockquote>Adding a method doesn’t change behavior unless the method is called somehow.</blockquote><p>When we talk about improving the design, there are many ways, such as refactoring, general cleanup, etc…In other words,</p><p>Refactoring differs from general cleanup in that we aren’t just doing low-risk things, such as reformatting source code, or invasive and risky things, such as rewriting chunks of it. Instead, we are making a series of small structural modifications, supported by tests, to make the code easier to change.</p><p>Developers are afraid to change existing code and architecture directly, and they need a way to change legacy systems. So this book suggests some ways in the upcoming chapters.</p><p>And Optimisation means, focus on the performance of the codebase, and the “something else” is some resource used by the program, usually time or memory.</p><p>I’m confused between refactoring and optimising the process, but the book explains it with proper examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*evHOEoQI3LZGy3tMEnPhKg.png" /></figure><p>Refactoring changes the structure and flow of the project, but optimising is related to resource usage.</p><blockquote>We have to figure out how to preserve the rest of the behaviour. Unfortunately, preserving it involves more than just leaving the code alone. We have to know that the behaviour isn’t changing, and that can be tough. The amount of behaviour that we have to preserve is usually very large, but that isn’t the big deal. The big deal is that we often don’t know how much of that behaviour is at risk when we make our changes. If we knew, we could concentrate on that behaviour and not care about the rest. Understanding is the key thing that we need to make changes safely.</blockquote><p>Preserving existing functionalities is one of the largest challenges in software development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*e3Hsio66FKB04k54_jYQ4A.png" /></figure><p>What is Risky change? When we need to make changes and preserve behaviour, it can involve considerable risk.</p><p>The book suggests three questions to mitigate risks,</p><ul><li>What changes do we have to make?</li><li>How will we know that we’ve done them correctly?</li><li>How will we know that we haven’t broken anything?</li></ul><p>When you make changes in any large system, you can expect to take a little time to get familiar with the area you are working with.</p><p>The difference between good systems and bad ones is that, in the good ones, you feel pretty calm after you’ve done that learning, and you are confident in the change you are about to make. In poorly structured code, the move from figuring things out to making changes feels like jumping off a cliff to avoid a tiger. You hesitate and hesitate. “Am I ready to do it? Well, I guess I have to.”</p><p><strong>Avoiding change has other bad consequences. When people don’t make changes often, they get rusty at it</strong>. Breaking down a big class into pieces can be pretty involved work unless you do it a couple of times a week. When you do, it becomes routine. You get better at figuring out what can break and what can’t, and it is much easier to do. The last consequence of avoiding change is fear. Unfortunately, many teams live with incredible fear of change, and it gets worse every day. Often, they aren’t aware of how much fear they have until they learn better techniques, and the fear starts to fade away.</p><p>I think this content is enough for chapter 1, and I hope these points can be easily found and extracted from the book. I learn a lot and change and update my knowledge areas related to legacy code bases.</p><p>Happy coding…! Happy reading…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=204e7ec495ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t misuse Dependency Injection in an Angular application]]></title>
            <link>https://heshanu97.medium.com/dont-misuse-dependency-injection-in-an-angular-application-e07cde297b2c?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e07cde297b2c</guid>
            <category><![CDATA[structural-design-pattern]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[facade-design-pattern]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 18:19:03 GMT</pubDate>
            <atom:updated>2026-04-25T18:29:07.541Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi All,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OBh3Crjl0vmCF5x929ztqw.jpeg" /><figcaption>pic from pexel.com</figcaption></figure><p>In this article, I wish to share my personal experience while developing the Angular frontend framework. I have refactoring experience with Angular&#39;s dependency injection mechanism.</p><p>I hope you already know depedency injection in the software development process. In simple words, it is the best practice and a way to avoiding tight coupling and pave the way to loose coupling. I misuse dependency without having proper knowledge. Here is how I learn, use and how I refactor Angular application and avoids too many low-level dependencies.</p><p>Scenario: Suppose you have an Angular application with 5 services such as user,auth,order,notification and logger.I used to use dependency injection for above services, type a script file like below.</p><pre>constructor(<br>  private userService: UserService,<br>  private authService: AuthService,<br>  private orderService: OrderService,<br>  private notificationService: NotificationService,<br>  private logger: LoggerService<br>) {}</pre><p>This kind of way is way better when you have a few services, but when it increases the parameters of the constructor, you already know there are life cycle procedures for Angular, like constructor,onchange,oninit, etc.</p><p>The issue is that this way consumes more memory and loading time with high dependency. I misuse dependency injection, and I violate the purpose of the Angular framework without intending to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7wRWruTlPwnGuCLe5reWgg.jpeg" /></figure><p>So the solution for this is to use the Facade design pattern. I think you already have some idea about design patterns; they are not strict rules to follow, but if we follow design patterns, we can easily debug, refactor and also collaborate with others. The main advantage is that, using a design pattern, we can collaborate more with others. When we told other people,” I use the facade design pattern, they got some idea about how it works and the procedure.</p><p>I will guide you to solve this performance issue with the facade design pattern. The facade design pattern is one of the structural design patterns, like creational and behavioural design patterns. In simple words, we create a single part instead of calling complex parts. For example, we can get a wedding planner who plans all the required functions, events, and everything for us. We need only hire or call an event or wedding planner and give our requirements, that’s all.</p><p>We can get some idea from the above design pattern to solve this issue. So we can hide all complex things and show only a simple component.</p><pre>@Injectable({ providedIn: &#39;root&#39; })<br>export class OrderFacade {<br><br>  constructor(<br>    private orderService: OrderService,<br>    private paymentService: PaymentService<br>  ) {} //use only related services only instead of all services <br><br>  placeOrder(order: any) {<br>    return this.paymentService.process(order).pipe(<br>      switchMap(() =&gt; this.orderService.create(order))<br>    );<br>  }<br>}</pre><p>The above facade is related to the user and its functionalities and its related services. Instead of a big, huge one, we show only simple things to call when needed.</p><p>After that, we can use the above facade code like below.</p><pre>constructor(private orderFacade: OrderFacade) {}<br>//this constructor it has <br>//simple items for dependency injection<br><br>ngOnInit() {<br>  this.orderFacade.placeOrder().subscribe();<br>}</pre><p>And use multiple facades, don&#39;t mix all into one facade code.</p><pre>@Injectable({ providedIn: &#39;root&#39; })<br>export class AuthFacade {<br><br>  constructor(private authService: AuthService) {}<br><br>  login(data: any) {<br>    return this.authService.login(data);<br>  }<br>}</pre><pre>@Injectable({ providedIn: &#39;root&#39; })<br>export class OrderFacade {<br><br>  constructor(<br>    private orderService: OrderService,<br>    private paymentService: PaymentService<br>  ) {}<br><br>  placeOrder(order: any) {<br>    return this.paymentService.process(order).pipe(<br>      switchMap(() =&gt; this.orderService.create(order))<br>    );<br>  }<br>}</pre><p>You can use the above code like,</p><pre>@Injectable({ providedIn: &#39;root&#39; })<br>export class DashboardFacade {<br><br>  constructor(<br>    private userFacade: UserFacade,<br>    private orderFacade: OrderFacade<br>  ) {}<br><br>  loadDashboard() {<br>    return combineLatest([<br>      this.userFacade.getUsers(),<br>      this.orderFacade.getOrders()<br>    ]);<br>  }<br>}</pre><p>Diagram like before facade design pattern,</p><pre>Big compoent constructor<br>    |<br>Service call</pre><p>After using facade design pattern.</p><pre>Component<br>   ↓<br>Facade  (orchestrates logic)<br>   ↓<br>Services (API, utilities, etc.)</pre><pre>Compoent<br>  |<br>userService+orderService (UserOrderFacade)<br>  |<br>Service </pre><p>There are some cons, like it adds an extra abstract layer, and it introduces an extra learning curve for developers. And we have to use this pattern carefully without introducing new complexity and tight coupling.</p><p><strong>This is typically used for large and scalable applications, not suitable for simple projects, and this may introduce more complexity to the codebase.</strong></p><p>I think this content is enough for how I learn and misuse DI for application. I wish you could get some idea about how I solve this. This article is based on my own experience.</p><p>Happy coding and learning.</p><p>References for Facade design pattern-<a href="https://refactoring.guru/design-patterns/facade">https://refactoring.guru/design-patterns/facade</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e07cde297b2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choose a suitable Rate Limiter for your distributed Systems.]]></title>
            <link>https://heshanu97.medium.com/choose-a-suitable-rate-limiter-for-your-distributed-systems-8f4819914a81?source=rss-dce3d674c0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f4819914a81</guid>
            <category><![CDATA[rate-limiting]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[token-algorithm]]></category>
            <category><![CDATA[leaky-bucket-algorithm]]></category>
            <dc:creator><![CDATA[Heshan Umayanga]]></dc:creator>
            <pubDate>Sat, 18 Apr 2026 18:40:50 GMT</pubDate>
            <atom:updated>2026-04-18T18:40:50.828Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BNgmOdrVKgKDInGSDpvIw.png" /><figcaption><a href="https://blog.algomaster.io/p/designing-a-distributed-rate-limiter">https://blog.algomaster.io/p/designing-a-distributed-rate-limiter</a></figcaption></figure><p>Hi All,</p><p>This article is all about rate limiters in networking and APIs. I wish to share my knowledge on choosing a suitable rate limiter for your APIs.</p><p>Huge thanks to ByteByteGo for their documentation on rate limiters. I&#39;ve done some R&amp;D stuff to apply these concepts to my projects and system design interviews.</p><h3>Why do you want these Rate Limiters?</h3><p>In system designing concepts, we discuss how to handle 1 million or more request-related scenarios and real-world systems, how they manage huge traffic and techniques to mitigate issues.</p><p>This decentralised system is huge and complex. So abuses are very common on these systems. like too many requests, mitigate DDoSs, etc.</p><p>It helps to send all users&#39; requests to the system, avoiding monopolising resources for all clients.</p><p><strong>We can get those features by using Rate Limiter. Such as Strong consistency, high availability, low latency, scalability, etc.</strong></p><h3>Popular rate-limiting algorithms like</h3><p>Token Bucket, Leaky bucket, fixed window counter, sliding window log, etc…</p><p><strong>The token bucket</strong> algorithm is like, tokens are added in the bucket at a fixed rate, each consumes a token, and if no tokens are available, the request is rejected. This is a simple rate limiter, easy to implement, and the problem with the token bucket is the overhead of tracking buckets during scaling phases.</p><p>And the leaky bucket algorithm’s process is like requests enter a queue and are processed at a fixed rate. If the bucket is full, new requests are dropped. You can see this feature by receiving a 429 Too Many Requests HTTP status in the browser. Pros are like smooth traffic and ensure steady request processing, and cons go to the required queue management</p><p>We have a<strong> fixed window counter algorithm</strong>, so it works on fixed time windows, like per min and resets at each window. It is simple, has low memory usage, and the issues of this algorithm are allowing traffic spikes at window edges.</p><p><strong>Sliding Window Log:</strong> Tracks the timestamp of each request. For a new request, it counts how many requests occurred in the last window. P<strong>ros are like </strong>highly accurate, no edge spikes.<strong>Cons:</strong> High memory usage, especially for high-throughput systems.</p><p><strong>Sliding Window Counter: </strong>Combines a fixed window and a sliding log. Uses weighted counts from the current and previous windows. <strong>Pros are like:</strong> Balances accuracy and memory efficiency. <strong>Cons are like:</strong> Slightly more complex to implement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*PdhifmmWBG99VZSvg0-Inw.png" /></figure><p>I think this content is enough for rate limiting basics. When we have a basic idea of anything, we can easily learn by using LLMs nowadays, fundamental matters for everything.</p><p>Happy Reading…!</p><p>References-ByteByteGo site</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f4819914a81" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>