<?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 Dishasrivastava on Medium]]></title>
        <description><![CDATA[Stories by Dishasrivastava on Medium]]></description>
        <link>https://medium.com/@dishasrivastava0902?source=rss-cae0934df486------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WXjFSRTwUFqConB4</url>
            <title>Stories by Dishasrivastava on Medium</title>
            <link>https://medium.com/@dishasrivastava0902?source=rss-cae0934df486------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:56:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dishasrivastava0902/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[If objects are completely independent and initialized with entirely different arguments, making…]]></title>
            <link>https://medium.com/@dishasrivastava0902/if-objects-are-completely-independent-and-initialized-with-entirely-different-arguments-making-88c916506141?source=rss-cae0934df486------2</link>
            <guid isPermaLink="false">https://medium.com/p/88c916506141</guid>
            <dc:creator><![CDATA[Dishasrivastava]]></dc:creator>
            <pubDate>Fri, 17 Jan 2025 09:49:48 GMT</pubDate>
            <atom:updated>2025-01-17T09:49:48.108Z</atom:updated>
            <content:encoded><![CDATA[<h3>If objects are completely independent and initialized with entirely different arguments, making separate objects directly is simpler and more efficient. In such cases, why would deep cloning be necessary?</h3><p>Deep cloning is used in specific scenarios where:</p><h3>1. Preserve State and Relationships:</h3><ul><li>Deep cloning is needed when you want to create a new object that starts as an exact replica of an existing object but can evolve independently.</li><li>It ensures that changes to the cloned object do not affect the original, especially for mutable fields or objects.</li></ul><p><strong>Example Use Case:</strong><br>Suppose you have a game where players have a character template (with weapons, abilities, etc.). You might clone this template and customize it for each player while preserving the original template for others.</p><h3>2. Reusability of Data:</h3><ul><li>Deep cloning allows you to copy an existing object’s state instead of initializing and setting up a new object from scratch. This can save development time when the object creation process is complex or involves many dependencies.</li></ul><p><strong>Example Use Case:</strong><br>Consider a configuration system where a base configuration is copied and slightly adjusted for different environments (e.g., staging, production).</p><h3>3. Immutable Base Object:</h3><ul><li>If you have an object that should remain unmodified (acting like a template or prototype), deep cloning allows you to create derived versions without affecting the original.</li></ul><h3>4. Complex Object Graphs:</h3><ul><li>In systems with nested objects (e.g., a tree structure, linked lists, or graphs), deep cloning is necessary when you want the entire structure to be replicated without shared references.</li></ul><p><strong>Example Use Case:</strong><br>A file management system where each user can copy a folder structure. Modifications to the copied folder should not alter the original.</p><h3>5. Performance Considerations:</h3><ul><li>In some cases, cloning an object might be faster than constructing a new one, especially if the object creation involves complex computations or resource-intensive operations.</li></ul><h3>Why Not Just Create Two Objects?</h3><p>While creating two separate objects is simpler:</p><ul><li>It does not help when one object is derived from or influenced by another (e.g., when maintaining relationships between attributes is crucial).</li><li>It requires manually replicating complex data or relationships, which can lead to errors or inconsistencies.</li></ul><h3>Example Difference:</h3><pre>// Creating two independent objects<br>Person person1 = new Person(&quot;John&quot;, new Address(&quot;Dublin&quot;, &quot;Ireland&quot;));<br>Person person2 = new Person(&quot;Jane&quot;, new Address(&quot;Cork&quot;, &quot;Ireland&quot;));</pre><pre>// Using deep cloning<br>Person person3 = new Person(person1);<br>person3.name = &quot;Jane&quot;;<br>person3.address.city = &quot;Cork</pre><p>In the second case, you start with person1&#39;s data and adjust it, preserving shared properties while modifying specific ones.</p><h3>Key Takeaway:</h3><p>Deep cloning is especially beneficial when working with objects that share a similar base state or structure but need to evolve independently. If objects are entirely different, creating separate instances directly is a simpler and more efficient choice.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88c916506141" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How DNS and CDN Work Together]]></title>
            <link>https://medium.com/@dishasrivastava0902/how-dns-and-cdn-work-together-985bbb2eb415?source=rss-cae0934df486------2</link>
            <guid isPermaLink="false">https://medium.com/p/985bbb2eb415</guid>
            <dc:creator><![CDATA[Dishasrivastava]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 22:45:09 GMT</pubDate>
            <atom:updated>2024-06-29T22:45:09.408Z</atom:updated>
            <content:encoded><![CDATA[<p>DNS (Domain Name System) and CDN (Content Delivery Network) are both essential components of modern web infrastructure, and they work together to enhance the performance and reliability of web services. Here’s how they are related and how they interact:</p><h3>DNS (Domain Name System)</h3><ol><li><strong>Function</strong>: DNS translates human-readable domain names (e.g., <a href="http://www.example.com/">www.example.com</a>) into IP addresses (e.g., 192.0.2.1) that computers use to identify each other on the network.</li><li><strong>Process</strong>: When a user enters a URL in their browser, a DNS query is made to find the corresponding IP address. This involves querying DNS servers in a hierarchical manner until the IP address is found.</li><li><strong>Role in Web Traffic</strong>: DNS is the first step in the process of accessing a web resource. Without DNS, users would have to remember IP addresses instead of domain names.</li></ol><h3>CDN (Content Delivery Network)</h3><ol><li><strong>Function</strong>: A CDN is a network of distributed servers that deliver web content to users based on their geographic location. It helps to reduce latency and improve load times by serving content from a server that is closer to the user.</li><li><strong>Content Distribution</strong>: CDNs cache content in multiple locations around the world. When a user requests a resource (such as a webpage, image, or video), the CDN delivers it from the nearest cache location.</li><li><strong>Performance and Reliability</strong>: CDNs enhance the performance and reliability of websites by distributing the load, reducing bandwidth costs, and providing redundancy.</li></ol><h3>How DNS and CDN Work Together</h3><ol><li><strong>DNS Redirection</strong>: CDNs use DNS to direct users to the nearest or most optimal CDN server. When a DNS query is made for a domain using a CDN, the CDN’s DNS infrastructure will resolve the domain to an IP address of the nearest CDN server.</li><li><strong>Geolocation</strong>: The CDN’s DNS servers use geolocation techniques to determine the user’s location and respond with the IP address of the CDN server that can best serve the user based on proximity and server load.</li><li><strong>Load Balancing</strong>: By integrating with DNS, CDNs can perform load balancing, directing traffic to servers that are less busy, ensuring a smooth and fast user experience.</li><li><strong>Failover and Redundancy</strong>: CDNs use DNS to provide failover capabilities. If one CDN server goes down, DNS can redirect traffic to another server, ensuring continuous availability of the content.</li></ol><h3>Example Workflow</h3><ol><li>A user enters www.example.com in their browser.</li><li>The browser initiates a DNS query to resolve the domain name.</li><li>The DNS query is directed to the CDN’s DNS infrastructure.</li><li>The CDN’s DNS server determines the optimal CDN server based on the user’s location.</li><li>The DNS server responds with the IP address of the nearest CDN server.</li><li>The browser connects to the CDN server to fetch the content.</li><li>The CDN server delivers the requested content from its cache or fetches it from the origin server if not cached.</li></ol><p>In summary, DNS and CDN work in tandem to ensure that web content is delivered quickly, efficiently, and reliably to users around the globe. DNS directs users to the appropriate CDN servers, and CDNs optimize content delivery based on various factors, including user location and server load.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=985bbb2eb415" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Return Value of Java HashMap put()]]></title>
            <link>https://medium.com/@dishasrivastava0902/return-value-of-java-hashmap-put-609f14f565a5?source=rss-cae0934df486------2</link>
            <guid isPermaLink="false">https://medium.com/p/609f14f565a5</guid>
            <dc:creator><![CDATA[Dishasrivastava]]></dc:creator>
            <pubDate>Thu, 18 Apr 2024 19:50:27 GMT</pubDate>
            <atom:updated>2024-04-18T19:50:27.646Z</atom:updated>
            <content:encoded><![CDATA[<p>Java HashMap put() method returns the previously stored value for the key if it was already present in the hashmap. Otherwise, it adds the key/value and returns null.</p><pre>private Map&lt;Bookmark, Integer&gt; mDevice = new HashMap&lt;String, Integer&gt;();<br><br>    String abc = &quot;two&quot;<br>    Integer ret = mDevice.put(abc, ONLINE);</pre><ol><li>if abc key already exists with value OFFLINE, ret is equal to OFFLINE.</li><li>if abc key already exists with value ONLINE, ret is equal to ONLINE.</li><li>if abc key did not exist, then ret is equal to null.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=609f14f565a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What can go wrong if I don’t follow equals and hashcode contract ?]]></title>
            <link>https://medium.com/@dishasrivastava0902/what-can-go-wrong-if-i-dont-follow-equals-and-hashcode-contract-9367c84b8a76?source=rss-cae0934df486------2</link>
            <guid isPermaLink="false">https://medium.com/p/9367c84b8a76</guid>
            <dc:creator><![CDATA[Dishasrivastava]]></dc:creator>
            <pubDate>Thu, 18 Apr 2024 17:20:40 GMT</pubDate>
            <atom:updated>2024-04-18T17:20:40.127Z</atom:updated>
            <content:encoded><![CDATA[<h3>What can go wrong if I don’t follow equals and hashcode contract ?</h3><p>If you don’t follow the equals() and hashCode() contract when using objects in a HashMap, you may encounter unexpected behavior, such as duplicate entries. Here’s an example to illustrate the issue:</p><pre>class Person {<br>    private String name;<br>    private int age;</pre><pre>    public Person(String name, int age) {<br>        this.name = name;<br>        this.age = age;<br>    }</pre><pre>    public String getName() {<br>        return name;<br>    }</pre><pre>    public int getAge() {<br>        return age;<br>    }</pre><pre>    // Equals method without overriding hashCode<br>    @Override<br>    public boolean equals(Object obj) {<br>        if (this == obj) {<br>            return true;<br>        }<br>        if (obj == null || getClass() != obj.getClass()) {<br>            return false;<br>        }<br>        Person person = (Person) obj;<br>        return age == person.age &amp;&amp; name.equals(person.name);<br>    }<br>}</pre><p>Now, let’s create two <em>Person</em> objects that are equal according to the overridden equals() method but do not override the hashCode() method:</p><pre>Person person1 = new Person(&quot;Alice&quot;, 25);<br>Person person2 = new Person(&quot;Alice&quot;, 25);</pre><p>If we attempt to add both objects to a HashMap:</p><pre>Map&lt;Person, String&gt; map = new HashMap&lt;&gt;();<br>map.put(person1, &quot;Value 1&quot;);<br>map.put(person2, &quot;Value 2&quot;);</pre><p>According to the equals() method, person1 and person2 are considered equal because their names and ages are the same. However, since we did not override the hashCode() method, the default hashCode() implementation from the Object class is used.</p><p>Due to the default hashCode() implementation, person1 and person2 will have different hash codes, and the HashMap will treat them as distinct keys. As a result, we end up with two entries in the HashMap:</p><pre>{Person@hashcode1: &quot;Value 1&quot;, Person@hashcode2: &quot;Value 2&quot;}</pre><p>In this case, we intended to have only one entry in the HashMap because the objects are equal according to the equals() method. However, due to the mismatch between the equals() and hashCode() implementations, the HashMap treats them as separate keys.</p><p>This situation violates the contract between equals() and hashCode(), as equal objects should have the same hashCode(). It leads to incorrect behavior in HashMap operations, such as retrieval, removal, or replacement of objects, as they may not work as expected when searching for objects based on equality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9367c84b8a76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Scale a System?]]></title>
            <link>https://medium.com/@dishasrivastava0902/how-to-scale-a-system-d1b2af2e8952?source=rss-cae0934df486------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1b2af2e8952</guid>
            <dc:creator><![CDATA[Dishasrivastava]]></dc:creator>
            <pubDate>Thu, 11 Apr 2024 14:35:32 GMT</pubDate>
            <atom:updated>2024-04-11T14:35:32.286Z</atom:updated>
            <content:encoded><![CDATA[<h4>1. Vertical Scaling (Scale up)</h4><p>This means adding more power to your existing machines by upgrading server with more RAM, faster CPUs, or additional storage. It’s a good approach for simpler architectures but has limitations in how far you can go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r9wcQjK27u-OdWxY.png" /></figure><p>Vertical Scaling</p><h4>2. Horizontal Scaling (Scale out)</h4><p>This means adding more machines to your system to spread the workload across multiple servers. It’s often considered the most effective way to scale for large systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TWaJ5QHnwKBOOiar.png" /></figure><p><strong>Example:</strong> Netflix uses horizontal scaling for its streaming service, adding more servers to their clusters to handle the growing number of users and data traffic.</p><h4>3. Load Balancing</h4><p>Load balancing is the process of distributing traffic across multiple servers to ensure no single server becomes overwhelmed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/0*AjcqCgkoqALWXWJU.png" /></figure><p><strong>Example:</strong> Google employs load balancing extensively across its global infrastructure to distribute search queries and traffic evenly across its massive server farms.</p><h4>4. Caching</h4><p>Store frequently accessed data in-memory (like RAM) to reduce the load on the server or database. Implement caching can dramatically improve response times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R9IM0iFsC3yYxkaX.png" /></figure><p><strong>Example:</strong> Reddit uses caching to store frequently accessed content like hot posts and comments so that they can be served quickly without querying the database each time.</p><h4>5. Content Delivery Networks (CDNs)</h4><p>Distribute static assets (images, videos, etc.) closer to users. This can reduce latency and result in faster load times.</p><p><strong>Example:</strong> Cloudflare provides CDN services, speeding up website access for users worldwide by caching content in servers located close to users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_nXe3O1dmLS8HLzj.png" /></figure><p>Credit: <a href="https://www.cloudflare.com/learning/cdn/what-is-a-cdn/">https://www.cloudflare.com/learning/cdn/what-is-a-cdn/</a></p><h4>6. Partitioning</h4><p>Split data or functionality across multiple nodes/servers to distribute workload and avoid bottlenecks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o5bXR808RK-lvJg2.png" /></figure><p><strong>Example:</strong> Amazon DynamoDB uses partitioning to distribute data and traffic for its NoSQL database service across many servers, ensuring fast performance and scalability.</p><h4>7. Asynchronous communication</h4><p>Defer long-running or non-critical tasks to background queues or message brokers. This ensures your main application remains responsive to users.</p><p><strong>Example:</strong> Slack uses asynchronous communication for messaging. When a message is sent, the sender’s interface doesn’t freeze; it continues to be responsive while the message is processed and delivered in the background.</p><h4>8. Microservices Architecture</h4><p>Break down your application into smaller, independent services that can be scaled independently. This improves resilience and allows teams to work on specific components in parallel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gUHVNFVt9_wojfIZ.png" /></figure><p><strong>Example:</strong> Uber has evolved its architecture into microservices to handle different functions like billing, notifications, and ride matching independently, allowing for efficient scaling and rapid development.</p><h4>9. Auto-Scaling</h4><p>Automatically adjust the number of active servers based on the current load. This ensures that the system can handle spikes in traffic without manual intervention</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LLhu1mfmHYlBvyw-.png" /></figure><p><strong>Example:</strong> AWS Auto Scaling monitors applications and automatically adjusts capacity to maintain steady, predictable performance at the lowest possible cost.</p><h4>10. Multi-region Deployment</h4><p>Deploy the application in multiple data centers or cloud regions to reduce latency and improve redundancy.</p><p><strong>Example:</strong> Spotify uses multi-region deployments to ensure their music streaming service remains highly available and responsive to users all over the world, regardless of where they are located.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1b2af2e8952" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>