<?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 Harshit Gupta on Medium]]></title>
        <description><![CDATA[Stories by Harshit Gupta on Medium]]></description>
        <link>https://medium.com/@harshitgupta028?source=rss-8a7c4439fa93------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ROSv2ezYO3gpZruzJciBqA.png</url>
            <title>Stories by Harshit Gupta on Medium</title>
            <link>https://medium.com/@harshitgupta028?source=rss-8a7c4439fa93------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:40:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harshitgupta028/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[Interview Questions: Java Spring Boot developer role]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://harshitgupta028.medium.com/interview-questions-java-spring-boot-developer-role-8a7ee7ed4e41?source=rss-8a7c4439fa93------2"><img src="https://cdn-images-1.medium.com/max/1280/1*Nfnv3rgY-jiS1r-dArPPxA.png" width="1280"></a></p><p class="medium-feed-snippet">What Interviewers Really Ask&#x200A;&#x2014;&#x200A;My Personal Experience</p><p class="medium-feed-link"><a href="https://harshitgupta028.medium.com/interview-questions-java-spring-boot-developer-role-8a7ee7ed4e41?source=rss-8a7c4439fa93------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://harshitgupta028.medium.com/interview-questions-java-spring-boot-developer-role-8a7ee7ed4e41?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a7ee7ed4e41</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[job-interview]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[interview-questions]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Sat, 29 Nov 2025 04:47:16 GMT</pubDate>
            <atom:updated>2025-11-29T04:47:16.836Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Part 2: Collection Framework Set interface]]></title>
            <link>https://harshitgupta028.medium.com/part-2-collection-framework-set-interface-705acb193823?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/705acb193823</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[collections-framework]]></category>
            <category><![CDATA[set]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Sun, 11 May 2025 08:16:51 GMT</pubDate>
            <atom:updated>2025-05-11T08:16:51.127Z</atom:updated>
            <content:encoded><![CDATA[<h4>HashSet, LinkedHashSet, TreeSet and EnumSet Classes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KDPl3ljnRAvaGbhDIqMUw.png" /><figcaption>Collection Framework: Set interface</figcaption></figure><p>📢 If you’re new to the collection framework, I recommend checking out this small <a href="https://harshitgupta028.medium.com/java-collection-framework-series-f2ab1808c312">article</a> first to understand the basics of the collection framework before deep diving into it.</p><h4>✅ Set Interface Overview</h4><ul><li>A Set is a <strong>collection that does not allow duplicate elements</strong>.</li><li>Implementations may vary in terms of ordering and performance.</li><li>Part of the java.util package.</li><li>Main implementations:</li><li>HashSet</li><li>LinkedHashSet</li><li>TreeSet</li></ul><h4>Common Methods of Set:</h4><pre>add(E e)<br>addAll(Collection&lt;? extends E&gt; c)<br>remove(Object o)<br>contains(Object o)<br>isEmpty()<br>size()<br>clear()<br>iterator()<br>retainAll(Collection&lt;?&gt; c)<br>removeAll(Collection&lt;?&gt; c)<br>EnumSet.allOf(Class&lt;E&gt; elementType)<br>EnumSet.noneOf(Class&lt;E&gt; elementType)<br>EnumSet.of(E... elements)<br>EnumSet.range(E from, E to)<br>add(), addAll(), remove(), contains(), clear(), etc. (from Set interface)</pre><h4>🔸 1. HashSet Example</h4><ul><li><strong>Unordered</strong></li><li>Backed by a <strong>hash table</strong></li><li>Allows <strong>one null</strong> element</li></ul><pre>import java.util.*;<br><br>public class HashSetExample {<br>    public static void main(String[] args) {<br>        Set&lt;String&gt; set = new HashSet&lt;&gt;();<br><br>        // Add elements<br>        set.add(&quot;Apple&quot;);<br>        set.add(&quot;Banana&quot;);<br>        set.add(&quot;Cherry&quot;);<br>        set.add(&quot;Apple&quot;); // duplicate, will be ignored<br>        set.add(null);    // only one null allowed<br><br>        System.out.println(&quot;Set: &quot; + set);<br>        System.out.println(&quot;Contains Banana? &quot; + set.contains(&quot;Banana&quot;));<br><br>        // Remove element<br>        set.remove(&quot;Banana&quot;);<br><br>        // Size<br>        System.out.println(&quot;Size: &quot; + set.size());<br><br>        // Iterate<br>        for (String fruit : set) {<br>            System.out.println(&quot;Fruit: &quot; + fruit);<br>        }<br><br>        // Clear<br>        set.clear();<br>        System.out.println(&quot;Is empty? &quot; + set.isEmpty());<br>    }<br>}</pre><h4>🔸 2. LinkedHashSet Example</h4><ul><li><strong>An ordered version</strong> of HashSet</li><li>Maintains <strong>insertion order</strong></li></ul><pre>import java.util.*;<br><br>public class LinkedHashSetExample {<br>    public static void main(String[] args) {<br>        Set&lt;String&gt; set = new LinkedHashSet&lt;&gt;();<br><br>        set.add(&quot;Dog&quot;);<br>        set.add(&quot;Cat&quot;);<br>        set.add(&quot;Horse&quot;);<br>        set.add(&quot;Cat&quot;); // duplicate, ignored<br><br>        System.out.println(&quot;LinkedHashSet (insertion order):&quot;);<br>        for (String animal : set) {<br>            System.out.println(animal);<br>        }<br><br>        System.out.println(&quot;Remove Dog: &quot; + set.remove(&quot;Dog&quot;));<br>        System.out.println(&quot;Set after removal: &quot; + set);<br>    }<br>}</pre><h4>🔸 3. TreeSet Example</h4><ul><li><strong>Sorted</strong> in natural order or via a custom Comparator</li><li><strong>No null values</strong> allowed</li><li>Backed by a <strong>Red-Black Tree</strong></li></ul><pre>import java.util.*;<br><br>public class TreeSetExample {<br>    public static void main(String[] args) {<br>        Set&lt;String&gt; set = new TreeSet&lt;&gt;();<br><br>        set.add(&quot;Zebra&quot;);<br>        set.add(&quot;Elephant&quot;);<br>        set.add(&quot;Lion&quot;);<br>        set.add(&quot;Tiger&quot;);<br><br>        System.out.println(&quot;TreeSet (sorted):&quot;);<br>        for (String animal : set) {<br>            System.out.println(animal);<br>        }<br><br>        System.out.println(&quot;Contains Lion? &quot; + set.contains(&quot;Lion&quot;));<br>        System.out.println(&quot;First: &quot; + ((TreeSet&lt;String&gt;)set).first());<br>        System.out.println(&quot;Last: &quot; + ((TreeSet&lt;String&gt;)set).last());<br><br>        // HeadSet and TailSet<br>        System.out.println(&quot;HeadSet before Lion: &quot; + ((TreeSet&lt;String&gt;)set).headSet(&quot;Lion&quot;));<br>        System.out.println(&quot;TailSet from Lion: &quot; + ((TreeSet&lt;String&gt;)set).tailSet(&quot;Lion&quot;));<br>    }<br>}</pre><h4>🔸 4. EnumSet Example</h4><ul><li>EnumSet is a <strong>high-performance</strong> Set implementation for enum types.</li><li>Part of java.util package.</li><li><strong>All elements must be of the same enum type</strong>.</li><li>It’s much more efficient than other Set implementations like HashSet when dealing with enums.</li><li><strong>Backed by a bit-vector</strong>, making it <strong>fast and compact</strong>.</li></ul><pre>import java.util.EnumSet;<br><br>enum Day {<br>    MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY<br>}<br><br>public class EnumSetExample {<br>    public static void main(String[] args) {<br>        // Create a set with all enum values<br>        EnumSet&lt;Day&gt; allDays = EnumSet.allOf(Day.class);<br>        System.out.println(&quot;All Days: &quot; + allDays);<br><br>        // Create an empty set<br>        EnumSet&lt;Day&gt; emptyDays = EnumSet.noneOf(Day.class);<br><br>        // Add individual elements<br>        emptyDays.add(Day.MONDAY);<br>        emptyDays.add(Day.FRIDAY);<br>        System.out.println(&quot;Selected Days: &quot; + emptyDays);<br><br>        // Range<br>        EnumSet&lt;Day&gt; midWeek = EnumSet.range(Day.TUESDAY, Day.THURSDAY);<br>        System.out.println(&quot;Midweek Days: &quot; + midWeek);<br><br>        // Remove<br>        emptyDays.remove(Day.MONDAY);<br>        System.out.println(&quot;After removal: &quot; + emptyDays);<br><br>        // Contains<br>        System.out.println(&quot;Contains FRIDAY? &quot; + emptyDays.contains(Day.FRIDAY));<br>    }<br>}</pre><h4>Comparison of all Classes in the Set interface</h4><pre>| Feature                       | `HashSet`                                      | `LinkedHashSet`              | `TreeSet`                               | `EnumSet`                              |<br>| ----------------------------- | ---------------------------------------------- | ---------------------------- | --------------------------------------- | -------------------------------------- |<br>| **Ordering**                  | No guarantee                                   | Maintains insertion order    | Sorted in natural/custom order          | Natural order of enum constants        |<br>| **Duplicates**                | ❌ Not allowed                                  | ❌ Not allowed                | ❌ Not allowed                           | ❌ Not allowed                          |<br>| **Null Elements**             | ✅ One allowed                                  | ✅ One allowed                | ❌ Not allowed                           | ❌ Not allowed                          |<br>| **Underlying Structure**      | Hash table                                     | Hash table + linked list     | Red-Black Tree (balanced binary tree)   | Bit vector (internal bit masking)      |<br>| **Performance**               | Fast (O(1) for add/remove/contains)            | Slightly slower than HashSet | Slower (O(log n) for add/remove/search) | Extremely fast (bit-level performance) |<br>| **Thread-Safe**               | ❌ No (wrap with `Collections.synchronizedSet`) | ❌ No                         | ❌ No                                    | ❌ No                                   |<br>| **Use Case**                  | When order doesn&#39;t matter, high speed          | Maintain insertion order     | Need sorted elements                    | Efficient operations on enum types     |<br>| **Implements Set?**           | ✅ Yes                                          | ✅ Yes                        | ✅ Yes                                   | ✅ Yes                                  |<br>| **Allows Custom Comparator?** | ❌ No                                           | ❌ No                         | ✅ Yes                                   | ❌ No (order fixed by enum declaration) |</pre><p>Part 1: <a href="https://harshitgupta028.medium.com/part-1-collection-framework-list-interface-f1475e5f3254">Collection Framework List interface — Published</a></p><p>Thank you, I hope you like the series. Do let me know your thoughts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=705acb193823" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JAVA: Collection Framework Series]]></title>
            <link>https://harshitgupta028.medium.com/java-collection-framework-series-f2ab1808c312?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2ab1808c312</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[collections-framework]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[lists]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Sun, 04 May 2025 07:20:57 GMT</pubDate>
            <atom:updated>2025-05-28T05:53:13.367Z</atom:updated>
            <content:encoded><![CDATA[<h3>JAVA: Collection Framework</h3><h4>Use JAVA pre-defined data structures and their features</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jUVtbp-aORx9wger41NxjQ.png" /><figcaption>Java Collections Framework</figcaption></figure><p>The <strong>Java Collection Framework</strong> is a unified architecture for representing and manipulating collections of data. It provides classes and interfaces for storing and processing groups of objects. Introduced in Java 2, the Collection Framework is part of the java.util package and is widely used to handle dynamic data structures efficiently.</p><p>This article is divided into multiple parts. I have attached all links whenever necessary to jump into the specific part you are looking for.</p><p>Let’s get started with a basic understanding of the <strong>Hierarchy of Java Collection Framework. </strong>If you look at the diagram above, there are boxes with round corners and with non-round corners; rounded corner boxes represent the interface, and non-rounded boxes represent the class.</p><p><strong>Collection Interface</strong>:</p><ul><li>The root of the hierarchy represents a group of objects.</li><li>Common methods: add(), remove(), size(), isEmpty(), etc.</li></ul><p><strong>Subinterfaces </strong>(<strong><em>Child of Collection interface</em></strong>):</p><ul><li><strong>List</strong>: Ordered, allows duplicate elements.</li><li>Examples: ArrayList, LinkedList, Vector.</li><li><strong>Set</strong>: No duplicate elements, unordered.</li><li>Examples: HashSet, LinkedHashSet, TreeSet.</li><li><strong>Queue</strong>: Follows FIFO (First-In-First-Out) or other order.</li><li>Examples: PriorityQueue, ArrayDeque.</li><li><strong>Deque</strong>: Double-ended queue, supports insertion/removal from both ends.</li><li>Examples: ArrayDeque, LinkedList.</li></ul><p><strong>Map Interface</strong> (<strong><em>Not a direct child of Collection</em></strong>):</p><ul><li>Represents key-value pairs.</li><li>Examples: HashMap, LinkedHashMap, TreeMap, Hashtable.</li></ul><p>Note: <em>I have not covered the </em><strong><em>Iterator interface</em></strong><em> and its details, as it is very rarely used. I will plan to add that too in future.</em></p><p>Now let’s deep dive into each of the Class which comes under subinterfaces(List, Set, Queue) and the Map interface.</p><p>Part 1: <a href="https://harshitgupta028.medium.com/part-1-collection-framework-list-interface-f1475e5f3254">Collection Framework List interface — Published</a></p><p>Part 2: <a href="https://harshitgupta028.medium.com/part-2-collection-framework-set-interface-705acb193823">Collection Framework Set interface — Published</a></p><p>Part 3: Collection Framework Queue interface — Coming soon</p><p>Part 4: Collection Framework Map interface — Coming soon</p><p>Part 5: Collection Framework Iterator interface — Coming soon</p><p>Thank you, I hope you like the series. Do let me know your thoughts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2ab1808c312" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 1: Collection Framework List interface]]></title>
            <link>https://harshitgupta028.medium.com/part-1-collection-framework-list-interface-f1475e5f3254?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1475e5f3254</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[lists]]></category>
            <category><![CDATA[interfaces]]></category>
            <category><![CDATA[collections-framework]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Sun, 04 May 2025 07:11:41 GMT</pubDate>
            <atom:updated>2025-05-04T07:43:50.465Z</atom:updated>
            <content:encoded><![CDATA[<h4>ArrayList, LinkedList, Stack and Vector Classes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IEYVWkp6dXHiAnpH4_Ebaw.png" /><figcaption>Collection Framework: List interface</figcaption></figure><p>📢 If you’re new to the collection framework, then I would recommend checking out this small <a href="https://harshitgupta028.medium.com/java-collection-framework-series-f2ab1808c312">article</a> first to understand the basics of the collection framework before deep diving into it.</p><h4>📋 List Interface Overview</h4><ul><li>Ordered collection (elements maintain insertion order).</li><li>Allows duplicate elements.</li><li>Allows positional access and element insertion/removal.</li></ul><h4>Common Methods in List Interface:</h4><pre>add(E e)<br>add(int index, E element)<br>remove(Object o)<br>remove(int index)<br>get(int index)<br>set(int index, E element)<br>contains(Object o)<br>indexOf(Object o)<br>lastIndexOf(Object o)<br>isEmpty()<br>size()<br>clear()<br>subList(fromIndex, toIndex)<br>iterator()<br>listIterator()</pre><h4>🗂️ 1. ArrayList Example</h4><ul><li>Backed by a dynamic array.</li><li>Best for fast <strong>random access</strong>, slower at <strong>inserting/removing</strong> in the middle.</li></ul><pre>import java.util.*;<br><br>public class ArrayListExample {<br>    public static void main(String[] args) {<br>        List&lt;String&gt; list = new ArrayList&lt;&gt;();<br><br>        // Add elements<br>        list.add(&quot;Java&quot;);<br>        list.add(&quot;Python&quot;);<br>        list.add(&quot;C++&quot;);<br>        list.add(1, &quot;JavaScript&quot;); // insert at index<br><br>        // Access<br>        System.out.println(&quot;Element at index 2: &quot; + list.get(2));<br><br>        // Modify<br>        list.set(2, &quot;C#&quot;);<br><br>        // Check<br>        System.out.println(&quot;Contains Python? &quot; + list.contains(&quot;Python&quot;));<br>        System.out.println(&quot;Index of JavaScript: &quot; + list.indexOf(&quot;JavaScript&quot;));<br><br>        // Remove<br>        list.remove(&quot;Python&quot;);<br>        list.remove(0);<br><br>        // Iterate<br>        for (String lang : list) {<br>            System.out.println(&quot;Lang: &quot; + lang);<br>        }<br><br>        // Sublist<br>        List&lt;String&gt; subList = list.subList(0, 1);<br>        System.out.println(&quot;Sublist: &quot; + subList);<br><br>        list.clear();<br>        System.out.println(&quot;Is Empty? &quot; + list.isEmpty());<br>    }<br>}</pre><h4>🔗 2. LinkedList Example</h4><ul><li>Doubly linked list.</li><li>Efficient for <strong>frequent insertions/deletions</strong>.</li></ul><pre>import java.util.*;<br><br>public class LinkedListExample {<br>    public static void main(String[] args) {<br>        LinkedList&lt;String&gt; list = new LinkedList&lt;&gt;();<br>        <br>        // Add elements<br>        list.add(&quot;Dog&quot;);<br>        list.add(&quot;Cat&quot;);<br>        list.add(&quot;Parrot&quot;);<br>        list.addFirst(&quot;Elephant&quot;);<br>        list.addLast(&quot;Tiger&quot;);<br>        <br>        // Access<br>        System.out.println(&quot;First: &quot; + list.getFirst());<br>        System.out.println(&quot;Last: &quot; + list.getLast());<br>        <br>        // Remove<br>        list.removeFirst();<br>        list.removeLast();<br>          <br>        // Iterate<br>        for (String animal : list) {<br>            System.out.println(&quot;Animal: &quot; + animal);<br>        }<br>    }<br>}</pre><h4>📋 3. Vector Example</h4><ul><li>Thread-safe (synchronised).</li><li>Legacy, not recommended unless thread safety is required.</li></ul><pre>import java.util.*;<br><br>public class VectorExample {<br>    public static void main(String[] args) {<br>        Vector&lt;Integer&gt; vector = new Vector&lt;&gt;();<br><br>        vector.add(10);<br>        vector.add(20);<br>        vector.add(30);<br>        vector.addElement(40); // legacy method<br><br>        System.out.println(&quot;Element at index 1: &quot; + vector.get(1));<br>        vector.set(2, 25);<br><br>        vector.remove(0);<br>        System.out.println(&quot;Size: &quot; + vector.size());<br><br>        Enumeration&lt;Integer&gt; e = vector.elements();<br>        while (e.hasMoreElements()) {<br>            System.out.println(&quot;Vector Element: &quot; + e.nextElement());<br>        }<br>    }<br>}</pre><h4>📚 4. Stack Example</h4><ul><li>LIFO (Last In First Out) behaviour.</li><li>Extends Vector.</li></ul><pre>import java.util.*;<br><br>public class StackExample {<br>    public static void main(String[] args) {<br>        Stack&lt;String&gt; stack = new Stack&lt;&gt;();<br><br>        stack.push(&quot;First&quot;);<br>        stack.push(&quot;Second&quot;);<br>        stack.push(&quot;Third&quot;);<br><br>        System.out.println(&quot;Top: &quot; + stack.peek()); // check top<br>        System.out.println(&quot;Popped: &quot; + stack.pop()); // remove top<br><br>        while (!stack.isEmpty()) {<br>            System.out.println(&quot;Popped: &quot; + stack.pop());<br>        }<br>    }<br>}</pre><h4>Comparison of all classes in List interface</h4><pre>| Class        | Key Feature             | Thread Safe | Best Use Case                          |<br>| ------------ | ----------------------- | ----------- | -------------------------------------- |<br>| ArrayList    | Fast random access      | ❌           | Frequent reading                       |<br>| LinkedList   | Fast insertion/deletion | ❌           | Frequent insertions in middle or ends  |<br>| Vector       | Synchronized (legacy)   | ✅           | When thread safety is required         |<br>| Stack        | LIFO behavior           | ✅           | Stack-based processing (undo, parsing) |</pre><p>Thank you, I hope you like it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1475e5f3254" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python: List, Set and Dictionary Comprehensions]]></title>
            <link>https://harshitgupta028.medium.com/python-list-set-and-dictionary-comprehensions-2d6f516f77c6?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d6f516f77c6</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[set]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lists]]></category>
            <category><![CDATA[datastrucutre]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Wed, 15 Jan 2025 04:55:00 GMT</pubDate>
            <atom:updated>2025-01-15T05:24:11.622Z</atom:updated>
            <content:encoded><![CDATA[<h4>Tips: No <strong>direct</strong> tuple comprehensions</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d4I8FWKtshbHh79j4c0Zgg.png" /></figure><p>Comprehensions in Python are concise and elegant ways to create new sequences (like lists, dictionaries, sets) by specifying their contents in a single line of code. They are a key feature of Python and are widely used to make code more readable and efficient.</p><h4>Type of Comprehensions in Python</h4><p>1. List Comprehension</p><p>List comprehensions are used to create lists from existing iterables (like lists, tuples, or ranges). The syntax is:</p><pre>[expression for item in iterable if condition]</pre><ul><li>expression: This defines what will be added to the new list.</li><li>item: Each element in the iterable (e.g., a list or range).</li><li>condition (optional): A filter that determines whether the item will be included.</li></ul><p>Examples</p><ul><li>Create a list of squares of numbers from 1 to 10:</li></ul><pre>squares = [x**2 for x in range(1, 11)]<br>print(squares)  # Output: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]</pre><ul><li>Create a list of even numbers from 1 to 20:</li></ul><pre>evens = [x for x in range(1, 21) if x % 2 == 0]<br>print(evens)  # Output: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]</pre><p>2. Dictionary Comprehension</p><p>Dictionary comprehensions allow you to create dictionaries in a concise manner. The syntax is:</p><pre>{key_expression: value_expression for item in iterable if condition}</pre><p>Examples</p><ul><li>Create a dictionary of numbers and their squares:</li></ul><pre>squares_dict = {x: x**2 for x in range(1, 6)}<br>print(squares_dict)  # Output: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}</pre><ul><li>Create a dictionary from a list of tuples:</li></ul><pre>pairs = [(&#39;a&#39;, 1), (&#39;b&#39;, 2), (&#39;c&#39;, 3)]<br>dictionary = {key: value for key, value in pairs}<br>print(dictionary)  # Output: {&#39;a&#39;: 1, &#39;b&#39;: 2, &#39;c&#39;: 3}</pre><p>3. Set Comprehension</p><p>Set comprehensions are used to create sets (unordered collections with unique elements). The syntax is similar to list comprehensions but uses curly braces {}.</p><pre>{expression for item in iterable if condition}</pre><p>Example:</p><ul><li>Create a set of squares of numbers from 1 to 5:</li></ul><pre>squares_set = {x**2 for x in range(1, 6)}<br>print(squares_set)  # Output: {1, 4, 9, 16, 25}</pre><ul><li>Create a set of unique characters in a string:</li></ul><pre>unique_chars = {char for char in &quot;hello world&quot;}<br>print(unique_chars)  # Output: {&#39;h&#39;, &#39;e&#39;, &#39;l&#39;, &#39;o&#39;, &#39; &#39;, &#39;w&#39;, &#39;r&#39;, &#39;d&#39;}</pre><p>4. Generator Comprehension</p><p>Generator comprehensions are similar to list comprehensions but use parentheses () instead of square brackets []. They return a generator object, which is an iterator and generates items on demand, making them memory efficient.</p><pre>(expression for item in iterable if condition)</pre><p>Example:</p><ul><li>Create a generator for squares of numbers:</li></ul><pre>squares_gen = (x**2 for x in range(1, 6))<br>print(squares_gen)  # Output: &lt;generator object ...&gt;<br>print(list(squares_gen))  # Output: [1, 4, 9, 16, 25]</pre><p>4. Nested Comprehension</p><p>Comprehensions can be nested to handle multiple levels of iteration.</p><h4>Example:</h4><ul><li>Create a list of pairs (x, y) for x in [1, 2, 3] and y in [4, 5, 6]:</li></ul><pre>pairs = [(x, y) for x in [1, 2, 3] for y in [4, 5, 6]]<br>print(pairs)  # Output: [(1, 4), (1, 5), (1, 6), (2, 4), (2, 5), (2, 6), (3, 4), (3, 5), (3, 6)]</pre><p>Note: <strong>Tuple comprehensions</strong> don’t exist in Python. However, you might see code that appears to resemble a “tuple comprehension.” This is usually a <strong>generator comprehension</strong> wrapped in a tuple() constructor.</p><p>Example of “Tuple Comprehension” (using a generator):</p><p>Creating a Tuple of Squares:</p><pre># Using a generator expression inside the tuple() function<br>squares = tuple(x**2 for x in range(1, 6))<br>print(squares)  # Output: (1, 4, 9, 16, 25)</pre><p>Thank you, I hope you like it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d6f516f77c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JAVA: POJO, DAO, DTO, JAVA Beans and Spring Beans]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://harshitgupta028.medium.com/java-pojo-dao-dto-java-beans-and-spring-beans-18ee9176ac38?source=rss-8a7c4439fa93------2"><img src="https://cdn-images-1.medium.com/max/1280/1*Zjo2hMMlo3N6D7y30PF6sw.png" width="1280"></a></p><p class="medium-feed-snippet">Understanding the differences between Java terminologies</p><p class="medium-feed-link"><a href="https://harshitgupta028.medium.com/java-pojo-dao-dto-java-beans-and-spring-beans-18ee9176ac38?source=rss-8a7c4439fa93------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://harshitgupta028.medium.com/java-pojo-dao-dto-java-beans-and-spring-beans-18ee9176ac38?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/18ee9176ac38</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Wed, 01 Jan 2025 15:19:10 GMT</pubDate>
            <atom:updated>2025-01-01T15:19:10.779Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Build Lambda Layers using Docker and AWS Linux Image]]></title>
            <link>https://awstip.com/build-lambda-layers-using-docker-and-aws-linux-image-f205b4b937d6?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/f205b4b937d6</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws-lambda-layer]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Tue, 24 Dec 2024 02:30:34 GMT</pubDate>
            <atom:updated>2025-02-17T14:10:19.302Z</atom:updated>
            <content:encoded><![CDATA[<h4>“No Module named xyz” Follow the below steps to create the layer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQgX5DvRLHPLpCl6439jDg.png" /><figcaption>Use docker to build the layers</figcaption></figure><p>I am writing this because I faced plenty of issues while creating the AWS Lambda Layers hopefully, this article will help someone who faced the same problem as me.</p><p>Building Lambda layers on a Windows system can be challenging, as some Python libraries may work seamlessly, while others fail due to platform-dependent issues. Since AWS Lambda runs in a Linux environment, layers built in a Windows environment may not be compatible. To ensure compatibility with the Linux environment, follow these steps:</p><blockquote>Important Note: [<em>17–FEB–2025]</em></blockquote><blockquote>If you need to compile the layers with the Amazon Linux 2023 (which ships with Python 3.XX) you can replace the 3.10 with 3.XX version in the below commands.</blockquote><h4>1. Starting the docker container with AWS Linux 2 image</h4><p>Pull the AWS Linux 2 image and start the docker container.</p><pre>docker pull public.ecr.aws/lambda/python:3.10<br>docker run --name amzn -d -t --rm public.ecr.aws/lambda/python:3.10 /bin/bash</pre><h4>2. Create the ‘<em>requirement.txt’</em> file</h4><p>Create the text file with the name <em>requirement.txt </em>containing the libraries which you want in your layer</p><p>Example requirements.txt:</p><pre>lxml==5.3.0<br>PyJWT==2.9.0<br>cffi==1.17.1<br>requests==2.32.3</pre><h4>3. Copy the ‘requirement.txt’ file into a docker container</h4><p>Go to the directory where you have created the requirements.txt file and run the command</p><pre>docker cp requirements.txt amzn:/root/requirements.txt</pre><p>Login to the docker container</p><pre>docker exec -it amzn bash</pre><p>Note:- If using macOS avoid creating the requirements.txt on your Desktop, if your terminal does not have permission to access the full disk, it is better to create it in the Documents.</p><h4>4. Install the libraries into the Docker container</h4><p>Once inside the container, install your dependencies into a directory that will serve as your Lambda layer:</p><blockquote>Important Note: [17–FEB-2025]</blockquote><blockquote>Amazon Linux 2023 (which ships with Python 3.12) has moved from yum to dnf as the default package manager. So execute the commands with <em>dnf</em> example: <em>dnf install -y zip</em></blockquote><pre>cd ~</pre><pre>yum update -y<br>yum install -y zip<br>python3.10 -m ensurepip<br>python3.10 -m pip install --upgrade pip</pre><pre>python3.10 -m pip install -r requirements.txt -t package/python<br>cd package</pre><p>After installing the dependencies, clean up unnecessary or platform-dependent files to reduce the layer size:</p><blockquote>Important Note: [17-FEB-2025]</blockquote><blockquote>The find command is a system utility, not tied to Python versions. If find is not working in Amazon Linux 2023 (which comes with Python 3.12), it might not be installed by default. You can install it using: <em>dnf install -y findutils</em></blockquote><pre>find . -name &quot;*.pyc&quot; -delete<br>rm -rf urllib3* six* botocore* idna* tomli* jmespath* charset_normalizer*<br>find . -name &quot;*.dist-info&quot; -exec rm -rf {} +<br>find . -type d -name &quot;__pycache__&quot; -exec rm -r {} +</pre><h4>5. Package the dependencies into a zip file</h4><p>Give the layer zip name whatever you want e.g. <em>python-utils-layer</em></p><pre>zip -r9q ../python-utils-layer.zip *</pre><h4>6. Exporting the Layer Package</h4><p>Exit the Docker container</p><pre>exit</pre><p>Copy the resulting package(zip file) back to your machine</p><pre>docker cp amzn:/root/python-utils-layer.zip ./Downloads/</pre><h4>7. Upload the zip file to lambda layers and attach it to the lambda</h4><p>Now follow the on-screen instructions to upload the layer to the AWS lambda attach it to your lambda and start using it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QYr-HWRu5L_4SJJcQlPk5w.png" /><figcaption>create a lambda layer</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lwi653Gp_fLFVh2yE7olpg.png" /><figcaption>Upload a layer zip</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y8IzRVxgVO_vzwCTBdBUmw.png" /><figcaption>Go to layers section</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hpGtnJkqKpZIH5elFcOXg.png" /><figcaption>Add a layer</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2FF5a23Maf-2hF83yUK2jg.png" /><figcaption>Layer attached</figcaption></figure><p>Thank you, I hope you like it :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f205b4b937d6" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/build-lambda-layers-using-docker-and-aws-linux-image-f205b4b937d6">Build Lambda Layers using Docker and AWS Linux Image</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is AWS Lambda Function?]]></title>
            <link>https://awstip.com/what-is-aws-lambda-function-ab7e19304801?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab7e19304801</guid>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[lambda-function]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Sun, 15 Dec 2024 11:28:34 GMT</pubDate>
            <atom:updated>2024-12-19T17:14:49.542Z</atom:updated>
            <content:encoded><![CDATA[<h4>AWS serverless computing service</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzVyFHYI891uOa6Mv-kkHg.png" /></figure><p>Worth reading: <a href="https://harshitgupta028.medium.com/what-is-serverless-architecture-2ff0b3d8115e">serverless architecture</a></p><h4>Intro to Lambda Function</h4><p>AWS Lambda function is a serverless computing service provided by Amazon Web Services (AWS). It lets you run your code without provisioning or managing servers. You simply upload your code, set up triggers and Lambda takes care of executing your code when needed, scaling automatically to handle requests.</p><p>The maximum time lambda can execute is <strong>15 min</strong> which is configurable according to the use case.</p><h4>1. Lambda Trigger and destination</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8e4fknp0ElgB7TmfOK3AGQ.png" /><figcaption>Lambda triger and destination</figcaption></figure><p><strong>Trigger</strong> is a source that invokes or “triggers” the execution of your Lambda function when an event occurs.</p><p>Triggers are set up to define the event source and conditions under which your Lambda function should execute. common AWS services that can be used as triggers: S3, API Gateway, SQS, SNS, DynamoDB etc.</p><p><strong>Destination </strong>is an action/service which will take place once the lambda execution completes</p><h4>2. Lambda function entry-point and example code</h4><p>When working with AWS Lambda, it is crucial to adhere to the structure and conventions set by AWS for Lambda functions. This ensures your code integrates seamlessly with the AWS Lambda runtime environment.</p><p><strong>a). Entry-point</strong></p><p>The Lambda runtime environment expects your code to have a method defined as the entry point, which is typically named lambda_handler. AWS invokes this method when the function is executed.</p><p>Example:</p><pre>def lambda_handler(event, context):<br>    print(&quot;Lambda Invoked&quot;)<br>    # Your function logic here<br>    return {&quot;statusCode&quot;: 200, &quot;body&quot;: &quot;Hello, world!&quot;}</pre><p>event:- Contains information about the triggering event.<br>context:- Provides runtime information about the function’s execution.</p><p>Tips:- To interact with different services in lambda, AWS provided the boto3 client library in Python.</p><p><strong>b). Example code</strong></p><p>Read a file from the S3 input bucket(storage service of AWS), process it in the lambda and save it in the output S3 bucket.</p><pre>import os<br>import boto3<br><br># Initialize the S3 client<br>s3_client = boto3.client(&#39;s3&#39;)<br>def lambda_handler(event, context):<br>    &quot;&quot;&quot;<br>    Lambda function to process an S3 file and save the modified content to another S3 bucket.<br>    &quot;&quot;&quot;<br>    try:<br>        # Get source bucket and object details from the event<br>        source_bucket = event[&quot;Records&quot;][0][&quot;s3&quot;][&quot;bucket&quot;][&quot;name&quot;]<br>        # Source file name<br>        source_key = event[&quot;Records&quot;][0][&quot;s3&quot;][&quot;object&quot;][&quot;key&quot;]<br>        # Get destination bucket from environment variable<br>        destination_bucket = os.environ.get(&quot;DESTINATION_BUCKET&quot;)<br>        # Destination file name<br>        destination_key = f&quot;processed-{source_key}&quot;<br>        # Read the file content from the source bucket<br>        response = s3_client.get_object(Bucket=source_bucket, Key=source_key)<br>        file_content = response[&quot;Body&quot;].read().decode(&quot;utf-8&quot;)<br>        # Process the file content (append a line for this example)<br>        processed_content = file_content + &quot;\nProcessed by Lambda!&quot;<br>        # Save the processed content to the destination bucket<br>        s3_client.put_object(<br>            Bucket=destination_bucket,<br>            Key=destination_key,<br>            Body=processed_content<br>        )<br>        return {<br>            &quot;statusCode&quot;: 200,<br>            &quot;body&quot;: f&quot;File {source_key} processed and saved as {destination_key}.&quot;<br>        }<br>    except Exception as e:<br>        return {<br>            &quot;statusCode&quot;: 500,<br>            &quot;body&quot;: f&quot;Error processing file: {str(e)}&quot;<br>        }</pre><h4>3. Layers</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U6ZvKG3aNr23TqGqxIF9kA.png" /><figcaption>Lambda Layers</figcaption></figure><p><strong>AWS Lambda Layers</strong> are a way to package and share additional code or data that your Lambda functions can use. Layers allow you to manage dependencies, libraries, or common functionality separately from your Lambda function code, promoting modularity and code reuse.</p><p>In most cases, layers are used to add 3rd party libraries which you need in your lambda function code, we need to create layers by uploading the libraries as zip files and attaching them to our lambda function</p><p>How to use it in code? Suppose you created a layer which contains the requests and boto3 Python libraries use it like</p><pre># Importing from the layers<br>import requests<br>import boto3<br><br>def lambda_handler(event, context):<br>    print(&quot;Lambda Invoked&quot;)</pre><h4>4. Monitoring</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sMIypiSwXljLsQ85zxxELQ.png" /><figcaption>Monitor lambda functions</figcaption></figure><p><strong>Monitoring in AWS Lambda functions</strong> involves tracking the performance, usage, and operational health of your Lambda functions to ensure they are working correctly and efficiently. AWS provides several tools and services for monitoring Lambda functions, enabling you to identify issues, optimize performance, and manage resource utilization.</p><p><strong>a). Performance Metrics</strong>:<br>Includes function invocation duration, number of requests, error rates, etc.</p><p><strong>b). Logs</strong>:<br>Log messages generated by your Lambda function help debug errors and understand their execution.</p><p><strong>c). Tracing</strong>:<br>Enables end-to-end tracking of requests across multiple services.</p><h4>5. Configurations</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*psRJ_GgtMDauElmsASbMnw.png" /><figcaption>Configurations of lambda function</figcaption></figure><p><strong>Configurations in AWS Lambda functions</strong> refer to the settings and parameters that define how a Lambda function behaves, runs, and interacts with other AWS resources or services.</p><p>These configurations enable you to control execution environment properties, resource allocations, permissions, and integrations for your Lambda function.</p><p>With the above concepts, you are ready to work with AWS lambda although there are some more advanced concepts and types of lambda(e.g. dockerized lambda) which are nice to have knowledge of</p><p>Thank you, hope you like it :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab7e19304801" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/what-is-aws-lambda-function-ab7e19304801">What is AWS Lambda Function?</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Serverless Architecture?]]></title>
            <link>https://awstip.com/what-is-serverless-architecture-2ff0b3d8115e?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ff0b3d8115e</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Wed, 04 Dec 2024 05:04:29 GMT</pubDate>
            <atom:updated>2025-01-10T18:31:11.013Z</atom:updated>
            <content:encoded><![CDATA[<h4>Serverless: focus on code, not on infrastructure.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AuhSnrN9cnev6pfJyuaI0A.png" /></figure><p>Let me start by saying…</p><p>Despite its name, “serverless” doesn’t mean there are no servers, it means that developers do not have to manage or maintain the servers.</p><p>Serverless architecture is a cloud computing model where developers build and run applications without managing the underlying server infrastructure. In this model, cloud providers dynamically manage the allocation of resources and scale automatically based on the demand. Developers focus on writing code, and the cloud provider takes care of running it.</p><p>These resources are not available 24*7 these are on-demand based which the cloud services provider manages efficiently for your application.</p><p>In this article, I’ve created a simple serverless architecture example(<em>Image processing application</em>) to help you better understand it.</p><p>Let’s learn the serverless architecture more in-depth</p><blockquote>Core components of serverless architecture</blockquote><ol><li>Function as-a-service</li></ol><ul><li>The core of serverless architecture.</li><li>Developers write functions (small pieces of code) that execute in response to events like HTTP requests, file uploads, or database updates.</li><li>These functions are designed in such a way that they can execute for a certain time duration only e.g. AWS Lambda functions (15 min), Azure functions (5 to 60 min)</li><li>Examples: AWS Lambda, Azure Functions, and Google Cloud Functions.</li></ul><p>2. Backend as-a-service</p><ul><li>Provides managed services for common backend tasks like database management, authentication, and file storage.</li><li>Examples: Firebase Authentication, AWS S3, DynamoDB.</li></ul><p>3. Event Driven</p><ul><li>Serverless systems rely on event-driven mechanisms. Events can be user interactions, API calls, scheduled jobs, or system triggers.</li><li>Example: SQS event triggers the AWS Lambda.</li></ul><p>4. Managed services</p><ul><li>Serverless applications use managed cloud services for tasks like data storage, messaging, and caching.</li><li>Examples: AWS SQS, Azure Event Hub, Redis.</li></ul><blockquote>Why to use serverless architecture</blockquote><ol><li><strong>Cost efficient</strong></li></ol><ul><li>Pay-as-You-Go Model: You pay only for the actual execution time of your code and the resources it consumes. No costs are incurred for idle resources.</li><li>Ideal for unpredictable workloads where usage spikes and drops are common.</li></ul><p>2. <strong>Scalability</strong></p><ul><li>Automatically scales up or down in response to traffic. For example, AWS Lambda can handle thousands of requests per second without any manual intervention.</li></ul><p>3. <strong>Event-driven nature</strong></p><ul><li>Easily integrates with event sources like API Gateway, S3, or database triggers to react to real-time events.</li></ul><blockquote>When to use the serverless architecture</blockquote><ol><li><strong>Event-Driven Applications</strong></li></ol><ul><li>Use cases like file processing (e.g., image resizing), IoT data processing, or real-time stream processing.</li></ul><p>2. <strong>Unpredictable Workloads:</strong></p><ul><li>Applications where traffic fluctuates significantly, like ticket booking systems or flash sales.</li></ul><p>3.<strong> Microservices and Modular Applications:</strong></p><ul><li>When building independent, small services that can scale individually.</li></ul><p>4.<strong> Prototyping and MVPs:</strong></p><ul><li>Quick to set up and deploy, making it ideal for experimentation and proof-of-concept projects.</li></ul><p>5. <strong>Data Transformation Pipelines:</strong></p><ul><li>Scenarios involving data ingestion, processing, and storage.</li></ul><p>6. <strong>Web and Mobile Backends:</strong></p><ul><li>For lightweight, scalable APIs and backend logic.</li></ul><blockquote>When not to use serverless architecture</blockquote><ol><li><strong>Long-Running Processes:</strong></li></ol><ul><li>Serverless functions often have execution time limits (e.g., AWS Lambda has a 15-minute cap).</li><li>Batch processing or applications requiring long-running jobs might not fit well.</li></ul><p>2. <strong>High-Performance, Low-Latency Requirements:</strong></p><ul><li>Cold starts (initial function invocation delay) can introduce latency, making it less suitable for real-time applications needing low latency.</li></ul><p>3. <strong>Complex Stateful Applications:</strong></p><ul><li>Serverless functions are stateless by design. Maintaining state across functions requires external services like databases or caches, adding complexity.</li></ul><p>4. <strong>Heavy, Predictable Workloads:</strong></p><ul><li>For constant, heavy workloads, traditional servers or containers might be more cost-effective.</li></ul><h4>Serverless architecture example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6t4jRl11qWY05xHRJkpMlg.png" /><figcaption>Image processing application architecture</figcaption></figure><p>Let’s consider an <strong>image-processing application</strong>:</p><p>For the above example, I’ve used the AWS services and the above architecture is event-driven serverless architecture, before I explain this let me tell you a bit about these services I’ve used.</p><p>- <strong>S3 Bucket: </strong>Fully managed storage service in AWS.<br>- <strong>SQS Queue: </strong>Fully managed messaging queue.<br>- <strong>Lambda Function: </strong>Fully managed service on which your codes run.</p><ol><li>A user uploads an image to an Input S3 bucket.</li><li>The SQS messaging queue triggers an event to trigger the Lambda function.</li><li>The Lambda function processes the image (e.g., resizing, applying filters) and saves it back to the S3 output bucket and RDS database.</li><li>All of this happens without any server setup, scaling is automatic, and you pay only for the computing time used.</li></ol><p>Note:- AWS Lambda has a maximum life span of 15 minutes only.</p><p>Thank you, hope you like it :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ff0b3d8115e" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/what-is-serverless-architecture-2ff0b3d8115e">What is Serverless Architecture?</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How OAuth 2.0 works, Explained]]></title>
            <link>https://harshitgupta028.medium.com/how-oauth-2-0-works-explained-c2d93d8f3171?source=rss-8a7c4439fa93------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2d93d8f3171</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[jwt-token]]></category>
            <category><![CDATA[client-credentials]]></category>
            <dc:creator><![CDATA[Harshit Gupta]]></dc:creator>
            <pubDate>Mon, 11 Nov 2024 16:40:15 GMT</pubDate>
            <atom:updated>2024-12-15T11:33:50.574Z</atom:updated>
            <content:encoded><![CDATA[<h4>OAuth: Grant access to resources on behalf of a user</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*bfBUeu2B77OpYLBbZADjmQ.png" /></figure><p>What is OAuth 2.0?</p><p>OAuth 2.0 is the second version of the OAuth framework, providing more secure, flexible, and simplified authorization methods for applications to access resources on behalf of a user.</p><p>It’s now the standard for web and mobile application authorization, supporting various authorization flows that accommodate different types of applications, including single-page apps, server-side apps, and machine-to-machine services.</p><figure><img alt="OAuth flow" src="https://cdn-images-1.medium.com/max/465/1*8pMso34yfDQ_XRx50_Z0mg.png" /></figure><p>In OAuth, the parties included are the client and servers. The client tries to access the resources on the server. If resources are protected, then the client has to validate its identity to determine whether the particular client trying to access the resource has the authorization to access it.</p><p>Here comes the twist how client can validate its identity?</p><p>To validate the client&#39;s identity, the client has to request the access token from the authorization provider of the resource which will contain the client&#39;s information along with the resource authorization details i.e. what resources the particular client can access.</p><p>So, before accessing the resource the client will send the request to the resource authorization provider to get the access token generally, it&#39;s a <em>JWT</em> token and the endpoint is <a href="https://somedomain.com/token"><em>https://some.domain.com/token</em></a></p><p>Sample response of the authorization provider</p><pre>{<br>  &quot;token_type&quot;: &quot;Bearer&quot;,<br>  &quot;expires_in&quot;: 3599,<br>  &quot;ext_expires_in&quot;: 3599,<br>  &quot;access_token&quot;: &quot;eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ij..............&quot;<br>}</pre><p>confused?</p><p>Let’s understand with an example of a blog application, whose API endpoints I wanted to expose that is secured by OAuth, let&#39;s take a look at how the flow is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*Ei3CJ9QXBjF5bp8WVoObzg.png" /></figure><p>In the above example,</p><p>I wanted to get the data for the posts from <em>/get-posts </em>but it&#39;s a secured endpoint so I can not access it directly, first I have to get the access_token from the <em>https:some.domain.com/token </em>Now I’ll pass the access token in the header of the <em>GET /get-posts</em> request,</p><p>The resource server will validate whether the client is authenticated and authorized to access that resource using the token passed.</p><p>Now you understand OAuth 2.0, there are multiple types of OAuth grants. The above example focuses on client_credentials.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2d93d8f3171" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>