<?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 Ranushka Pasindu on Medium]]></title>
        <description><![CDATA[Stories by Ranushka Pasindu on Medium]]></description>
        <link>https://medium.com/@rdharmaranga?source=rss-87a02a8af800------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xq02BSLz3E0vZdYd</url>
            <title>Stories by Ranushka Pasindu on Medium</title>
            <link>https://medium.com/@rdharmaranga?source=rss-87a02a8af800------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 08:22:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rdharmaranga/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Power of Lazy Initialization]]></title>
            <link>https://medium.com/@rdharmaranga/the-power-of-lazy-initialization-e73f7540476b?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/e73f7540476b</guid>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Tue, 10 Dec 2024 02:56:18 GMT</pubDate>
            <atom:updated>2024-12-10T02:56:18.648Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6BsTBE-IliF7xwjz" /><figcaption>Photo by <a href="https://unsplash.com/@blake_lipthratt?utm_source=medium&amp;utm_medium=referral">Blake Lipthratt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The Power of Lazy Initialization in .NET</h3><p>When building applications in .NET, you often encounter situations where certain objects or resources are expensive to create, or you don’t need them immediately. Instead of initializing these objects upfront, there’s a better approach: <strong>lazy initialization</strong>.</p><p>In this article, we’ll explore what lazy initialization is, why it’s useful, and how you can implement it effectively. I’ll keep it simple, practical, and to the point.</p><h3>What is Lazy Initialization?</h3><p>Lazy initialization is a design pattern where the creation of an object is delayed until the moment it’s actually needed. Instead of immediately allocating memory or executing expensive operations, you “wait and see” if the object is ever required. If it isn’t, you save time and resources.</p><p>Think of it like brewing coffee. If you’re not sure you’ll drink it, you might wait until you’re ready to pour a cup before making the brew. This way, you avoid wasting coffee if you change your mind.</p><h3>Why Use Lazy Initialization?</h3><p>Here are some common reasons to use lazy initialization:</p><ol><li><strong>Performance Optimization</strong>:<br> If creating an object involves heavy computations or retrieving data from an external service, lazy initialization ensures that this cost is incurred only when absolutely necessary.</li><li><strong>Resource Management</strong>:<br> Some objects use limited system resources, such as network connections or file handles. Initializing them upfront could lead to unnecessary resource consumption.</li><li><strong>Reduced Startup Time</strong>:<br> Applications that initialize multiple services upfront might experience slower startup times. By deferring initialization, you can make the app start faster.</li><li><strong>Thread Safety</strong>:<br> Lazy initialization ensures that the object is created only once, even in multi-threaded environments.</li></ol><h3>How Lazy Initialization Works in .NET</h3><p>.NET provides the <strong>Lazy&lt;T&gt;</strong> class to handle lazy initialization in a clean and thread-safe way. Here&#39;s how it works:</p><ul><li>You wrap the expensive object in a Lazy&lt;T&gt; instance.</li><li>The object isn’t created until you access the Value property.</li></ul><h3>Practical Example: Lazy Initialization for a RestClient</h3><p>Suppose you’re working with a RestClient in a .NET application. This client is used to make HTTP requests, but it requires a base URL that you retrieve from a database or an API. Since the base URL retrieval and RestClient creation are both expensive operations, you want to delay this process until the client is actually needed.</p><p>Here’s how you can use lazy initialization:</p><h3>Without Lazy Initialization</h3><p>This approach initializes the RestClient upfront, even if it&#39;s never used:</p><pre>var baseAddress = await GetBaseAddressFromDatabaseAsync();<br>var client = new RestClient(baseAddress); // Created immediately</pre><h3>With Lazy Initialization</h3><p>In this version, the RestClient is created only when accessed:</p><pre>private Lazy&lt;Task&lt;RestClient&gt;&gt; lazyClient;<br><br>public void InitializeClient()<br>{<br>    lazyClient = new Lazy&lt;Task&lt;RestClient&gt;&gt;(async () =&gt;<br>    {<br>        string baseAddress = await GetBaseAddressFromDatabaseAsync();<br>        return new RestClient(baseAddress);<br>    });<br>}<br>public async Task&lt;RestClient&gt; GetClientAsync()<br>{<br>    return await lazyClient.Value; // The client is created here if not already initialized<br>}</pre><h3>Benefits in Real-World Scenarios</h3><h3>1. Avoid Unnecessary HTTP Connections</h3><p>If your application handles multiple tenants but not all tenants make API calls, you don’t want to create a RestClient for every tenant. Lazy initialization ensures the RestClient is created only when the tenant makes an API call.</p><h3>2. Thread-Safe Initialization</h3><p>With Lazy&lt;T&gt;, the object is created only once, even if multiple threads try to access it simultaneously. This avoids bugs like duplicate clients or race conditions.</p><h3>3. Easier Integration with Dependency Injection (DI)</h3><p>You can combine lazy initialization with DI to ensure the RestClient is created efficiently across your application.</p><h3>Example: A Complete RestClientFactory</h3><p>Here’s how you can implement lazy initialization in a RestClientFactory that works with DI:</p><pre>using System;<br>using System.Threading.Tasks;<br>using RestSharp;<br><br>public class RestClientFactory<br>{<br>    private readonly Lazy&lt;Task&lt;RestClient&gt;&gt; lazyClient;<br>    public RestClientFactory(Func&lt;Task&lt;string&gt;&gt; baseAddressProvider)<br>    {<br>        lazyClient = new Lazy&lt;Task&lt;RestClient&gt;&gt;(async () =&gt;<br>        {<br>            string baseAddress = await baseAddressProvider();<br>            return new RestClient(baseAddress);<br>        });<br>    }<br>    public async Task&lt;RestClient&gt; GetClientAsync()<br>    {<br>        return await lazyClient.Value; // Creates the client only when accessed<br>    }<br>}</pre><h3>Usage in a .NET Application</h3><p><strong>Register the Factory with DI</strong>:</p><pre>services.AddSingleton&lt;RestClientFactory&gt;(provider =&gt; {<br><br>var tenantSettingsRepository = provider.GetRequiredService&lt;ITenantSettingsRepository&gt;();     <br>return new RestClientFactory(() =&gt; tenantSettingsRepository.GetBaseAddressAsync()); <br>});</pre><p><strong>Use the Factory</strong>:</p><pre>public class MyService {<br>  private readonly RestClientFactory restClientFactory;      <br>  public MyService(RestClientFactory restClientFactory){         <br>    this.restClientFactory = restClientFactory;     <br>  }      <br>public async Task DoSomethingAsync(){         <br>  var client = await restClientFactory.GetClientAsync();         // Use the client for API calls     <br>  } <br>}</pre><h3>When to Avoid Lazy Initialization</h3><p>While lazy initialization is useful, it’s not always the best choice:</p><ul><li><strong>When Objects are Always Needed</strong>: If the object is used immediately in most cases, lazy initialization adds unnecessary complexity.</li><li><strong>Frequent Reinitialization</strong>: If the lazy-initialized object changes frequently, it may be better to initialize it upfront or use a different pattern.</li></ul><h3>Conclusion</h3><p>Lazy initialization is a simple yet powerful pattern that can optimize your application’s performance and resource usage. By combining Lazy&lt;T&gt; with asynchronous initialization, you can efficiently handle even complex scenarios like HTTP clients with external dependencies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e73f7540476b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In software development, STS (Short-Term Support) and LTS (Long-Term Support) are common terms used…]]></title>
            <link>https://medium.com/@rdharmaranga/in-software-development-sts-short-term-support-and-lts-long-term-support-are-common-terms-used-bb16a2889410?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb16a2889410</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Fri, 15 Nov 2024 01:31:51 GMT</pubDate>
            <atom:updated>2024-11-15T01:34:20.201Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is the difference between LTS and STS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f8jclXQih-N5L3cp" /><figcaption>Photo by Sheng Hu on Unsplash</figcaption></figure><p>In software development, STS (Short-Term Support) and LTS (Long-Term Support) are common terms used to denote the support lifecycles of software releases. Here’s a detailed look at what they mean and why they matter:</p><p><strong>1. Long-Term Support (LTS)</strong></p><p>Definition: LTS versions are software releases that receive extended support, typically focused on stability and security updates rather than new features.</p><p>Duration: LTS versions are maintained for an extended period, often ranging from 2 to 5 years or more, depending on the software vendor.</p><p>Updates: LTS versions primarily receive:</p><p>Security patches</p><p>Critical bug fixes</p><p>Performance improvements</p><p>Use Case: LTS versions are ideal for:</p><p>Enterprise applications that require stability and reduced risk.</p><p>Systems where frequent upgrades are not feasible due to downtime concerns.</p><p>Users or organizations that prefer a predictable release cycle.</p><p><strong>Examples</strong>:</p><p>Node.js: LTS releases are supported for 30 months (2.5 years).</p><p>Ubuntu Linux: LTS versions are supported for 5 years.</p><p>.NET Core/ASP.NET: LTS releases have support for 3 years.</p><p>Benefits of LTS:</p><p>Stability: Fewer changes ensure a reliable environment.</p><p>Reduced Maintenance: Less frequent upgrades mean lower maintenance costs.</p><p>Better Support: More focus on critical updates and bug fixes.</p><p><strong>2. Short-Term Support (STS)</strong></p><p>Definition: STS versions (also known as non-LTS or current versions) are software releases that include the latest features, improvements, and changes but have a shorter support window.</p><p>Duration: STS versions typically have a support period of 6 months to 1 year.</p><p>Updates: STS versions receive:</p><p>Frequent feature updates</p><p>Regular security and bug fixes, but for a limited time</p><p>Use Case: STS versions are suited for:</p><p>Developers and early adopters who want to leverage the latest features.</p><p>Projects that can tolerate frequent updates and changes.</p><p>Scenarios where innovation and new capabilities are prioritized over long-term stability.</p><p><strong>Examples</strong>:</p><p>Node.js: STS releases are supported for only 6 months after a new release.</p><p>Ubuntu Linux: Non-LTS versions have 9 months of support.</p><p>.NET Core/ASP.NET: STS releases are typically supported for 18 months.</p><p>Benefits of STS:</p><p>Access to New Features: Get the latest features and enhancements faster.</p><p>Early Feedback: Provides an opportunity to test and provide feedback on new features before they are included in LTS.</p><p>Faster Iteration: Enables more rapid development and innovation.</p><p>Comparison of LTS vs. STS</p><p>When to Choose LTS vs. STS</p><p><strong>Choose LTS if</strong>:</p><p>You need stability and predictable performance.</p><p>Your software is used in production environments or critical systems.</p><p>Upgrading frequently is difficult or costly.</p><p><strong>Choose STS if</strong>:</p><p>You want access to the latest features and improvements.</p><p>You are developing new projects or testing features.</p><p>You can handle the risk of frequent updates.</p><p><strong>Real-World Scenario</strong></p><p>Imagine a company building a financial application. They might choose an LTS version of .NET or Node.js for their production environment to ensure long-term stability and security. However, for their development and testing environments, they might opt for the latest STS release to experiment with new features and see if they can integrate them into the next version of their application.</p><p>This approach allows companies to balance innovation and stability based on their needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb16a2889410" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migration from DocumentDB to Cosmos DB]]></title>
            <link>https://medium.com/@rdharmaranga/migration-from-documentdb-to-cosmos-db-63ef06685919?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/63ef06685919</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[cosmos]]></category>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Mon, 11 Nov 2024 15:43:45 GMT</pubDate>
            <atom:updated>2024-11-11T15:44:29.108Z</atom:updated>
            <content:encoded><![CDATA[<p>The migration from <strong>DocumentDB</strong> to <strong>Cosmos DB</strong> involves several key adjustments, particularly with regard to how queries are executed, data is partitioned, and resources are consumed. Here’s a summary of the key concepts and steps for a successful migration:</p><p>1. Partitioning and Partition Key</p><p>-DocumentDB used collections that were either single-partition or multi-partition.<br>-Cosmos DB introduces partitioned containers as a standard approach for scalability. Each container in Cosmos DB is divided into logical partitions, with a partition key being crucial for efficient query routing.<br> Partition Key is a required field when setting up a Cosmos DB container.<br> This key is used to distribute data across multiple physical partitions, allowing Cosmos DB to scale efficiently and handle large datasets.</p><p>Key Change:<br>When querying, you must provide the partition key (‘tenantId’, ‘userId’, etc.) to target a specific partition. Failing to do so can lead to inefficient cross-partition queries, which are more costly in terms of Request Units (RUs) and slower.</p><p>2. FeedOptions and Cross-Partition Queries</p><p>DocumentDB used ‘FeedOptions’ to control aspects of query execution, including enabling cross-partition queries.<br>In Cosmos DB, while ‘EnableCrossPartitionQuery = true’ is still available, it’s considered inefficient. Cross-partition queries are more expensive and slower because they have to scan all partitions.<br> <br>Key Change:<br>Instead of relying on cross-partition queries, it’s recommended to explicitly define the partition key for more efficient and cost-effective queries. You should use ‘RequestOptions’ with `PartitionKey` rather than enabling cross-partition querying.</p><p>3. Query Modifications</p><p>In DocumentDB, queries didn’t necessarily require specifying the partition key, especially if the collection wasn’t partitioned.<br>In Cosmos DB, partitioned queries must specify the partition key to avoid full collection scans.</p><p>Key Change:<br>Queries that did not previously use partition keys need to be updated. For instance, methods querying by ‘id’ should also specify the partition key (e.g., ‘tenantId’), ensuring the query targets a specific partition for improved performance.</p><p>4. Request Options and Partition Key Handling</p><p>DocumentDB did not have explicit partition key handling in queries.<br>In Cosmos DB, queries need to specify the partition key either in ‘RequestOptions’ or directly within query execution options.</p><pre>Key Change:<br>Use ‘RequestOptions’ with the partition key for targeted queries:<br> <br> RequestOptions requestOptions = new RequestOptions<br> {<br> PartitionKey = new PartitionKey(tenantId)<br> };<br> </pre><p>This ensures that the query is routed to the correct partition and reduces the need for costly cross-partition queries.</p><p>5. Performance and Cost Considerations</p><p>DocumentDB pricing was based on throughput, and queries on partitioned collections could become expensive if not handled efficiently.<br>Cosmos DB uses Request Units (RUs) as the unit of measure for throughput, with costs tied to both the execution of operations and the use of resources like storage and query execution.</p><p>Key Change:<br>By ensuring that queries are partitioned correctly and do not require cross-partition querying, you optimize both performance (faster queries) and cost (lower RU consumption).</p><p>6. Migration Steps:</p><p>1. Review Existing Queries:<br> Identify queries that can benefit from partitioning (those querying by specific keys like ‘tenantId’ or ‘userId’).<br> Update queries to use partition keys.</p><p>2. Modify Code:<br> Remove ‘FeedOptions’ like EnableCrossPartitionQuery’ and replace them with ‘RequestOptions’ that specify the partition key.<br> Ensure that queries are targeting specific partitions.</p><p>3. Update Client Configuration:<br> Ensure that the Cosmos DB SDK is used in place of DocumentDB SDKs (since they are different in some cases).<br> Make any necessary changes to the way data is structured if it wasn’t partitioned before.</p><p>4. Test for Performance:<br> After migration, verify that queries are more efficient by checking the RU consumption and execution time.</p><p>5. Monitor Cost and Performance:<br> Use Cosmos DB’s monitoring tools to track the cost and performance of your queries, ensuring they are optimized.</p><p>7. Key Considerations:</p><p>Partitioning Strategy: Ensure that the choice of partition key aligns with the most common query patterns to avoid hotspots and unbalanced data distribution.<br>Cross-Partition Queries: Only use them when necessary, as they are less efficient and more costly.<br>Testing: Validate that all queries and data access patterns perform well post-migration.</p><p><strong>Conclusion:</strong></p><p>Migrating from <strong>DocumentDB </strong>to C<strong>osmos DB</strong> requires a shift towards partitioning and efficient use of <strong>partition keys</strong>. By specifying partition keys in queries and leveraging <strong>RequestOptions</strong> instead of relying on cross-partition queries, you can significantly improve query performance and reduce costs in <strong>Cosmos DB</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63ef06685919" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantum AI: Revolutionizing the Future of Artificial Intelligence]]></title>
            <link>https://medium.com/@rdharmaranga/quantum-ai-revolutionizing-the-future-of-artificial-intelligence-56669b8533f9?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/56669b8533f9</guid>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[quantum-physics]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Fri, 08 Nov 2024 13:35:54 GMT</pubDate>
            <atom:updated>2024-11-08T13:38:52.890Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_INahAtF8SIJVbci" /><figcaption>Photo by Steve Johnson on Unsplash</figcaption></figure><p>Introduction</p><p>Quantum Artificial Intelligence (Quantum AI) is an emerging field that merges quantum computing with artificial intelligence (AI). While AI relies on classical computing to process vast amounts of data and learn patterns, quantum computing harnesses the power of quantum mechanics, promising exponential speedups and new capabilities. The fusion of these two disciplines could transform industries, solve intractable problems, and redefine the limits of computation.</p><p>What is Quantum AI?</p><p>Quantum AI is the application of quantum algorithms and principles of quantum mechanics to enhance machine learning models and AI processes. Traditional AI relies on classical computers, which process data using binary states (0s and 1s). Quantum computers, however, use qubits, which can represent both 0 and 1 simultaneously thanks to superposition. This allows quantum systems to perform multiple computations in parallel, potentially offering immense computational power.</p><p>Why Quantum AI?</p><p>Quantum AI is not just about making AI faster; it aims to tackle problems that are currently unsolvable by classical computers due to their complexity. For example:</p><p>Optimization Problems: Quantum AI could revolutionize optimization, which is crucial in fields like logistics, finance, and neural network training. Quantum algorithms like Quantum Approximate Optimization Algorithm (QAOA) can find optimal solutions faster than classical methods.</p><p>Enhanced Machine Learning: Quantum computers could enable more efficient training of AI models, reducing the time required to process massive datasets.</p><p>Quantum Neural Networks: The development of quantum neural networks (QNNs) may lead to models that can learn and generalize better than classical neural networks.</p><p>Key Quantum Algorithms in AI</p><p>Quantum AI utilizes specialized algorithms that exploit the principles of quantum mechanics:</p><p>1. Quantum Support Vector Machine (QSVM): A quantum version of the classical support vector machine, which uses quantum kernels for faster and more accurate classification.</p><p>2. Quantum k-Nearest Neighbors (QkNN): This algorithm can perform faster similarity searches, making it useful for tasks like recommendation systems.</p><p>3. Quantum Principal Component Analysis (QPCA): Used for dimensionality reduction, QPCA can handle large datasets more efficiently than classical PCA.</p><p>Current Applications of Quantum AI</p><p>1. Drug Discovery and Healthcare:</p><p>Quantum AI can help simulate complex molecular structures and accelerate the discovery of new drugs.</p><p>Companies like IBM and Google are partnering with pharmaceutical firms to explore quantum-enhanced machine learning models for drug research.</p><p>2. Financial Services:</p><p>Quantum AI can optimize trading strategies, enhance risk analysis, and improve fraud detection. Financial institutions are investing heavily in quantum computing research to gain a competitive edge.</p><p>Quantum machine learning algorithms are being tested for portfolio optimization and efficient credit scoring.</p><p>3. Autonomous Systems and Robotics:</p><p>Quantum AI has the potential to enhance decision-making in autonomous vehicles and robotic systems, allowing for better real-time data processing and navigation.</p><p>Challenges in Quantum AI</p><p>While the potential is vast, Quantum AI faces several critical challenges:</p><p>1. Hardware Limitations:</p><p>Quantum computers are still in their infancy, with limited qubits and high error rates. Current quantum devices (e.g., IBM’s Q System One, Google’s Sycamore) are prone to decoherence, where qubits lose their quantum state due to external noise.</p><p>2. Algorithm Development:</p><p>Creating efficient quantum algorithms for AI is complex. Many existing quantum machine learning algorithms require further refinement and proof of advantage over classical counterparts.</p><p>3. Scalability Issues:</p><p>Scaling quantum computers to handle real-world AI applications remains a significant hurdle. Achieving quantum supremacy (a point where quantum computers outperform classical ones) for practical AI tasks is still an open challenge.</p><p>4. Integration with Classical Systems:</p><p>Integrating quantum computing with existing classical AI systems is non-trivial. Hybrid quantum-classical models are being explored, but seamless interaction between the two remains difficult.</p><p>Research Trends in Quantum AI</p><p>1. Quantum Machine Learning (QML) Frameworks:</p><p>Open-source frameworks like PennyLane, TensorFlow Quantum, and Qiskit Machine Learning are enabling researchers to experiment with quantum AI algorithms more easily.</p><p>These tools allow the integration of quantum algorithms with classical machine learning workflows.</p><p>2. Hybrid Quantum-Classical Models:</p><p>Given the current hardware limitations, hybrid models are a practical approach, where parts of the AI model are processed on classical computers, and quantum computers are used for specific sub-tasks that benefit from quantum speedup.</p><p>3. Quantum Data:</p><p>Research is also focusing on creating and processing quantum data, which is inherently different from classical data. Quantum data, such as data from quantum sensors, may provide unique insights that classical AI cannot process efficiently.</p><p>The Future of Quantum AI</p><p>The future of Quantum AI is promising but will likely evolve in phases:</p><p>Near-term (1-5 years): We can expect progress in hybrid quantum-classical models and specific quantum algorithms that provide a modest speedup for niche AI tasks.</p><p>Mid-term (5-10 years): As hardware improves, we may see broader applications of Quantum AI, especially in fields requiring complex optimization and simulations.</p><p>Long-term (10+ years): Fully-fledged Quantum AI systems could revolutionize industries, enabling breakthroughs in AI capabilities far beyond current possibilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56669b8533f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Chaos Engineering: Building Resilience Through Failure]]></title>
            <link>https://medium.com/@rdharmaranga/exploring-chaos-engineering-building-resilience-through-failure-1bce13884b8c?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bce13884b8c</guid>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Wed, 06 Nov 2024 12:32:16 GMT</pubDate>
            <atom:updated>2024-11-06T12:33:31.280Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c2tGmcG1k6TL1z_U" /><figcaption>Photo by <a href="https://unsplash.com/@tama66?utm_source=medium&amp;utm_medium=referral">Peter Herrmann</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In a world where digital experiences are an integral part of daily life, users expect applications to be fast, reliable, and seamless. Downtime and bugs can frustrate users and harm brand reputation. This is where <strong>chaos engineering</strong> steps in as a proactive approach to uncover potential failures before they disrupt real users.</p><p><strong>What is Chaos Engineering?</strong></p><p>Chaos engineering is a discipline that intentionally introduces faults or disruptions into a system to test its resilience. Think of it as a controlled experiment where engineers simulate unpredictable events — network outages, server crashes, and high traffic spikes — to see how the system handles these disruptions. The goal is not to cause chaos for its own sake but to learn from controlled failures to build a more robust system.</p><p>A common mantra in chaos engineering is “hope is not a strategy.” This means that instead of hoping everything will work fine, chaos engineering lets teams test and prove their systems’ reliability in the face of failure.</p><p><strong>Why Do We Need Chaos Engineering?</strong></p><p>Modern systems are highly distributed, with countless dependencies across networks, databases, microservices, and third-party APIs. If one part of this complex web fails, it can have cascading effects, potentially causing partial or complete system outages. Traditional testing methods, while essential, don’t always cover these edge cases, especially in production.</p><p>Chaos engineering answers questions like:<br>- What happens if the primary database goes down?<br>- How does our system behave under heavy load?<br>- Will our backup services automatically kick in if a key service fails?</p><p>By actively exploring these scenarios, chaos engineering allows organizations to:<br>1. Discover vulnerabilities in real time.<br>2. Understand their systems’ limits and dependencies.<br>3. Prepare teams for real-world incidents.</p><p><strong>Principles of Chaos Engineering</strong></p><p>Chaos engineering operates on a few core principles to ensure experiments are conducted in a controlled and ethical manner:</p><p>1. <strong>Define a steady state:</strong> Before introducing failures, teams need to understand the system’s normal behavior. This might involve monitoring metrics like response time, CPU load, or error rate.<br> <br>2.<strong> Hypothesize an outcome: </strong>Before running an experiment, predict how the system should behave. For example, if you cut off access to a specific database, maybe a replica should automatically take over without any noticeable impact on users.</p><p>3. <strong>Introduce controlled chaos</strong>: This is where the fun starts. With tools (e.g., Chaos Monkey, Gremlin) and well-defined boundaries, engineers introduce faults and watch the impact. Common disruptions include simulating network delays, shutting down services, or overwhelming the system with requests.</p><p>4.<strong> Observe and learn</strong>: Record how the system responds to each fault. Does the backup system work as expected? Does latency increase but recover quickly? These observations are essential for making improvements.</p><p>5. <strong>Refine and iterate</strong>: After each experiment, take action based on the findings. Adjust configurations, update failover mechanisms, or refine monitoring alerts. Chaos engineering is an ongoing process of learning and improvement.</p><p><strong>Getting Started with Chaos Engineering</strong></p><p>Starting with chaos engineering can be intimidating, especially for organizations that haven’t experimented in production. Here’s a step-by-step approach:</p><p>1.<strong> Start Small</strong>: Begin with minor disruptions in non-critical parts of your system. If your system is split into multiple services, consider testing a less essential service first.</p><p>2. <strong>Use a Staging Environment</strong>: Test in a staging environment that closely mirrors production. This way, you can uncover issues without affecting end users.</p><p>3. <strong>Automate Monitoring and Alerts</strong>: Chaos engineering is only effective when combined with robust monitoring. Set up real-time alerts for key metrics, so you know if something goes wrong and how bad the impact is.</p><p>4. <strong>Document Findings</strong>: Record what you learn from each experiment. These insights are invaluable for building a knowledge base on system behavior and failure points.</p><p>5. <strong>Run Simulations Regularly</strong>: Make chaos engineering a regular part of your testing routine. As you gain confidence, you can test more critical parts of your system, ultimately even in production.</p><p><strong>The Benefits of Chaos Engineering</strong></p><p>When done right, chaos engineering brings several key benefits:</p><p>1. <strong>Higher Resilience</strong>: By identifying weaknesses, teams can improve system reliability, reducing the chances of critical outages.</p><p>2.<strong> Increased Confidence</strong>: Chaos engineering provides a level of confidence that the system will perform well under various adverse conditions.</p><p>3. <strong>Team Preparedness</strong>: Regular chaos experiments prepare engineering teams to respond quickly and effectively during real incidents.</p><p>4. <strong>Better User Experience</strong>: Less downtime and quicker recovery from issues mean users have a smoother experience.</p><p><strong>Challenges of Chaos Engineering</strong></p><p>Implementing chaos engineering isn’t without its challenges:</p><p><strong>Risk of Real Impact</strong>: Even controlled experiments can impact users if they’re not handled carefully. This is why organizations start with non-production environments or isolated systems.</p><p><strong>Cultural Resistance</strong>: Some organizations may be hesitant to “break things” on purpose, especially in production. It requires a shift in mindset to view chaos as a tool for improvement.</p><p><strong>Monitoring Overload</strong>: Chaos engineering demands robust monitoring and alerting. Without it, you may not get the insights needed or, worse, might cause real problems without realizing it.</p><p><strong>Final Thoughts</strong></p><p>Chaos engineering isn’t about courting disaster it’s about mastering it. By understanding how our systems behave under stress and failure, we can build applications that not only survive in the real world but also offer reliable, high-quality experiences to users.</p><p>So, the next time you’re tempted to overlook potential weak points in your architecture, remember: <strong>chaos today can prevent catastrophe tomorrow</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bce13884b8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Are You Pouring Resources into a Sinkhole? Here’s How to Spot and Avoid It.]]></title>
            <link>https://medium.com/@rdharmaranga/are-you-pouring-resources-into-a-sinkhole-heres-how-to-spot-and-avoid-it-b13c252e382a?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/b13c252e382a</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[antipattern]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[layered-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Mon, 28 Oct 2024 05:54:29 GMT</pubDate>
            <atom:updated>2024-10-28T05:54:29.545Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JE0ji_UUZ1ZDxL-g" /><figcaption>Photo by <a href="https://unsplash.com/@curology?utm_source=medium&amp;utm_medium=referral">Curology</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Introduction</strong></p><p>If you’ve been in software development long enough, you’ve likely encountered projects that seem to demand endless hours of work but don’t visibly move forward. Progress is minimal, new features feel non-existent, and your team keeps “digging” without an end in sight. Welcome to the <strong>Sinkhole Anti-pattern</strong>.</p><p>The Sinkhole Anti-pattern is when a project or feature continually absorbs development time, resources, and attention without yielding measurable progress or value. Let’s dive into what causes this pattern, how to recognize it, and — most importantly — how to avoid getting sucked into its depths.</p><p><strong>Understanding the Sinkhole Anti-pattern</strong></p><p>The term “sinkhole” is apt because, like a real-world sinkhole, the anti-pattern represents an unanticipated drain on resources. Instead of productive development that leads to a tangible outcome, the sinkhole scenario is a constant churn of work that doesn’t translate to meaningful progress.</p><p>Sinkholes can occur for several reasons:</p><ol><li><strong>Vague Requirements</strong>: When project goals or feature requirements are poorly defined, teams spend excessive time on guesswork.</li><li><strong>Technical Debt</strong>: A large amount of unaddressed technical debt can transform any feature or bug fix into a time-consuming endeavor.</li><li><strong>Over-engineering</strong>: This happens when teams spend too much time on design or optimization, aiming for a “perfect” solution that ends up becoming a costly detour.</li><li><strong>Continuous Rework</strong>: Sometimes, frequent changes to requirements lead to continual reworking of features, which results in slow and frustrating progress.</li></ol><p><strong>Signs You’re Stuck in a Sinkhole</strong></p><p>So, how do you know if you’re in a sinkhole situation? Here are some common red flags:</p><ul><li><strong>Endless Debugging</strong>: Are you repeatedly fixing issues that just don’t seem to go away? This cycle of never-ending fixes could be a sign that the foundational code needs a significant overhaul.</li><li><strong>Low ROI on Development Time</strong>: If you’re spending hours on features that don’t seem to add any new functionality, it might be time to step back and evaluate.</li><li><strong>High Developer Frustration</strong>: A strong indicator of a sinkhole is when morale drops because the team feels like their work isn’t leading to anything productive.</li><li><strong>Repeating the Same Tasks</strong>: When you find yourself addressing the same issues over and over or fixing the same bugs repeatedly, there’s likely a sinkhole at play.</li></ul><p><strong>How to Avoid or Escape the Sinkhole Trap</strong></p><p>Avoiding a sinkhole requires careful project management, open communication, and regular assessments. Here are some strategies that can help:</p><ul><li>Clarify Requirements Early</li></ul><p>Ambiguity is a major contributor to sinkhole situations. Spend time with stakeholders at the outset to clearly understand project goals and feature requirements. Revisit and refine these as the project progresses.</p><ul><li>Regularly Assess Technical Debt</li></ul><p>If technical debt is hindering progress, address it proactively. Allocate time specifically for technical debt cleanup to prevent the accumulation of issues that can turn into a sinkhole down the road.</p><ul><li>Limit Scope and Focus on MVP</li></ul><p>Encourage the development of a Minimum Viable Product (MVP) before committing to further feature expansion. By focusing on the essentials, you avoid the trap of over-engineering and can iterate on real-world feedback.</p><ul><li>Set Clear Deadlines</li></ul><p>The sense of urgency that comes with deadlines can prevent a sinkhole from forming. Deadlines push teams to make decisions and can prevent endless tweaking and optimization.</p><ul><li>Encourage Open Communication</li></ul><p>Sometimes, developers feel hesitant to voice concerns about a project going astray. Foster a culture where team members can openly discuss setbacks or suggest pivoting strategies when they sense a sinkhole forming.</p><p><strong>Real-World Example: A Cautionary Tale</strong></p><p>Consider a project I once worked on, where we were tasked with refactoring a legacy system to improve performance. Requirements were vaguely defined, and as a team, we found ourselves repeatedly revisiting the same modules without achieving measurable gains. Every sprint, we would identify “must-fix” bugs and dependencies that kept derailing us, sinking further into unproductive cycles.</p><p>After a few months, we realized we were in a classic sinkhole situation. Refocusing our goals, breaking down features, and clarifying our requirements finally allowed us to make incremental improvements without getting overwhelmed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b13c252e382a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering C# Extension Methods: An End-to-End Guide]]></title>
            <link>https://medium.com/@rdharmaranga/mastering-c-extension-methods-an-end-to-end-guide-60a82614568f?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/60a82614568f</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[dot-net-developers]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Wed, 18 Sep 2024 07:57:38 GMT</pubDate>
            <atom:updated>2024-09-18T07:59:18.259Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2eL6fRJeDgH5SI29" /><figcaption>Photo by <a href="https://unsplash.com/@timmossholder?utm_source=medium&amp;utm_medium=referral">Tim Mossholder</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>C# is a versatile and powerful programming language widely used for developing a range of applications, from desktop to web to mobile. One of its key features that enhances the language’s flexibility and re-usability is extension methods. Extension methods allow you to add new methods to existing types without modifying the original type’s code, thus enabling you to keep your code clean, organized, and maintainable.</p><p>What Are Extension Methods?</p><p>Extension methods are static methods that you can invoke as if they were instance methods on the extended type. They are a way to “extend” existing types with new methods, providing additional functionality without altering the original type.</p><p>Basic Structure of Extension Methods</p><p>To create an extension method, you need:<br>1. A static class to contain the extension method.<br>2. A static method within that class.<br>3. The first parameter of the method specifies the type being extended, prefixed with the `this` keyword.</p><p>Here is a simple example:</p><pre>public static class StringExtensions<br>{<br> public static int WordCount(this string str)<br> {<br> return str.Split(new char[] { &#39; &#39;, &#39;.&#39;, &#39;?&#39; }, StringSplitOptions.RemoveEmptyEntries).Length;<br> }<br>}</pre><p>In this example:<br><strong>StringExtensions </strong>is the static class containing the extension method.<br><strong>WordCount </strong>is the static method that extends the `string` type.<br>The first parameter <strong>this string str </strong>indicates that this method extends the <strong>string </strong>type.</p><p>Using Extension Methods</p><p>Once defined, you can call the extension method as if it were an instance method of the type it extends:</p><pre>string phrase = &quot;Hello, how are you?&quot;;<br>int wordCount = phrase.WordCount();<br>Console.WriteLine(wordCount); // Output: 4</pre><p>Benefits of Extension Methods</p><p><strong>Encapsulation</strong>: Extension methods allow you to add functionality to existing types without modifying them, preserving encapsulation.<br><strong>Readability</strong>: They provide a more intuitive and readable way to call methods, similar to calling instance methods.<br><strong>Maintainability</strong>: You can keep your core logic clean and extend functionalities in a modular manner.</p><p>Advanced Usage of Extension Methods</p><p>Extension methods are not limited to simple scenarios. They can be applied to complex types and used in various contexts:</p><p>Extending Generic Types</p><p>You can create extension methods for generic types, making them even more versatile.</p><pre>public static class EnumerableExtensions<br>{<br> public static T Second&lt;T&gt;(this IEnumerable&lt;T&gt; source)<br> {<br> return source.Skip(1).FirstOrDefault();<br> }<br>}</pre><p>Usage:</p><pre>var numbers = new List&lt;int&gt; { 1, 2, 3, 4 };<br>int secondNumber = numbers.Second();<br>Console.WriteLine(secondNumber); // Output: 2</pre><p>Fluent Interfaces</p><p>Extension methods can help create fluent interfaces, making the code more readable and expressive.</p><pre>public static class StringBuilderExtensions<br>{<br> public static StringBuilder AppendFormattedLine(this StringBuilder sb, string format, params object[] args)<br> {<br> sb.AppendFormat(format, args);<br> sb.AppendLine();<br> return sb;<br> }<br>}</pre><p>Usage:</p><pre>var sb = new StringBuilder();<br>sb.AppendFormattedLine(&quot;Name: {0}&quot;, &quot;John&quot;)<br> .AppendFormattedLine(&quot;Age: {0}&quot;, 30);<br>Console.WriteLine(sb.ToString());</pre><p>Best Practices for Extension Methods</p><p><strong>Relevance</strong>: Ensure the extension method is relevant to the type it extends.<br><strong>Naming</strong>: Follow standard naming conventions and ensure the method name is intuitive.<br><strong>Performance</strong>: Be mindful of performance impacts, especially with extension methods that operate on large collections.<br><strong>Visibility</strong>: Only expose extension methods that provide meaningful and necessary functionality.</p><p>Limitations and Considerations</p><p>While powerful, extension methods have some limitations:<br>- They cannot access private members of the type they extend.<br>- If an extension method has the same name and signature as an instance method, the instance method takes precedence.<br>- Overuse of extension methods can lead to code that is difficult to understand and maintain.</p><p>Conclusion</p><p>Extension methods in C# provide a powerful mechanism to enhance existing types with new functionalities in a clean, maintainable, and readable manner. By understanding their structure, usage, and best practices, you can effectively leverage extension methods to write more modular and expressive code. Whether extending simple types or creating complex fluent interfaces, extension methods are a valuable tool in any C# developer’s toolkit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60a82614568f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Abstract Classes and Interfaces in Object-Oriented Programming (OOP) with C#]]></title>
            <link>https://medium.com/@rdharmaranga/understanding-abstract-classes-and-interfaces-in-object-oriented-programming-oop-with-c-2cae35a33fe5?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cae35a33fe5</guid>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Sun, 19 May 2024 16:22:02 GMT</pubDate>
            <atom:updated>2024-05-19T16:22:02.555Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wZvejQLQCGvnCtWA" /><figcaption>Photo by <a href="https://unsplash.com/@kikisad?utm_source=medium&amp;utm_medium=referral">Killian Cartignies</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Object-Oriented Programming (OOP) is a programming paradigm that uses objects to represent data and methods. Among the key features of OOP are abstract classes and interfaces, which help in designing flexible and reusable code. This article will guide you through these concepts using C# examples.</p><p><strong>Abstract Classes</strong></p><p>An abstract class in C# is a class that cannot be instantiated directly. It’s meant to serve as a base class for other classes. An abstract class can contain abstract methods (without implementation) and concrete methods (with implementation).</p><p><strong>Key Features of Abstract Classes:</strong><br>1. <strong>Cannot be Instantiated:</strong> Abstract classes are not meant to create objects directly.<br>2. <strong>Abstract Methods:</strong> Must be implemented by derived classes.<br>3. <strong>Concrete Methods: </strong>Can include methods with implementations.<br>4. <strong>Fields and Properties:</strong> Can contain fields and properties.</p><p><strong>Example in C#:</strong></p><pre>using System;<br>abstract class Animal<br>{<br> public abstract void MakeSound(); // Abstract method<br>public void Sleep() // Concrete method<br> {<br> Console.WriteLine(&quot;Sleeping…&quot;);<br> }<br>}<br>class Dog : Animal<br>{<br> public override void MakeSound()<br> {<br> Console.WriteLine(&quot;Bark&quot;);<br> }<br>}<br>class Cat : Animal<br>{<br> public override void MakeSound()<br> {<br> Console.WriteLine(&quot;Meow&quot;);<br> }<br>}<br>class Program<br>{<br> static void Main()<br> {<br> Dog dog = new Dog();<br> dog.MakeSound(); // Output: Bark<br> dog.Sleep(); // Output: Sleeping…<br>Cat cat = new Cat();<br> cat.MakeSound(); // Output: Meow<br> cat.Sleep(); // Output: Sleeping…<br> }<br>}</pre><p>In this example, `<em>Animal</em>` is an abstract class with an abstract method `<em>MakeSound</em>` and a concrete method `<em>Sleep</em>`. `<em>Dog</em>` and `<em>Cat</em>` are derived from `<em>Animal</em>` and provide implementations for `<em>MakeSound</em>`.</p><p><strong>Interfaces</strong></p><p>An interface in C# is a contract that defines a set of methods and properties that a class must implement. Interfaces do not provide any implementation.</p><p><strong>Key Features of Interfaces:</strong><br>1. <strong>Method and Property Declarations:</strong> Only signatures without implementation.<br>2. <strong>Multiple Implementation:</strong> A class can implement multiple interfaces.<br>3. <strong>No Fields:</strong> Interfaces do not contain fields.</p><p><strong>Example in C#:</strong></p><pre>using System;<br>interface IAnimal<br>{<br> void MakeSound();<br> void Sleep();<br>}<br>class Dog : IAnimal<br>{<br> public void MakeSound()<br> {<br> Console.WriteLine(&quot;Bark&quot;);<br> }<br>public void Sleep()<br> {<br> Console.WriteLine(&quot;Sleeping…&quot;);<br> }<br>}<br>class Cat : IAnimal<br>{<br> public void MakeSound()<br> {<br> Console.WriteLine(&quot;Meow&quot;);<br> }<br>public void Sleep()<br> {<br> Console.WriteLine(&quot;Sleeping…&quot;);<br> }<br>}<br>class Program<br>{<br> static void Main()<br> {<br> IAnimal dog = new Dog();<br> dog.MakeSound(); // Output: Bark<br> dog.Sleep(); // Output: Sleeping…<br>IAnimal cat = new Cat();<br> cat.MakeSound(); // Output: Meow<br> cat.Sleep(); // Output: Sleeping…<br> }<br>}</pre><p>In this example, `<em>IAnimal</em>` is an interface with two method declarations: `<em>MakeSound</em>` and `<em>Sleep</em>`. The `<em>Dog</em>` and `<em>Cat</em>` classes implement the `<em>IAnimal</em>` interface, providing concrete implementations for both methods.</p><p><strong>Differences Between Abstract Classes and Interfaces</strong></p><p>While both abstract classes and interfaces are used to define methods that must be implemented by derived classes, they have distinct differences and use cases.</p><p>1. <strong>Purpose:</strong><br> — Abstract Classes: Used when classes share a common base and some shared code.<br> — Interfaces: Used to define a contract that multiple classes should follow.</p><p>2. <strong>Inheritance:</strong><br> — Abstract Classes: A class can inherit from only one abstract class.<br> — Interfaces: A class can implement multiple interfaces.</p><p>3. <strong>Members:</strong><br> — Abstract Classes: Can have fields, constructors, and methods (both abstract and concrete).<br> — Interfaces: Can only have method and property declarations (no implementation).</p><p><strong>Practical Use Cases</strong></p><p><strong>When to Use Abstract Classes:</strong><br>- When you have a base class that should not be instantiated.<br>- When you need to provide some shared code among related classes.<br>- When you need to define common fields or properties.</p><p><strong>When to Use Interfaces:</strong><br>- When you need to ensure a group of classes adhere to a specific contract.<br>- When you want to take advantage of multiple inheritance.<br>- When the classes implementing the interface can belong to different parts of the class hierarchy.</p><p><strong>Conclusion</strong></p><p>Abstract classes and interfaces are essential tools in OOP that help in designing flexible and maintainable software. Abstract classes allow for shared code and a common base, while interfaces enforce a contract that multiple classes can implement. Understanding when and how to use these features in C# can significantly enhance your ability to design robust and scalable applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cae35a33fe5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why do we need `READPAST` and `UPDLOCK in SQL server.]]></title>
            <link>https://medium.com/@rdharmaranga/why-do-we-need-readpast-and-updlock-in-sql-server-6f4c1a2ad3c9?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f4c1a2ad3c9</guid>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[mssql]]></category>
            <category><![CDATA[sql-queries]]></category>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Thu, 02 May 2024 11:12:13 GMT</pubDate>
            <atom:updated>2024-05-02T11:12:13.565Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8VmyyUtbEhyx4IRQ" /><figcaption>Photo by <a href="https://unsplash.com/@abject?utm_source=medium&amp;utm_medium=referral">benjamin lehman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In SQL Server, `READPAST` and `UPDLOCK` are table hint options used to control the behavior of SQL operations, particularly in scenarios involving data concurrency, performance, and consistency. Here’s an explanation of each hint and why they might be needed:</p><p><strong>READPAST</strong><br><em>What It Does:</em> The `READPAST` hint allows a query to skip over locked rows during data retrieval operations. When a query using `READPAST` encounters a locked row, it simply continues to the next row without waiting for the lock to be released.</p><p><strong>When to Use It</strong>: <br> — When you have queries that should not be blocked by other queries holding locks.<br> — In high-traffic environments where delays caused by row locks could degrade performance.<br> — In cases where retrieving incomplete data is acceptable, such as in reporting or dashboarding, where getting fast results is more important than retrieving all rows.<br>Example Scenario: In a messaging system where multiple threads are processing messages, using `READPAST` can allow one thread to skip messages being processed by another thread, reducing the chance of blocking and deadlocks.</p><p><strong>UPDLOCK</strong><br><em>What It Does:</em> The `UPDLOCK` hint acquires an update lock (a more restrictive lock) on rows that are read during the query. This helps ensure that no other operations can modify these rows before the query does, preventing concurrency issues like deadlocks.</p><p><strong>When to Use It: </strong><br> — When you want to prevent other transactions from modifying rows that you’ve read but not yet updated.<br> — To avoid deadlocks in concurrent update operations, ensuring that one query retains control over the rows it intends to update.<br>-Example Scenario: If you have a scenario where multiple threads are updating the same rows in a table, using `UPDLOCK` can reduce the chance of deadlocks or data inconsistencies by locking the rows intended for update early in the transaction.</p><p><strong>Why Are These Needed?</strong><br><em>Concurrency:</em> Both `READPAST` and `UPDLOCK` are useful in scenarios with high levels of concurrency. `READPAST` prevents blocking, while `UPDLOCK` prevents deadlocks and ensures consistency.</p><p><em>Performance:</em> By controlling lock behaviors, these hints can improve performance, allowing systems to scale efficiently.</p><p><em>Consistency:</em> `UPDLOCK` can ensure consistent data by preventing other operations from altering rows that you plan to update.</p><p><strong>Ultimately</strong>, the use of `READPAST` and `UPDLOCK` depends on your specific use case and your need to balance concurrency, performance, and data consistency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f4c1a2ad3c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Rise of the Modular Monolith: A New Approach to Software Architecture.]]></title>
            <link>https://medium.com/@rdharmaranga/the-rise-of-the-modular-monolith-a-new-approach-to-software-architecture-fbb27f3ffd20?source=rss-87a02a8af800------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbb27f3ffd20</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Ranushka Pasindu]]></dc:creator>
            <pubDate>Tue, 30 Apr 2024 10:57:29 GMT</pubDate>
            <atom:updated>2024-04-30T10:57:29.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QKbv9DtHVt1gQ30x" /><figcaption>Photo by <a href="https://unsplash.com/@sxoxm?utm_source=medium&amp;utm_medium=referral">Sven Mieke</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the world of software architecture, there’s a constant push for innovation and evolution. Microservices architecture has been a dominant force for several years, championed for its scalability and flexibility. However, the journey to microservices can be complex, fraught with distributed systems issues, and not always suitable for every application or organization. This has led to a resurgence of an older concept with a modern twist: the modular monolith. In this article, we’ll explore what the modular monolith is, why it’s gaining traction, and how it can benefit software development teams.</p><h3><strong>What is a Modular Monolith?</strong></h3><p>A modular monolith is a single-deployment application with a clear separation of concerns through modular design. Unlike a traditional monolithic application, where the codebase is tightly coupled and often lacks clear boundaries, a modular monolith emphasizes a well-structured internal architecture with distinct modules. Each module represents a functional component of the application, with well-defined interfaces and minimal dependencies on other modules.</p><p>In a modular monolith, the entire application is deployed as a single unit, but the internal structure allows for flexibility, maintainability, and potential future transitions to microservices.</p><h3>Benefits of the Modular Monolith</h3><h4>Simplicity and Ease of Deployment</h4><p>Since the modular monolith is deployed as a single unit, the deployment process is simpler compared to microservices, which often require orchestration tools like Kubernetes. This simplicity reduces the overhead of managing multiple services, making it easier for teams with limited resources or infrastructure expertise.</p><h4>Improved Maintainability</h4><p>The modular design encourages developers to create well-defined interfaces and encapsulate functionality within specific modules. This approach leads to a cleaner codebase, where changes to one module are less likely to affect others. The result is a more maintainable system that is easier to understand and evolve over time.</p><h4>Enhanced Collaboration</h4><p>Modular monoliths promote team collaboration by allowing developers to focus on specific modules without needing to understand the entire codebase. This approach can improve productivity and reduce the cognitive load on developers, especially in large-scale applications.</p><h4>Gradual Transition to Microservices</h4><p>One of the key advantages of the modular monolith is its potential to serve as a stepping stone to microservices. By designing a monolithic application with clear modular boundaries, organizations can gradually transition to microservices as their needs evolve. This flexibility allows teams to adopt microservices incrementally, reducing the risks associated with large-scale architectural changes.</p><h3>When to Choose a Modular Monolith</h3><p>While the modular monolith offers several benefits, it’s not always the right choice for every project. Here are some scenarios where the modular monolith might be the best fit:</p><p><em>Small to Medium-Sized Projects</em>: For applications with a moderate level of complexity, a modular monolith can offer a good balance between simplicity and maintainability.</p><p><em>Limited Infrastructure Resources</em>: If your team lacks the resources or expertise to manage complex distributed systems, a modular monolith can provide a simpler deployment and maintenance process.</p><p><em>Transitional Architecture</em>: If your organization is considering a move to microservices but wants to take a gradual approach, a modular monolith can serve as an intermediary step.</p><h3>Conclusion</h3><p>The modular monolith represents a fresh perspective on software architecture, offering a middle ground between traditional monolithic applications and complex microservices. By emphasizing modularity, maintainability, and simplicity, the modular monolith allows organizations to build scalable and flexible applications without the overhead of microservices. If you’re considering a new software project or reevaluating your current architecture, the modular monolith is worth exploring. It might be the perfect solution for achieving a scalable architecture while maintaining a manageable deployment process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbb27f3ffd20" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>