<?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 Alok Ratnaparkhi on Medium]]></title>
        <description><![CDATA[Stories by Alok Ratnaparkhi on Medium]]></description>
        <link>https://medium.com/@alokratnaparkhi8?source=rss-78778bce738e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zcS9SFZuiYD3UB5hoSxBtA.jpeg</url>
            <title>Stories by Alok Ratnaparkhi on Medium</title>
            <link>https://medium.com/@alokratnaparkhi8?source=rss-78778bce738e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 19:48:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alokratnaparkhi8/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[Understanding Strong, Weak, Soft and Phantom References in Java]]></title>
            <link>https://alokratnaparkhi8.medium.com/understanding-strong-weak-soft-and-phantom-references-in-java-823d50992465?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/823d50992465</guid>
            <category><![CDATA[java-memory-management]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Fri, 30 Jan 2026 10:31:00 GMT</pubDate>
            <atom:updated>2026-01-30T10:43:11.224Z</atom:updated>
            <content:encoded><![CDATA[<p>Java is known for automatic memory management through Garbage Collection (GC). Most developers rely on GC without thinking much about how objects are kept alive in memory. What many don’t realize is that not all object references are equal.</p><p>Java provides four different types of references, each controlling:</p><ul><li>how long an object stays in memory</li><li>when it becomes eligible for garbage collection</li><li>how we can react to its removal</li><li>Understanding these reference types helps you write memory-efficient, leak-free, and scalable applications.</li></ul><h3>1. Strong Reference (The Default Behavior)</h3><h3>What it is</h3><p>A <strong>strong reference</strong> is the normal reference we use every day in Java.</p><p>If an object has <strong>even one strong reference</strong>, the Garbage Collector <strong>will not remove it</strong>. For an Example,</p><pre>String city = new String(&quot;Los Santos&quot;);</pre><p>Here:</p><ul><li>city strongly refers to &quot;Los Santos&quot;</li><li>The object will stay in memory as long as city points to it</li></ul><h3>When does it get collected?</h3><p>Only when <strong>all strong references are removed</strong>.</p><pre>city = null; // now eligible for GC</pre><h3>Key Takeaway</h3><p>Strong references guarantee object availability but can easily cause <strong>memory leaks</strong> if objects are held longer than needed.</p><h3>2. Weak Reference (WeakReference)</h3><h3>What it is</h3><p>A <strong>weak references</strong> are garbage collected as per Garbage collector’s discretion.</p><p>If an object is <strong>only weakly referenced</strong>, it can be collected <strong>as soon as GC runs</strong>, even if memory is sufficient.</p><h3>Why it exists</h3><p>Weak references are useful when:</p><ul><li>you want objects temporarily</li><li>you don’t want memory to grow uncontrollably</li><li>objects should disappear automatically when unused</li></ul><h3>Example</h3><pre>import java.lang.ref.WeakReference;<br><br>Object data = new Object();<br>WeakReference&lt;Object&gt; weakRef = new WeakReference&lt;&gt;(data);<br><br>data = null; // remove strong reference<br><br>System.gc();<br><br>System.out.println(weakRef.get()); // may return null</pre><p>Once the strong reference is gone, GC is free to collect the object.</p><h3>Practical Usage</h3><ul><li>WeakHashMap</li><li>Listeners or callbacks</li><li>Temporary caches</li></ul><h3>Key Takeaway</h3><p>Weak references are <strong>short-lived by design</strong> and are cleared aggressively.</p><h3>3. Soft Reference (SoftReference)</h3><h3>What it is</h3><p>A <strong>soft reference</strong> sits between strong and weak references.</p><p>The Garbage Collector removes softly referenced objects <strong>only when memory is low</strong>.</p><p>Think of it as: <em>“Keep this object if you can, but remove it if memory is needed.”</em></p><h3>Example</h3><pre>import java.lang.ref.SoftReference;<br><br>Object image = new Object();<br>SoftReference&lt;Object&gt; softRef = new SoftReference&lt;&gt;(image);<br><br>image = null;<br><br>// Usually still available unless memory pressure occurs<br>System.out.println(softRef.get());</pre><h3>How it behaves</h3><ul><li>Survives normal GC cycles</li><li>Removed only during memory pressure</li><li>More stable than weak references</li></ul><h3>Practical Usage</h3><ul><li>Image caching</li><li>Large computed data</li><li>Reusable but non-critical objects</li></ul><h3>Key Takeaway</h3><p>Soft references are ideal for <strong>memory-sensitive caches</strong>.</p><h3>4. Phantom Reference (PhantomReference)</h3><h3>What it is</h3><p>A <strong>phantom reference</strong> is the weakest type of reference.</p><p>You <strong>cannot access the object</strong> through it — get() always returns null.</p><p>Its purpose is <strong>not access</strong>, but <strong>notification</strong>.</p><h3>Why it exists</h3><p>Phantom references allow you to:</p><ul><li>know exactly when an object is removed from memory</li><li>perform cleanup <strong>after GC</strong></li><li>replace unreliable finalization logic</li></ul><pre>import java.lang.ref.PhantomReference;<br>import java.lang.ref.ReferenceQueue;<br><br>Object resource = new Object();<br>ReferenceQueue&lt;Object&gt; queue = new ReferenceQueue&lt;&gt;();<br><br>PhantomReference&lt;Object&gt; phantomRef =<br>        new PhantomReference&lt;&gt;(resource, queue);<br><br>resource = null;<br>System.gc();<br><br>// Check if object is queued for cleanup<br>if (queue.poll() != null) {<br>    System.out.println(&quot;Object has been removed from memory&quot;);<br>}</pre><h3>How it works</h3><ul><li>Object becomes unreachable</li><li>GC finalizes it</li><li>Phantom reference is placed in ReferenceQueue</li><li>Cleanup code runs safely</li></ul><h3>Key Takeaway</h3><p>Phantom references are used for <strong>precise post-GC cleanup</strong>, not object access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*YOcHw6eQySHmFODsw_2bHQ.png" /></figure><h3>Final Thoughts</h3><p>Java’s reference types give you <strong>fine-grained control over object lifetime</strong>.</p><ul><li>Strong references provide safety</li><li>Weak references provide flexibility</li><li>Soft references provide balance</li><li>Phantom references provide control</li></ul><p>Used correctly, they help build <strong>high-performance, memory-efficient Java applications</strong> without fighting the Garbage Collector.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=823d50992465" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 100 Java Stream Interview Problems for practice]]></title>
            <link>https://alokratnaparkhi8.medium.com/top-100-java-stream-interview-problems-for-practice-ea2278f492b2?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea2278f492b2</guid>
            <category><![CDATA[java-8-feature]]></category>
            <category><![CDATA[java-stream-api]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[javastreams]]></category>
            <category><![CDATA[java8]]></category>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Fri, 05 Dec 2025 08:09:08 GMT</pubDate>
            <atom:updated>2026-03-10T06:06:11.326Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve been following along, you might remember my previous blog where we explored <strong>Top 10 Java Stream Interview Problems (With Bonus Questions)</strong>— the kind of questions every developer should be ready for. If you missed it or want a quick look, feel free to check it out first.</p><p><a href="https://alokratnaparkhi8.medium.com/top-10-java-stream-interview-problems-with-bonus-questions-460ef05a61d4">Top 10 Java Stream Interview Problems (With Bonus Questions)</a></p><p>Over the years — through giving countless interviews and reviewing shared candidate experiences across the internet — I’ve collected a goldmine of Java Streams questions that companies are actually asking. This list is not random. It’s <strong>curated from real interview experiences</strong>, coding rounds, and discussions from developers who successfully made it through the process.</p><p>If you want to feel confident when an interviewer suddenly says: <em>“Let’s do this using streams only…”</em>…then you’re exactly where you should be 😎</p><p>Welcome to <strong>Top 100 Java Streams Interview Questions. </strong>Let’s crack them together and stay ahead of the game. 🔥</p><h3>⭐ Basics:</h3><ol><li>Calculate the sum of elements in a list.</li><li>Calculate the average of a list without using average().</li><li>Find the minimum and maximum values from a list.</li><li>Find the second highest and second lowest number in a list.</li><li>Remove duplicates from a list using streams.</li><li>Count number of elements in a list using streams.</li><li>Convert a list of strings to uppercase/lowercase.</li><li>Find the length of the longest string in a list.</li><li>Concatenate a list of strings into a single comma-separated string.</li><li>Filter out null values from a list.</li><li>Filter even or odd numbers from a list.</li><li>Find the square of each number in a list.</li><li>Sort a list in ascending order.</li><li>Sort a list in descending order.</li><li>Count occurrences of a specific element in a list.</li></ol><h3>⭐ Numeric Stream &amp; Mapping:</h3><ol><li>Convert Stream&lt;Integer&gt; to IntStream and sum values.</li><li>Convert primitive stream back to boxed list.</li><li>Generate first 10 Fibonacci numbers using Streams.</li><li>Find product of elements using reduce.</li><li>Difference between map() vs mapToInt() — practical example.</li></ol><h3>⭐String Manipulation</h3><ol><li>Count frequency of each character in a string.</li><li>Find duplicate characters in string.</li><li>First non-repeated character in string.</li><li>Reverse each word in a sentence.</li><li>Check if two strings are anagram using streams.</li><li>Count vowels and consonants using streams.</li><li>Remove special characters &amp; spaces using filter.</li></ol><h3>👥 Object List (Employee / Student)</h3><ol><li>Find employee with highest salary.</li><li>Find employee with second highest salary.</li><li>Sort employees by salary then by name.</li><li>Group employees by department.</li><li>Count employees in each department.</li><li>Average salary in each department.</li><li>Partition employees by gender.</li><li>Find oldest employee.</li><li>Find top 3 salaried employees.</li><li>Convert List&lt;Employee&gt; to Map&lt;id, employee&gt;.</li><li>Handle duplicate keys in Collectors.toMap.</li><li>Find employee names starting with “A”.</li><li>Join employee names into single string.</li><li>Filter employees who joined after a given year.</li><li>Find distinct job titles from employee list.</li><li>Find highest-paid employee per department.</li><li>Group employees by salary range (e.g., &gt;50k, &lt;=50k).</li><li>Get list of departments employees belong to (flatten nested field e.g. employee may belong to multiple departments).</li><li>I. Employees sorted by joining date. II. Return list of employees by each department sorted by employee name descending order. (Guage whether Interviewee knows Collectors.collectingAndThen() to sort after GroupBy).</li></ol><h3>⭐Optional + Reductions</h3><ol><li>Safely fetch first element using findFirst().</li><li>Use reduce() to compute factorial.</li><li>Use reduce() to concatenate strings.</li><li>Use reduce() to find longest string.</li></ol><h3>⭐Collectors &amp; Maps</h3><ol><li>Sort map by value using streams.</li><li>Sort map by key using streams.</li><li>Convert Map to Stream and filter entries.</li><li>Convert list to EnumMap based on condition.</li><li>Return frequency map of list of elements.</li><li>Group list into sub-lists by a predicate.</li><li>Convert list into immutable collection using collectors.</li></ol><h3>⭐Flattening &amp; Transformation</h3><ol><li>Flatten list of lists into single list.</li><li>Flatten map values to single list.</li><li>Convert a list of arrays into a list (flatMap).</li><li>Convert list of strings to list of all characters.</li></ol><h3>⭐Date &amp; Time</h3><ol><li>Sort employees by LocalDate field.</li><li>Group employees by year of joining.</li><li>Filter by date range using streams.</li></ol><h3>⭐Statistical Problems</h3><ol><li>Count numbers greater than threshold.</li><li>Find numbers starting &amp; ending with specific digits.</li><li>Find frequency of words in list of sentences.</li><li>Most repeated word.</li><li>Sort words by frequency.</li><li>Remove stop-words from a text list.</li></ol><h3>🧠Advanced Challenging Questions</h3><ol><li>Parallel stream vs sequential example &amp; use case</li><li>Custom collector to compute summary stats</li><li>Why collect() vs toList()</li><li>Implement infinite stream using iterate.</li><li>Distinguish peek() vs map() with example.</li><li>Why sorted() is a stateful intermediate operation?</li><li>Create a stream from Iterable &amp; Iterator.</li><li>Handle checked exceptions inside streams.</li><li>Reuse stream using Supplier&lt;Stream&gt; solution.</li><li>Collectors.toCollection(TreeSet) example.</li><li>Convert list into priority queue.</li><li>Sort and preserve duplicates count.</li><li>Drop first N elements using skip().</li><li>Take first N elements using limit().</li><li>Convert array of primitives to Boxed List.</li><li>Convert String array to CSV using Streams.</li></ol><h3>🛠 Practical Problem Solving</h3><ol><li>Find median of list using streams.</li><li>Find mode (most repeated number) of list using streams.</li><li>Spiral flattening of matrix (using streams for rows).</li><li>Validate list contains only unique elements.</li><li>Partition into even &amp; odd lists.</li><li>Identify palindromes in a list.</li><li>Remove first and last elements using streams only.</li><li>Combine two lists and remove duplicates.</li><li>Group by list length.</li><li>Distinct words sorted by length.</li><li>Find sum of digit values of each number in list.</li><li>Convert List&lt;String&gt; → Map&lt;String, Integer(length)&gt;.</li><li>Shuffle list using streams (trick: not directly possible — discuss).</li><li>Stream pipeline debugging with peek</li><li>Given an integer array, sort the array in ascending order and move all zeros (0) in the array at the end of array using streams.</li></ol><p>Of course, there’s <strong>no way this is an exhaustive list</strong> of Java Stream interview questions. If you come across any additional questions in real interviews, please <strong>share them in the comments along with the company name</strong> — this way, this blog can become a single reference point for everyone looking for Stream-related interview questions.</p><p>If you have <strong>GitHub repositories or solutions</strong> for these questions, don’t hesitate to drop the links in the comments as well — many readers will find it extremely useful.</p><p>If you found this blog helpful, please <strong>applaud, comment, and share</strong> it with others who are preparing for their next Java interviews. Your encouragement motivates me to write more insightful blogs like this.</p><p>Thank you so much for reading this far — I truly appreciate your time and support!</p><h3>✨✨ Important closing note:</h3><p>As we embrace an era where AI can generate clean and efficient code in seconds, the role of software engineers is evolving. Technology changes rapidly, and new frameworks appear every few months. In such a world, interview processes should also evolve. Assessments based purely on memorized syntax or obscure language features rarely reflect a candidate’s real engineering ability — they measure how well someone has memorized facts, not how effectively they solve problems.</p><p>I personally discourage asking such syntax-driven, trivia-style questions in interviews because they don’t truly evaluate a candidate’s capability.</p><p>An ideal interview should balance problem-solving skills, practical reasoning, and hands-on technical knowledge. Unfortunately, we don’t yet live in this ideal world. Many interviews still rely heavily on knowledge-based or language-feature questions, especially in the early rounds. And since these questions continue to appear widely, it’s practical to prepare for them while building deeper engineering skills over time. This is coming from experience of giving tons of interviews from the tons of well reputed companies. Many companies will still ask these questions.</p><p>The hope is that as more engineers move into influential positions, they will help shape interview practices that better identify creativity, clarity of thought, and real-world capability. For now, we go with the flow, master what is needed today, and aim to be part of the positive change tomorrow.</p><p>I’d love to know your perspective too — <br>Do you believe syntax-focused interview questions truly reflect a developer’s capability and intelligence?.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea2278f492b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 10 Java Stream Interview Problems (With Bonus Questions)]]></title>
            <link>https://alokratnaparkhi8.medium.com/top-10-java-stream-interview-problems-with-bonus-questions-460ef05a61d4?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/460ef05a61d4</guid>
            <category><![CDATA[java8-streams]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[java-8-stream]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java-stream-api]]></category>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Fri, 05 Dec 2025 06:20:04 GMT</pubDate>
            <atom:updated>2025-12-05T08:14:03.026Z</atom:updated>
            <content:encoded><![CDATA[<p>Java Streams are among the most popular topics in interviews. Below is a curated list of essential Stream API problems that are frequently asked in real technical interviews. These are most basic and commonly expected Java Stream problems in technical interviews. Even if you are not preparing specifically for interviews, working through these examples will help you strengthen your understanding of Stream APIs from a beginner to intermediate level.</p><h3>1. Given a list of integers, find the Second Highest and Second Lowest Number</h3><h3><strong>2. Count Frequency of Each Character in a String</strong></h3><h3>3. Find Duplicate Elements in a List</h3><p>Extract elements that appear more than once, with or without their counts.</p><h3>4. Find the First Non-Repeating Character</h3><p>Hint:- How to preserve insertion order while counting frequencies? (Expectation: LinkedHashMap)</p><h3>5. Sort a List of Objects by Multiple Fields</h3><p>Example: sort employees first by salary, then by name using Comparator.thenComparing. (Expectation: Candidate should know sorted() method and how to use Comparator methods such as thenComparing.)</p><h3>6. Get the Maximum Salaried Employee</h3><h3>7. Convert List&lt;Employee&gt; to Map&lt;id, name&gt;</h3><p>Follow up: How to deal with duplicate keys while converting to map?. Expectation: Check whether candidate knows whether toMap() method throws exception if it encounters any duplicate key while converting to map. Check whether candidate knows about merge function that can be passed to toMap() method.</p><h3>8. Partition Employees by Gender</h3><h3>9. Find the Sum of All Even Numbers</h3><h3>10. Flatten a List of Lists</h3><p>Good to start question with what is flatMap and where it is used followed up by actual syntax of using flatMap.</p><h3>Bonus: Very Frequent Follow-Ups</h3><h3>11. Sort a Map by value</h3><h3>12. Group employees by department and count</h3><h3>13. Find top 3 highest salaries</h3><h3>14. Parallel Stream vs Stream — performance differences</h3><h3>15. Why do IntStream, LongStream, DoubleStream exist?<br> — When to use map() vs mapToInt()?</h3><h3>16. Difference between toList() and Collectors.toList() .</h3><p>If you want to <strong>practice more problems</strong> or explore a <strong>larger collection of Java Stream questions</strong> that have appeared in interviews, check out my next blog:</p><p><a href="https://alokratnaparkhi8.medium.com/top-100-java-stream-interview-problems-for-practice-ea2278f492b2">Top 100 Java Stream Interview Problems for practice</a></p><p>It’s a curated list from real interview experiences and is perfect for taking your Stream skills to the next level.</p><h3>✨✨ Important closing note:</h3><p>As we embrace an era where AI can generate clean and efficient code in seconds, the role of software engineers is evolving. Technology changes rapidly, and new frameworks appear every few months. In such a world, interview processes should also evolve. Assessments based purely on memorized syntax or obscure language features rarely reflect a candidate’s real engineering ability — they measure how well someone has memorized facts, not how effectively they solve problems.</p><p>I personally discourage asking such syntax-driven, trivia-style questions in interviews because they don’t truly evaluate a candidate’s capability.</p><p>An ideal interview should balance problem-solving skills, practical reasoning, and hands-on technical knowledge. Unfortunately, we don’t yet live in this ideal world. Many interviews still rely heavily on knowledge-based or language-feature questions, especially in the early rounds. And since these questions continue to appear widely, it’s practical to prepare for them while building deeper engineering skills over time. This is coming from experience of giving tons of interviews from the tons of well reputed companies. Many companies will still ask these questions.</p><p>The hope is that as more engineers move into influential positions, they will help shape interview practices that better identify creativity, clarity of thought, and real-world capability. For now, we go with the flow, master what is needed today, and aim to be part of the positive change tomorrow.</p><p>I’d love to know your perspective too — <br>Do you believe syntax-focused interview questions truly reflect a developer’s capability and intelligence?.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=460ef05a61d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Component Life Cycle hooks in simple language]]></title>
            <link>https://alokratnaparkhi8.medium.com/angular-component-life-cycle-hooks-in-simple-language-19edfd468a61?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/19edfd468a61</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[full-stack-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[full-stack-developer]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 14:32:03 GMT</pubDate>
            <atom:updated>2024-07-23T14:32:03.123Z</atom:updated>
            <content:encoded><![CDATA[<p>I remember when I started learning Angular many years ago, I found component lifecycle hooks concept very confusing. Thanks to the writing style of the official Angular documentation. This is the reason why Angular is infamous for having a steep learning curve compared to its Opp, React. (If you do not know what Opp is, then you might be too old. Maybe drink some water and get some good sleep, haha). Let’s begin the article by discussing the different lifecycle hooks of the component in very simple words. Simple words mean in words that people who know the meaning of Opp word would understand them very easily.</p><p>The life of a component starts with instantiation using the Component’s constructor and dependency injection. Once the component is instantiated, it starts the change detection cycle for the component. Then it goes through different phases of the lifecycle for which you can use custom logic to perform any action by hooking into these phases. Below are all the available lifecycle hooks:</p><ol><li><strong>OnChanges</strong> — This lifecycle hook runs whenever there is a change in any input property of a component. So, as it is well understood by definition, this lifecycle hook can run multiple times.</li><li><strong>OnInit</strong> — This runs when the component is initialized. Useful when you want to add some initialization logic or set some properties for the component. This hook runs only once during the component’s lifecycle. Input properties of a component may change multiple times, but the component will be initialized only once.</li><li><strong>ngDoCheck</strong> — Detects any changes that Angular can’t figure out itself. Useful for custom change detection that cannot be detected by the OnChanges hook. As the definition itself suggests, this can also run multiple times as it runs during every change detection cycle.</li></ol><p>Now before discussing the remaining hooks (<strong>ngAfterContentInit</strong>, <strong>ngAfterContentChecked</strong>, <strong>ngAfterViewInit</strong>, <strong>ngAfterViewChecked</strong>), it is necessary to clarify some concepts. These concepts are discussed below:</p><p>A] <strong>Content vs View</strong> Content literally means any content that is projected into the component from outside. It is not part of a component’s original view. View, on the other hand, is the component’s own template/view excluding any external projected content.</p><p>B] <strong>Init vs Checked</strong> Init hooks are run by Angular when any content or view is initialized for the first time when a component is instantiated using a constructor. These are only run once during the first change detection cycle.</p><p>Checked hooks are run by Angular when there is some change in the projected content or view of a component. So, these hooks will run multiple times during the change detection cycle. This is why it is generally not recommended to use checked hooks because these are expensive operations due to the fact that they may run every time there is a change in content or view. This can degrade performance.</p><p>Now that these concepts are clear, let’s jump into the remaining lifecycle hooks.</p><ol><li><strong>ngAfterContentInit</strong> — Runs when the external content is projected into the component. Only runs once after the first ngDoCheck.</li><li><strong>ngAfterContentChecked</strong> — Runs whenever there is a change in the projected content of a component. May run multiple times during the change detection cycle. Runs after ngAfterContentInit and all subsequent ngDoChecks.</li><li><strong>ngAfterViewInit</strong> — Runs after the component view is initialized. Only runs once after the first ngAfterContentChecked.</li><li><strong>ngAfterViewChecked</strong> — Runs whenever there is a change in the component’s view or child views. May run multiple times after ngAfterViewInit and subsequent ngAfterContentChecked.</li><li><strong>ngOnDestroy</strong> — Runs when Angular destroys the component.</li></ol><p>I hope this simple explanation will help you in interviews and you will not get confused during them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19edfd468a61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Correctness of Distributed Algorithms]]></title>
            <link>https://alokratnaparkhi8.medium.com/correctness-of-distributed-algorithms-ce3b71734eb1?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce3b71734eb1</guid>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Mon, 19 Feb 2024 17:06:04 GMT</pubDate>
            <atom:updated>2024-02-19T17:06:04.305Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*VBwQc4q2IxhJcO2tVREZQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*n01t0_mYTYFDMiZZNgIBOw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce3b71734eb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serializable isolation level & 2PL]]></title>
            <link>https://alokratnaparkhi8.medium.com/serializable-isolation-level-2pl-96eea639a4e0?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/96eea639a4e0</guid>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Sun, 04 Feb 2024 02:33:21 GMT</pubDate>
            <atom:updated>2024-02-04T02:33:21.630Z</atom:updated>
            <content:encoded><![CDATA[<p>Serializable isolation level guarantees that even multiple transactions are executed concurrently, they will be executed as if they are executed serially by the database.</p><p>It is the strictest of all isolation levels.</p><h3>How to implement?</h3><ol><li>Literally execute transactions serially. (E.g., executing all transactions using single execution thread)</li></ol><ul><li><strong>pros</strong> : No concurrency problem</li><li><strong>cons</strong>: Low throughput, worst performance</li></ul><ol><li>Using 2PL (two phase locking) — most popular</li><li>Optimistic concurrency control techniques (Serializable snapshot isolation)</li></ol><h3>Two Phase Locking</h3><ol><li>There are two kinds of locks for all transactions</li></ol><ul><li>Shared locks</li><li>Exclusive locks</li></ul><p>2. Locks are acquired at the beginning of transaction and released at the end of transactions. Due to these two phases, it is called as two phase locking (2PL).</p><p>3. Both readers and writers acquire locks. Writers block both readers and writers. Readers block the writers.</p><p>4. If transaction wants to read, it acquire shared lock if there is no other transaction hold exclusive lock on it. Multiple readers can share reader locks. Writer can not acquire exclusive lock on object until readers finishes the read (i.e., as long as there are any shared or exclusive lock on object).</p><p>6. If transaction wants to write to object, it checks whether there are any shared or exclusive on object, if not it acquires it. Other transactions (both readers and writers) should wait until this transaction releases a lock on object.</p><p><strong>pros</strong>:</p><ul><li>Ensure serializability</li><li>protects from concurrency issues like write skey/ phantoms which are not possible by other isolation levels ( Using Predicate locks &amp; Index Range locks)</li><li>Ensure better read performance than executing all transactions serially</li></ul><p><strong>cons:</strong></p><ul><li>still, poor performance but better than first soltion</li><li>low throughput</li><li>too many locks</li><li>Is susceptible to deadlock due to locks</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96eea639a4e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most Common Problems in Database Transactions]]></title>
            <link>https://alokratnaparkhi8.medium.com/most-common-problems-in-database-transactions-4daec030a042?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4daec030a042</guid>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Sat, 20 Jan 2024 22:32:04 GMT</pubDate>
            <atom:updated>2024-01-30T04:59:03.882Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong> Database transactions are a fundamental aspect of ensuring data integrity, consistency, and reliability. However, they come with their own set of challenges that developers must navigate. In this article, we will delve into some of the most common problems encountered in database transactions, including dirty reads, dirty writes, read skew, non-repeatable reads, lost updates, write skew, and phantom reads. Understanding these issues is crucial for designing robust and scalable database systems.</p><p><strong>1. Dirty Read:</strong></p><ul><li><em>Problem:</em> Dirty reads occur when a transaction reads uncommitted changes made by another transaction.</li><li><em>Minimum Isolation Level Guarantee:</em> Read Committed Isolation</li></ul><p><strong>2. Dirty Write:</strong></p><ul><li><em>Problem:</em> Dirty writes happen when one transaction overwrites uncommitted changes made by another transaction.</li><li><em>Minimum Isolation Level Guarantee:</em> Read Committed Isolation</li></ul><p><strong>3. Read Skew and Non-Repeatable Read:</strong></p><ul><li><em>Problem:</em> Non-repeatable read(fuzzy read) occurs when a transaction reads the same row at least twice but the same row’s data is different between the 1st and 2nd read because other transaction update the same row’s data and commit at the same time(concurrently).</li><li>Read skew happens between two different read queries where a transaction reads inconsistent data between the 1st and 2nd read query because other transactions insert, update or delete data and commit between those reads. Finally, an inconsistent result is produced by the inconsistent data.</li><li>In summary, non-repeatable read is specifically about the inconsistency of a single read operation (reading same object twice) when the data is modified by another transaction between consecutive reads. On the other hand, read skew is a broader concept or generalization of NRR that involves inconsistencies in multiple reads (same object rows or different rows) within a transaction, especially when the transaction is making decisions based on those reads.</li><li><em>Minimum Isolation Level Guarantee:</em> Snapshot aka Read Repeatable Isolation</li></ul><p>4. <strong>Lost Updates:</strong></p><ul><li><em>Problem:</em> Lost updates occur when one transaction overwrites changes made by another transaction without taking those changes into account.</li><li><em>Minimum Isolation Level Guarantee:</em> Snapshot aka Read Repeatable Isolation</li></ul><p><strong>5. Write Skew:</strong></p><ul><li><em>Problem:</em> Two transactions read from same objects at the same time, based on the information provided by the reads, they update same or different objects. If it is same object then you can get dirty write or lost update anomaly. But, if objects are different then it may lead to write skew anomaly.</li><li><em>Minimum Isolation Level Guarantee:</em> Serializable isolation</li></ul><p><strong>6. Phantom Reads:</strong></p><ul><li><em>Problem:</em> Phantom reads involve changes to the number of rows returned by a query due to concurrent transactions inserting or deleting data.</li><li><em>Minimum Isolation Level Guarantee:</em> Serializable isolation</li></ul><p><strong>Important notes:</strong></p><p>Difference between <strong>Phantom read</strong> and <strong>non-repeatable read is</strong> that, Non-repeatable read: The A row that user A has queried has a different value the second time. All the rows in the query have the same value before and after, <em>but different rows are being selected</em> (because B has deleted or inserted some).</p><p>Phantom read happens when second transaction insert new row or delete existing row which transaction one has no idea about while executing concurrently. That is why it is called as phantom/ghostly read as new row appears like a ghost. In contrast, non-repeatable read talks about reading same row twice give different result as opposed to new row.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4daec030a042" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Different Types of Database Partitioning]]></title>
            <link>https://alokratnaparkhi8.medium.com/understanding-different-types-of-database-partitioning-e46d4f9fb24b?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e46d4f9fb24b</guid>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Fri, 05 Jan 2024 14:45:40 GMT</pubDate>
            <atom:updated>2024-01-05T14:45:40.632Z</atom:updated>
            <content:encoded><![CDATA[<p>Database partitioning is a crucial technique for managing large datasets efficiently. There are several types of partitioning strategies, each tailored to specific needs:</p><ol><li><strong>Horizontal Partitioning:</strong> Divides a table into multiple smaller tables, each containing a subset of rows. It is particularly useful for managing large datasets by distributing rows based on certain criteria.</li><li><strong>Vertical Partitioning:</strong> Divides a table into smaller tables by columns, grouping related columns together. This approach can improve query performance by minimizing the amount of data read from storage.</li><li><strong>Range Partitioning:</strong> Involves dividing data based on a specified range of values, such as dates or numerical intervals.</li><li><strong>Hash Partitioning: </strong>Utilizes a hash function to distribute data across partitions, ensuring a uniform distribution and minimizing hotspots.</li><li><strong>List Partitioning:</strong> Involves grouping data based on predefined lists of values, facilitating targeted management of specific data sets.</li><li><strong>Round Robin Partitioning:</strong> Distributes data equally among partitions in a circular fashion, preventing data skew by maintaining a balance across partitions.</li><li><strong>Composite Partitioning:</strong> Combines multiple partitioning methods, providing a more flexible and efficient solution by leveraging the strengths of different approaches for various subsets of data.</li><li><strong>Reference Partitioning:</strong> Involves partitioning a table based on a foreign key relationship, where data in the child table is partitioned according to the parent table.</li><li><strong>Key Partitioning:</strong> Divides data based on a specific column or set of columns that act as the partition key. Each unique key value determines the partition to which a row belongs.</li></ol><p>Trade-Offs of Different Database Partitioning Types:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*JLsNJaPidf-aPATGkkJ8RQ.png" /></figure><p>Skew and Hotspot in Database Partitioning:</p><ul><li><strong>Skew: </strong>Imbalance in data distribution among partitions, leading to potential performance disparities.</li><li><strong>Hotspot:</strong> Specific partition becoming a bottleneck due to high activity or concentrated data, negatively impacting overall system efficiency.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e46d4f9fb24b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Aspect Oriented Programming terminologies you should be familiar with]]></title>
            <link>https://alokratnaparkhi8.medium.com/aspect-oriented-programming-terminologies-you-should-be-familiar-with-6e3a473a8c63?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e3a473a8c63</guid>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Tue, 26 Dec 2023 02:33:37 GMT</pubDate>
            <atom:updated>2023-12-31T22:10:43.378Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Aspect Oriented Programming terminologies you should be familiar with</strong></p><ol><li><strong>Aspect:</strong> An aspect is a modular unit that encapsulates cross-cutting concerns in a program. Cross-cutting concerns are functionalities that affect multiple parts of the codebase. Class having cross cutting concerns is denoted with <em>@Aspect</em> notation</li><li><strong>Advice:</strong> Advice is the code that gets executed when a certain point in the program is reached. It represents the behavior associated with a cross-cutting concern. These are the actual actions which are executed on join points based on type of advices. AspectJ supports five types of advice annotations: <em>@Before, @After, @AfterReturning, @After Throwing, @Around</em>.</li><li><strong>Join Point: </strong>A join point can be a point during the execution of a program, such as the execution of a method or the handling of an exception. A call to a method is a join point, and so is a field access. Join points are where advice can be applied.</li><li><strong>Point Cut: </strong>A pointcut is a set of join points. <em>A pointcut is a predicate that matches join points</em>. Advice is associated with a pointcut expression and runs at any join point matched by the pointcut. E.g. <em>@Pointcut(“execution(* transfer(..))”) // the pointcut expression</em></li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11dcb78ecc94e552c322fa575e26d749/href">https://medium.com/media/11dcb78ecc94e552c322fa575e26d749/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e3a473a8c63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[कुछ मेरे लफ्ज़….]]></title>
            <link>https://alokratnaparkhi8.medium.com/%E0%A4%95%E0%A5%81%E0%A4%9B-%E0%A4%AE%E0%A5%87%E0%A4%B0%E0%A5%87-%E0%A4%B2%E0%A4%AB%E0%A5%8D%E0%A5%9B-ac9a9fb82018?source=rss-78778bce738e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac9a9fb82018</guid>
            <dc:creator><![CDATA[Alok Ratnaparkhi]]></dc:creator>
            <pubDate>Sat, 25 Nov 2023 15:09:13 GMT</pubDate>
            <atom:updated>2023-11-25T16:03:38.517Z</atom:updated>
            <content:encoded><![CDATA[<h3>Roads of cobblestone</h3><p>Those roads of cobblestone</p><p>May be I will never walk again…</p><p>Those silent nights and shivering cold</p><p>May be I will never feel again…</p><p>Those crooked eyes and empty souls</p><p>I’ll probably never see again….</p><p>Those lies and hearts of stone</p><p>May be I will never believe again..</p><p>Still, life goes on…just like a bird</p><p>That wants to be free again…</p><p>That wants to live again….</p><p>By Alok Ratnaparkhi</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*ZL7qchisy3EBLjHtCAttsQ.jpeg" /></figure><h3>आठवणींच्या हया बागेत फिरताना….</h3><p>वाटा बदलल्या ह्रितु बदलले</p><p>परंतु आठवणींच्या हया बागेत फिरताना</p><p>मन हे परत हरपले</p><p>ती स्वप्नान्तर ची कोवळी पाहट</p><p>ती गजबजलेली सन्ध्या</p><p>ते कधी लागलेले सुर</p><p>ते कधी गायलेले राग</p><p>आजही भौर्या सारखे फिरते मन</p><p>त्या एके काळच्या वैकुण्ठात….</p><p>— By Alok Ratnaparkhi</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*O411dWsA39Gj3KnbjVILaw.jpeg" /></figure><h3>जो सागर तुझ्यात आहे….</h3><p>शब्द जरी तू मिटवू शकशील पाण्यातल्या लहरी प्रमाणे…</p><p>पण कशे मिटावशील भावना हृदयातल्या..</p><p>जो सागर तुझ्यात आहे</p><p>— By Alok Ratnaparkhi</p><h3>अकेला फ़क़ीर….</h3><p>दुनिया कहे मुझे पागल, कहे मुझे अकेला फ़क़ीर</p><p>वो क्या जाने इस दुनिया को क्यों गाती थी भजन मीरां</p><p>किस रस में झूमे थे कबीर ||</p><p>— By Alok Ratnaparkhi</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*H3rAwW5x_N-jv5IJbtVDHA.jpeg" /></figure><h3>In the end….</h3><p>In the end, the bad thing is, you are all alone in this vast world.. But, the good thing is, you are all alone in this vast world.. — Alok Ratnaparkhi</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*JqH58LibXDLPfN--vXfI1w.jpeg" /></figure><h3>Hey Morning star….</h3><p>Hey morning star,</p><p>I remembered you today. It’s been a long time. I hope you are doing fine. I remembered how my sleepless nights used to welcome you warmly. I also remembered how the breeze of morning cold used to touch my bare skin, to sooth my weathered veins. It used to say to me, one day everything will be fine. I remembered the sprinkle of joy I had everyday in meeting my only friend, the first ray of sunlight. I remembered all those early morning tears, cups of tea and the smell of cinnamon which were the only constants of my life.</p><p>May be we will not meet again, but I want to thank you for the beautiful journey both of us had. I am doing good and I have come so far. I am still going far…but my memories will always find you in solitude, just like a small kids find their mom.</p><p>Take care my friend, Never loose your shine..</p><p>— By Alok Ratnaparkhi</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kCN3dPBC92KS8pgtl4lGaA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac9a9fb82018" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>