<?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 Aedulapuram Manivyas on Medium]]></title>
        <description><![CDATA[Stories by Aedulapuram Manivyas on Medium]]></description>
        <link>https://medium.com/@aedulapuram.manivyas?source=rss-a9c7c71a9d5a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*z3uwvawqds5TzjaSkiljBA@2x.jpeg</url>
            <title>Stories by Aedulapuram Manivyas on Medium</title>
            <link>https://medium.com/@aedulapuram.manivyas?source=rss-a9c7c71a9d5a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:07:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aedulapuram.manivyas/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[Building a Log Versioning System: A Backward Compatibility Challenge]]></title>
            <link>https://medium.com/@aedulapuram.manivyas/building-a-log-versioning-system-a-backward-compatibility-challenge-d42e9c3f2a3f?source=rss-a9c7c71a9d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d42e9c3f2a3f</guid>
            <category><![CDATA[linkedhashmap]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[backward-compatibility]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[hashmap]]></category>
            <dc:creator><![CDATA[Aedulapuram Manivyas]]></dc:creator>
            <pubDate>Sun, 08 Dec 2024 11:52:57 GMT</pubDate>
            <atom:updated>2024-12-08T11:52:57.127Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>An interview problem by a famous FinTech Company: Designing a system to store, modify, and retrieve logs with version control.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*T_HwV9YkYfNaiWgmx_oUrw.png" /><figcaption>Logging System</figcaption></figure><h4><strong>Problem Description</strong></h4><p>The task involves building a <strong>log versioning system</strong> that maintains <strong>backward compatibility</strong>. The system should:</p><ol><li>Allow users to <strong>add logs</strong> and automatically assign a new version.</li><li>Allow users to <strong>read logs</strong> of any desired version.</li><li>Provide functionality to <strong>delete a log from a specific version</strong>, which creates a new version reflecting the change while retaining the previous versions.</li></ol><p>This system mimics version control behaviour and ensures that every modification results in a new version, maintaining a history of logs.</p><h4>Why HashMap vs LinkedHashMap?</h4><p><strong>HashMap</strong>:</p><ul><li>Unordered: Does not maintain any specific order of entries.</li><li>Fast access: Provides <strong>O(1)</strong> average time complexity for get, put, and containsKey operations.</li><li>Use case: Suitable when order preservation is not required.</li></ul><p><strong>LinkedHashMap</strong>:</p><ul><li>Ordered: Maintains the <strong>insertion order</strong> of entries.</li><li>Slightly slower than HashMap due to order maintenance.</li><li>Use case: Essential for scenarios where the order of versions is important, as in this log versioning system. It ensures versions are iterated in the sequence they were created, which simplifies operations and debugging.</li></ul><p>In this problem, <strong>LinkedHashMap</strong> is preferred to preserve the chronological order of log versions, making it easier to trace and access logs.</p><h4>Code Implementation</h4><p><strong>LoggingSystem.class</strong></p><pre><br>import java.util.*;<br><br>public class LoggingSystem {<br>    // Map to store logs with version numbers<br>    private final LinkedHashMap&lt;Integer, List&lt;String&gt;&gt; versionedLogs = new LinkedHashMap&lt;&gt;();<br>    private int currentVersion = 0;<br><br>    // Validates if the requested version exists<br>    private void validateVersion(int version) {<br>        if (!versionedLogs.containsKey(version)) {<br>            throw new IllegalArgumentException(&quot;Version doesn&#39;t exist&quot;);<br>        }<br>    }<br><br>    // Returns logs up to the specified version<br>    public List&lt;String&gt; getLogsUpTo(int version) {<br>        return versionedLogs.getOrDefault(version, new ArrayList&lt;&gt;());<br>    }<br><br>    // Adds a new log, creates a new version<br>    public void addLog(String log) {<br>        currentVersion++;<br>        // Copy logs from the last version and append the new log<br>        List&lt;String&gt; newLog = new ArrayList&lt;&gt;(getLogsUpTo(currentVersion - 1));<br>        newLog.add(log);<br>        versionedLogs.put(currentVersion, newLog);<br>        System.out.println(&quot;New log added with version v&quot; + currentVersion + &quot;: &quot; + versionedLogs.get(currentVersion));<br>    }<br><br>    // Reads logs for the specified version<br>    public String readLog(int version) {<br>        validateVersion(version);<br>        return String.join(&quot; &quot;, versionedLogs.get(version));<br>    }<br><br>    // Deletes the last log of the specified version, creates a new version<br>    public void deleteLog(int version) {<br>        validateVersion(version);<br>        currentVersion++;<br>        // Copy logs of the specified version<br>        List&lt;String&gt; newLog = new ArrayList&lt;&gt;(versionedLogs.get(version));<br>        // Remove the last log, if available<br>        if (!newLog.isEmpty()) {<br>            newLog.remove(newLog.size() - 1);<br>        }<br>        versionedLogs.put(currentVersion, newLog);<br>        System.out.println(&quot;Log at version v&quot; + version + &quot; modified. Created version v&quot; + currentVersion);<br>    }<br>}</pre><p><strong>Main method:</strong></p><pre>// Main method to test the logging system<br>    public static void main(String[] args) {<br>    LoggingSystem loggingSystem = new LoggingSystem();<br><br>    // Adding logs<br>    loggingSystem.addLog(&quot;hello&quot;);               // v1<br>    loggingSystem.addLog(&quot;world&quot;);               // v2<br>    System.out.println(&quot;Read v2: &quot; + loggingSystem.readLog(2));<br><br>    loggingSystem.addLog(&quot;earth&quot;);               // v3<br>    System.out.println(&quot;Read v3: &quot; + loggingSystem.readLog(3));<br><br>    // Deleting a log from version 2<br>    loggingSystem.deleteLog(2);                  // v4<br>    System.out.println(&quot;Read v4: &quot; + loggingSystem.readLog(4));<br><br>    // Adding new technical logs<br>    loggingSystem.addLog(&quot;Design Patterns&quot;);     // v5<br>    System.out.println(&quot;Read v5: &quot; + loggingSystem.readLog(5));<br><br>    loggingSystem.addLog(&quot;Java Concurrency&quot;);    // v6<br>    System.out.println(&quot;Read v6: &quot; + loggingSystem.readLog(6));<br>}</pre><h3>Execution Example</h3><h4>Initial Actions:</h4><p><strong>1.Add Logs</strong>:</p><ul><li>v1 -&gt; [&quot;hello&quot;]</li><li>v2 -&gt; [&quot;hello&quot;, &quot;world&quot;]</li><li>v3 -&gt; [&quot;hello&quot;, &quot;world&quot;, &quot;earth&quot;]</li></ul><p><strong>2. Delete Log at </strong><strong>v2</strong>:</p><ul><li>Removes &quot;world&quot; from v2:</li><li>v4 -&gt; [&quot;hello&quot;]</li></ul><p><strong>3. Add Log (</strong><strong>&quot;Design Patterns&quot;)</strong>:</p><ul><li>Appends to v4:</li><li>v5 -&gt; [&quot;hello&quot;, &quot;Design Patterns&quot;]</li></ul><p><strong>4. Add Log (</strong><strong>&quot;Java Concurrency&quot;)</strong>:</p><ul><li>Appends to v5:</li><li>v6 -&gt; [&quot;hello&quot;, &quot;Design Patterns&quot;, &quot;Java Concurrency&quot;]</li></ul><h4>Output</h4><pre>New log added with version v1: [hello]<br>New log added with version v2: [hello, world]<br>Read v2: hello world<br>New log added with version v3: [hello, world, earth]<br>Read v3: hello world earth<br>Log at version v2 modified. Created version v4<br>Read v4: hello<br>New log added with version v5: [hello, Design Patterns]<br>Read v5: hello Design Patterns<br>New log added with version v6: [hello, Design Patterns, Java Concurrency]<br>Read v6: hello Design Patterns Java Concurrency</pre><h4>Why This Approach Works</h4><ul><li><strong>Backward Compatibility</strong>: All previous versions remain unchanged.</li><li><strong>Version History</strong>: Users can fetch, modify, or delete logs without losing historical data.</li><li><strong>Efficiency</strong>: Using LinkedHashMap ensures order and allows efficient access and updates.</li></ul><h4><strong>You can connect me on</strong></h4><p>— <a href="https://www.linkedin.com/in/manivyas-aedulapuram-33330b19a/">LinkedIn</a></p><p><em>Thank you for reading …</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d42e9c3f2a3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating New Relic Setup in Java Spring Applications: A Dynamic Build Approach]]></title>
            <link>https://medium.com/@aedulapuram.manivyas/automating-new-relic-setup-in-java-spring-applications-a-dynamic-build-approach-836b993e5d1b?source=rss-a9c7c71a9d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/836b993e5d1b</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[new-relic]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[gradle]]></category>
            <dc:creator><![CDATA[Aedulapuram Manivyas]]></dc:creator>
            <pubDate>Fri, 22 Nov 2024 10:47:12 GMT</pubDate>
            <atom:updated>2024-11-22T10:47:12.644Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Dynamic New Relic Setup in Java Spring Applications with Gradle</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3iyP9SeVpXN_ThbaG-_4NQ.png" /></figure><p><strong>Introduction</strong></p><p>Configuring New Relic manually for Java Spring apps can lead to bloated builds and maintenance headaches, especially when different environments have unique requirements. Here’s a streamlined approach to dynamically manage New Relic setup using Gradle, tailored for environment profiles.</p><p><strong>The Problem</strong></p><ul><li>Manual addition of JAR files.</li><li>Unnecessary inclusion in environments where New Relic isn’t needed</li></ul><p><strong>Solution</strong></p><p>Using Gradle, we automate New Relic setup based on the build profile. If the profile matches environments like dev, prd, or qa, the New Relic agent is included dynamically.</p><p><strong>Implementation Steps</strong></p><ol><li><strong>Define Environment Profiles:</strong></li></ol><p>Add this logic to your build.gradle:</p><pre>def profile = project.hasProperty(&#39;profile&#39;) ? project.getProperty(&#39;profile&#39;) : &#39;default&#39;<br>def newrelicProfiles = [&#39;dev&#39;, &#39;prd&#39;, &#39;stg&#39;, &#39;qa&#39;, &#39;sit&#39;]<br>def isNewRelicEnabled = profile in newrelicProfiles</pre><p><strong>2. Automate Setup:</strong></p><p>Create a Gradle task to download and extract the New Relic agent only when needed:</p><pre>task setupNewRelic {<br>    onlyIf { isNewRelicEnabled }<br>    doFirst {<br>        ant.get(src: &#39;https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip&#39;,<br>                dest: file(&#39;newrelic/newrelic-java.zip&#39;))<br>    }<br>    doLast {<br>        copy {<br>            from zipTree(file(&#39;newrelic/newrelic-java.zip&#39;))<br>            into &#39;.&#39;<br>            exclude &#39;newrelic/*.yml&#39;<br>        }<br>        delete &#39;newrelic/newrelic-java.zip&#39;<br>    }<br>}</pre><p><strong>3. Update Build Dependency</strong></p><pre>build {<br>    if (isNewRelicEnabled) {<br>        dependsOn setupNewRelic<br>    }<br>}</pre><p>4. <strong>Run with Profile</strong>:</p><pre>./gradlew build -Pprofile=dev</pre><p><strong>Key Benefits:</strong></p><ul><li><strong>Environment-Specific</strong>: Includes New Relic only when required.</li><li><strong>Cleaner Builds</strong>: Reduces unnecessary files and improves compliance.</li><li><strong>Simplified Maintenance</strong>: Automates what used to be manual.</li></ul><p><strong>Conclusion:</strong></p><p>This approach saves time, minimises errors, and keeps builds lean</p><p><strong>You can connect me on</strong></p><p>— <a href="https://www.linkedin.com/in/manivyas-aedulapuram-33330b19a/">LinkedIn</a></p><p><em>Thank you for reading …</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=836b993e5d1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolving Bean Conflicts in Spring: Using @Qualifier and @Primary Effectively]]></title>
            <link>https://medium.com/@aedulapuram.manivyas/resolving-bean-conflicts-in-spring-using-qualifier-and-primary-effectively-2f21598bd315?source=rss-a9c7c71a9d5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f21598bd315</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[qualifier-annotation]]></category>
            <category><![CDATA[beans]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Aedulapuram Manivyas]]></dc:creator>
            <pubDate>Wed, 20 Nov 2024 06:22:11 GMT</pubDate>
            <atom:updated>2024-11-20T06:22:11.062Z</atom:updated>
            <content:encoded><![CDATA[<p>Handling Multiple Beans of the Same Type Error in Your Application Context</p><figure><img alt="@Primary vs @Qualifier" src="https://cdn-images-1.medium.com/max/1024/1*MwDq6vuN97ggdBKOwui81A.png" /></figure><p>1.<strong>@Primary Annotation</strong></p><ul><li>Designates a single bean as the default choice when multiple beans of the same type exist.</li><li>Applies globally to a bean type. If a bean is marked as @Primary, it will be injected whenever there’s ambiguity (unless explicitly overridden with @Qualifier).</li></ul><p><strong>@PrimaryExample:</strong></p><p>Imagine a notification system where you have multiple notification services (e.g., email and SMS).</p><pre>// Common interface for notification service<br>public interface NotificationService {<br>    void notify(String message);<br>}<br><br>@Component<br>@Primary   // Indicates this bean should be the default when there are multiple beans of the same type<br>public class EmailNotificationService implements NotificationService {<br>    @Override<br>    public void notify(String message) {<br>        System.out.println(&quot;Email notification: &quot; + message);<br>    }<br>}<br><br>@Component<br>public class SmsNotificationService implements NotificationService {<br>    @Override<br>    public void notify(String message) {<br>        System.out.println(&quot;SMS notification: &quot; + message);<br>    }<br>}<br><br>// NotificationManager is a service that uses NotificationService to send notifications<br>@Service<br>public class NotificationManager {<br>    private final NotificationService notificationService;<br><br>    @Autowired<br>    public NotificationManager(NotificationService notificationService) {<br>        this.notificationService = notificationService;<br>    }<br><br>    public void sendNotification(String message) {<br>        notificationService.notify(message);<br>    }<br>}</pre><p><strong>Explanation of the Code Execution:</strong></p><ul><li>There are two beans implementing the `NotificationService` interface: `EmailNotificationService` and `SmsNotificationService`</li><li>The `@Primary` annotation on `EmailNotificationService` designates it as the default bean.</li><li>When Spring initializes the `NotificationManager` bean and sees the dependency on `NotificationService`, it will inject the `EmailNotificationService` bean because of the `@Primary` annotation.</li><li>When the `sendNotification` method is called on `NotificationManager`, it will use the `notify` method of `EmailNotificationService`.</li></ul><p><strong>Expected Output:</strong></p><p>If you call `notificationManager.sendNotification(“Hello, World!”);`the output will be:</p><p><em>Email notification: Hello, World!</em></p><p>2. <strong>@Qualifier Annotation</strong></p><ul><li>Explicitly specifies which bean to inject when there are multiple beans of the same type.</li><li>Applied locally to a specific injection point.</li><li>Best when you need precise control at a specific injection point or if there is no “default” bean.</li></ul><p><strong>@Qualifier Example</strong></p><pre>// Common interface for notification service<br>public interface NotificationService {<br>    void notify(String message);<br>}<br><br>@Component<br>public class EmailNotificationService implements NotificationService {<br>    @Override<br>    public void notify(String message) {<br>        System.out.println(&quot;Email notification: &quot; + message);<br>    }<br>}<br><br>@Component<br>public class SmsNotificationService implements NotificationService {<br>    @Override<br>    public void notify(String message) {<br>        System.out.println(&quot;SMS notification: &quot; + message);<br>    }<br>}<br><br>// NotificationManager is a service that uses NotificationService to send notifications<br>@Service<br>public class NotificationManager {<br>    private final NotificationService notificationService;<br><br>    @Autowired<br>    public NotificationManager(@Qualifier(&quot;smsNotificationService&quot;) NotificationService notificationService) {<br>        this.notificationService = notificationService;<br>    }<br><br>    public void sendNotification(String message) {<br>        notificationService.notify(message);<br>    }<br>}</pre><p><strong>Explanation of the Code Execution:</strong></p><ul><li>There are two beans implementing the `NotificationService` interface: `EmailNotificationService` and `SmsNotificationService`</li><li>Since no `@Primary` annotation is used, Spring would normally throw an error due to ambiguity.</li><li>The `@Qualifier` annotation in `NotificationManager` resolves the ambiguity by explicitly selecting `SmsNotificationService`.</li><li>When Spring initializes the `NotificationManager` bean, it injects `SmsNotificationService` into it.</li><li>When the `sendNotification` method is called, it will use the `notify` method of the `SmsNotificationService`.</li></ul><p><strong>Expected Output:</strong></p><p>If you call `notificationManager.sendNotification(“Hello, World!”);`, the output will be:</p><p><em>SMS notification: Hello, World!</em></p><blockquote><strong>Additionally, Code with Both </strong><strong>@Primary and </strong><strong>@Qualifier Annotations:</strong></blockquote><ul><li>`@Primary` is applied to `EmailNotificationService`, meaning it would be used by default if no explicit bean is specified.</li><li>The `NotificationManager` class is using the `@Qualifier` annotation to explicitly select `SmsNotificationService`.</li><li>Despite `@Primary` being on `EmailNotificationService`, the `@Qualifier(“smsNotificationService”)` forces Spring to inject the `SmsNotificationService` bean.</li><li>Therefore, when the `sendNotification` method is called, it will use the `notify` method of `SmsNotificationService`.</li></ul><p><strong>You can connect me on</strong></p><p>— <a href="https://www.linkedin.com/in/manivyas-aedulapuram-33330b19a/">LinkedIn</a></p><p><em>Thank you for reading …</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f21598bd315" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>