<?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 Shivprasadbaraskar on Medium]]></title>
        <description><![CDATA[Stories by Shivprasadbaraskar on Medium]]></description>
        <link>https://medium.com/@shivprasadbaraskar3632?source=rss-b9defbf45c56------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*q6ce-lC587SJHA08</url>
            <title>Stories by Shivprasadbaraskar on Medium</title>
            <link>https://medium.com/@shivprasadbaraskar3632?source=rss-b9defbf45c56------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:56:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shivprasadbaraskar3632/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[Promises and Async/Await in JavaScript: Understanding Asynchronous Programming]]></title>
            <link>https://medium.com/@shivprasadbaraskar3632/promises-and-async-await-in-javascript-understanding-asynchronous-programming-332894560014?source=rss-b9defbf45c56------2</link>
            <guid isPermaLink="false">https://medium.com/p/332894560014</guid>
            <dc:creator><![CDATA[Shivprasadbaraskar]]></dc:creator>
            <pubDate>Fri, 18 Sep 2026 09:14:58 GMT</pubDate>
            <atom:updated>2026-09-18T09:14:58.171Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript is widely known for its ability to handle asynchronous operations without blocking the execution of other code. This is especially important when working with APIs, database requests, file operations, timers, and other tasks that may take some time to complete.</p><p>Two important concepts that make asynchronous programming easier to understand and manage are <strong>Promises</strong> and <strong>Async/Await</strong>.</p><h3>🔹 What is Asynchronous Programming?</h3><p>In synchronous programming, tasks are generally executed one after another. If one task takes a long time, the following tasks have to wait.</p><p>In asynchronous programming, JavaScript can start a time-consuming operation and continue executing other code while waiting for the operation to complete.</p><p>For example, when requesting data from an API, we don’t want the entire application to stop while waiting for the server response.</p><p>This is where asynchronous programming becomes useful.</p><h3>🔹 The Problem with Callbacks</h3><p>One traditional way of handling asynchronous operations in JavaScript is using <strong>callbacks</strong>.</p><p>A callback is a function passed to another function and executed after an operation is completed.</p><pre>function getData(callback) {<br>    setTimeout(() =&gt; {<br>        callback(&quot;Data received!&quot;);<br>    }, 2000);<br>}</pre><pre>getData((data) =&gt; {<br>    console.log(data);<br>});</pre><p>Callbacks work, but when multiple asynchronous operations depend on each other, the code can become difficult to read and maintain.</p><p>This problem is commonly known as <strong>Callback Hell</strong>.</p><h3>🔹 What is a Promise?</h3><p>A <strong>Promise</strong> is an object that represents the eventual completion or failure of an asynchronous operation.</p><p>A Promise has three states:</p><ul><li><strong>Pending</strong> — The operation is still in progress.</li><li><strong>Fulfilled</strong> — The operation completed successfully.</li><li><strong>Rejected</strong> — The operation failed.</li></ul><p>A simple example:</p><pre>const promise = new Promise((resolve, reject) =&gt; {</pre><pre>    let success = true;</pre><pre>    if (success) {<br>        resolve(&quot;Operation successful!&quot;);<br>    } else {<br>        reject(&quot;Operation failed!&quot;);<br>    }</pre><pre>});</pre><p>We can handle the result using .then() and .catch():</p><pre>promise<br>    .then((result) =&gt; {<br>        console.log(result);<br>    })<br>    .catch((error) =&gt; {<br>        console.log(error);<br>    });</pre><p>Here:</p><ul><li>resolve() indicates successful completion.</li><li>reject() indicates failure.</li><li>.then() handles the successful result.</li><li>.catch() handles errors.</li></ul><h3>🔹 Promise Chaining</h3><p>Promises also allow us to perform multiple asynchronous operations in sequence.</p><pre>getUser()<br>    .then((user) =&gt; {<br>        return getOrders(user.id);<br>    })<br>    .then((orders) =&gt; {<br>        console.log(orders);<br>    })<br>    .catch((error) =&gt; {<br>        console.log(error);<br>    });</pre><p>Instead of deeply nested callbacks, Promise chaining provides a cleaner structure.</p><h3>🔹 What is Async/Await?</h3><p>Although Promises make asynchronous code cleaner, JavaScript provides an even more readable syntax: <strong>Async/Await</strong>.</p><p>An async function always returns a Promise.</p><p>The await keyword pauses the execution of the async function until the Promise is settled.</p><p>Example:</p><pre>async function getData() {</pre><pre>    const result = await fetchData();</pre><pre>    console.log(result);</pre><pre>}</pre><pre>getData();</pre><p>This code looks similar to synchronous code, but it is still working with asynchronous operations.</p><h3>🔹 Handling Errors with Async/Await</h3><p>We can use try...catch to handle errors.</p><pre>async function fetchUser() {</pre><pre>    try {</pre><pre>        const response = await fetch(<br>            &quot;https://example.com/api/user&quot;<br>        );</pre><pre>        const data = await response.json();</pre><pre>        console.log(data);</pre><pre>    } catch (error) {</pre><pre>        console.log(&quot;Error:&quot;, error);</pre><pre>    }</pre><pre>}</pre><p>This makes asynchronous error handling much easier to read.</p><h3>🔹 Promises vs Async/Await</h3><p>Both approaches are based on Promises, but their syntax is different.</p><p>PromisesAsync/AwaitUses .then() and .catch()Uses await and try...catchCan involve chainingUsually reads like sequential codeUseful for handling multiple Promise operationsOften easier to read and maintainMore functional styleMore synchronous-looking style</p><p>It is important to understand that <strong>Async/Await does not replace Promises</strong>. Instead, it provides a cleaner way to work with Promise-based asynchronous operations.</p><h3>🔹 Why Are They Important?</h3><p>Promises and Async/Await are used extensively in modern JavaScript applications.</p><p>They are especially useful when working with:</p><ul><li>REST APIs</li><li>Database operations</li><li>File operations</li><li>Network requests</li><li>Authentication</li><li>External services</li><li>Timers and other asynchronous tasks</li></ul><p>For example, a web application may need to:</p><pre>User Request<br>     ↓<br>Call API<br>     ↓<br>Wait for Response<br>     ↓<br>Process Data<br>     ↓<br>Display Result</pre><p>Promises and Async/Await help us manage this process without making the application unnecessarily block while waiting for the response.</p><h3>🔹 Conclusion</h3><p>Asynchronous programming is an essential part of modern JavaScript development.</p><p>Callbacks introduced a way to handle asynchronous operations, but complex callback structures could become difficult to maintain. Promises provided a cleaner approach, and Async/Await made Promise-based code even easier to understand.</p><p>Understanding these concepts is important for anyone working with JavaScript, frontend frameworks, Node.js, or REST APIs.</p><p>The key takeaway is simple:</p><p><strong>Promises provide a structured way to handle asynchronous operations, while Async/Await provides a cleaner and more readable syntax for working with those Promises.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=332894560014" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Activity & Activity Lifecycle]]></title>
            <link>https://medium.com/@shivprasadbaraskar3632/android-activity-activity-lifecycle-cceeaf53965b?source=rss-b9defbf45c56------2</link>
            <guid isPermaLink="false">https://medium.com/p/cceeaf53965b</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[android-programming]]></category>
            <category><![CDATA[activity-lifecycle]]></category>
            <dc:creator><![CDATA[Shivprasadbaraskar]]></dc:creator>
            <pubDate>Fri, 06 Mar 2026 17:06:31 GMT</pubDate>
            <atom:updated>2026-03-06T17:06:31.401Z</atom:updated>
            <content:encoded><![CDATA[<p>Android is one of the most widely used mobile operating systems in the world, and applications built for Android are made up of several important components. One of the most fundamental components is an <strong>Activity</strong>. An Activity represents a <strong>single screen with a user interface</strong> where users can perform interactions such as clicking buttons, entering text, viewing information, or navigating through different parts of an application. In simple terms, an Activity can be thought of as a <strong>page or screen of an Android application</strong>.</p><p>For example, in a typical mobile application there may be multiple screens such as a <strong>login screen, home screen, profile page, settings page, or payment page</strong>. Each of these screens is implemented using an Activity. When a user moves from one screen to another, Android switches between different Activities.</p><p>To manage how these screens behave during different stages of use, Android provides a concept called the <strong>Activity Lifecycle</strong>. The Activity Lifecycle refers to the <strong>series of states an Activity goes through from the moment it is created until it is destroyed</strong>. Android manages these states automatically using special lifecycle callback methods. These methods help developers control the behavior of the application, manage resources properly, and ensure a smooth user experience.</p><p>The first lifecycle method is <strong>onCreate()</strong>. This method is called when the Activity is created for the first time. It is one of the most important methods because it is used to initialize essential components of the application. Developers typically set the user interface layout inside this method using the setContentView() function. They may also initialize variables, buttons, text views, or other user interface elements. Essentially, onCreate() prepares the Activity for display.</p><p>After onCreate(), the next method called is <strong>onStart()</strong>. This method is triggered when the Activity becomes visible to the user. At this stage, the Activity is displayed on the screen but may not yet be ready for full interaction. Developers often use this method to prepare UI elements or register listeners needed while the Activity is visible.</p><p>The next stage is <strong>onResume()</strong>. When this method is called, the Activity comes to the foreground and becomes fully interactive. This means the user can now interact with the application by tapping buttons, entering information, or scrolling through content. Most user interactions happen when the Activity is in the resumed state.</p><p>Sometimes an Activity may lose focus temporarily. For example, if the user receives a phone call, opens a notification, or launches another small window that partially covers the current screen, the <strong>onPause()</strong> method is called. In this state, the Activity is still visible but not in the foreground. Developers typically use onPause() to pause animations, stop sensors, or save temporary data so that the application does not lose information.</p><p>If the Activity becomes completely hidden from the user, the <strong>onStop()</strong> method is executed. This happens when the user switches to another application or navigates to a different Activity within the same application. At this stage, the Activity is no longer visible. Developers may release heavy resources or stop background processes to improve performance.</p><p>When a stopped Activity is brought back to the screen, the <strong>onRestart()</strong> method is called. This method prepares the Activity to start again. After onRestart(), the lifecycle continues with <strong>onStart()</strong> and <strong>onResume()</strong>, allowing the Activity to become visible and interactive again.</p><p>Finally, when the Activity is completely closed or removed from memory, the <strong>onDestroy()</strong> method is called. This method is responsible for final cleanup operations. Developers can release resources such as memory allocations, database connections, or background threads before the Activity is destroyed.</p><p>A real-life example of the Activity Lifecycle can be seen in messaging applications. Suppose a user opens a messaging app and navigates to a chat screen. When the chat screen loads, the onCreate() method is executed to initialize the layout. The Activity then becomes visible through onStart() and interactive through onResume(). If the user receives a phone call, the Activity moves to the onPause() state. When the user switches to another application, the Activity enters the onStop() state. If the user returns to the messaging app, the Activity restarts using onRestart(), onStart(), and onResume().</p><p>Understanding the Activity Lifecycle is extremely important for Android developers. Proper handling of lifecycle methods helps ensure that applications run efficiently, manage memory effectively, and maintain a consistent user experience even when users switch between multiple apps. It also helps developers prevent crashes, save user data, and maintain application stability.</p><p>In conclusion, the Activity and its lifecycle form the backbone of Android application development. By understanding how each lifecycle method works and when it is triggered, developers can design applications that are responsive, reliable, and user-friendly. Mastering the Activity Lifecycle allows developers to build robust Android applications that handle different user interactions and system events smoothly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*FZscxg-lDiN3hUR8.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cceeaf53965b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>