<?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 Prateek Gupta on Medium]]></title>
        <description><![CDATA[Stories by Prateek Gupta on Medium]]></description>
        <link>https://medium.com/@WorkOfWisdom?source=rss-56eb2b9b977a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qX7TcsVLPlUoFnRqmng2dQ.png</url>
            <title>Stories by Prateek Gupta on Medium</title>
            <link>https://medium.com/@WorkOfWisdom?source=rss-56eb2b9b977a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 22:33:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@WorkOfWisdom/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[Why Rewarding yourself is necessary!]]></title>
            <link>https://medium.com/bytes-of-motivation/why-rewarding-yourself-is-necessary-ecbb4c266074?source=rss-56eb2b9b977a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecbb4c266074</guid>
            <category><![CDATA[happiness]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[motivation]]></category>
            <category><![CDATA[love]]></category>
            <dc:creator><![CDATA[Prateek Gupta]]></dc:creator>
            <pubDate>Tue, 01 Oct 2024 01:30:03 GMT</pubDate>
            <atom:updated>2024-10-01T01:30:03.826Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y04kyKKSviBz1cCOL5Q2eA.png" /></figure><p>Here’s why:</p><p><strong>1. Boosts motivation:</strong> Rewards create a sense of achievement, making you more excited to keep going.<br><strong> 2. Builds positive habits:</strong> By associating hard work with rewards, you condition yourself to enjoy the process.<br><strong> 3. Reduces burnout:</strong> Celebrating small wins gives you a mental break, preventing exhaustion from constant effort.<br><strong> 4. Increases self-confidence: </strong>Acknowledging your successes boosts self-esteem and belief in your abilities.<br><strong> 5. Creates a positive feedback loop:</strong> Regular rewards make tasks feel more enjoyable and satisfying.</p><p>Rewarding yourself is a powerful psychological tool that significantly contributes to motivation, habit formation, and overall well-being. Here’s an in-depth exploration of why it’s necessary and how it impacts your motivation and behavior:</p><p><strong>1. Boosts Motivation</strong></p><ul><li><strong>Immediate Gratification:</strong> When you reward yourself after completing a task or achieving a goal, you create an immediate sense of gratification. This feeling reinforces the behavior that led to the reward, making it more likely that you will engage in the same behavior in the future.</li><li><strong>Incentive to Act:</strong> Knowing that a reward awaits can serve as a powerful incentive. It gives you something to look forward to, which can be especially important when tackling challenging or tedious tasks.</li></ul><p><strong>2. Builds Positive Habits</strong></p><ul><li><strong>Conditioning through Reinforcement:</strong> According to behaviorist psychology, positive reinforcement strengthens the association between behavior and its outcomes. By consistently rewarding yourself after completing tasks or achieving goals, you condition yourself to develop positive habits.</li><li><strong>Habit Formation:</strong> When you create a pattern of rewarding behaviors, your brain begins to expect the reward as a natural consequence of completing the task. This process can help solidify good habits over time, making them part of your routine.</li></ul><p><strong>3. Reduces Burnout</strong></p><ul><li><strong>Mental Breaks:</strong> Continuous hard work without breaks can lead to burnout, characterized by emotional, physical, and mental exhaustion. Rewards serve as mental breaks that allow you to step back, relax, and recharge.</li><li><strong>Balancing Efforts:</strong> By incorporating rewards into your workflow, you create a balance between effort and enjoyment. This balance helps prevent the feeling of being overwhelmed, which is common in demanding tasks or long-term projects.</li></ul><p><strong>4. Increases Self-Confidence</strong></p><ul><li><strong>Acknowledgment of Achievements:</strong> Celebrating your successes, no matter how small, fosters a sense of accomplishment. This acknowledgment reinforces your self-worth and can lead to greater self-confidence.</li><li><strong>Positive Self-Image: </strong>When you reward yourself, you affirm your capabilities and achievements. Over time, this can contribute to a positive self-image, enabling you to tackle future challenges with more confidence.</li></ul><p><strong>5. Creates a Positive Feedback Loop</strong></p><ul><li><strong>Enjoyable Process:</strong> Incorporating rewards into your tasks can make the process more enjoyable. When you associate tasks with positive outcomes, you are more likely to engage in them willingly.</li><li><strong>Motivation Maintenance:</strong> As you continue to reward yourself, you create a feedback loop: the positive feelings from the reward encourage you to pursue the task again, which leads to more rewards and further motivation.</li></ul><p><strong>6. Enhances Focus and Productivity</strong></p><ul><li><strong>Increased Focus:</strong> Knowing that a reward awaits can help sharpen your focus on the task at hand. The anticipation of the reward acts as a motivator, helping you to concentrate and work more efficiently.</li><li><strong>Boosts Productivity:</strong> The psychological incentive of rewards can lead to higher productivity levels. When you feel motivated and engaged, you are likely to accomplish more in less time.</li></ul><p><strong>7. Encourages Persistence</strong></p><ul><li><strong>Overcoming Challenges: </strong>Rewards can provide the extra push needed to persist through difficult or monotonous tasks. When faced with obstacles, the prospect of a reward can motivate you to keep going instead of giving up.</li><li><strong>Long-term Commitment:</strong> For long-term goals, having rewards along the way helps maintain motivation over extended periods. This ongoing reinforcement can make challenging tasks seem more manageable.</li></ul><p>By integrating rewards into your daily routine, you can cultivate a more satisfying and productive journey toward your goals, ensuring that the process is as enjoyable as the outcomes. This practice fosters a positive mindset, allowing you to navigate challenges with enthusiasm and persistence.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecbb4c266074" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bytes-of-motivation/why-rewarding-yourself-is-necessary-ecbb4c266074">Why Rewarding yourself is necessary!</a> was originally published in <a href="https://medium.com/bytes-of-motivation">Bytes of Motivation</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin Coroutines: A Primer]]></title>
            <link>https://medium.com/@WorkOfWisdom/kotlin-coroutines-a-primer-ed792b979854?source=rss-56eb2b9b977a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed792b979854</guid>
            <category><![CDATA[coroutine]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[suspend-function]]></category>
            <category><![CDATA[coroutines-in-kotlin]]></category>
            <dc:creator><![CDATA[Prateek Gupta]]></dc:creator>
            <pubDate>Tue, 01 Oct 2024 00:35:46 GMT</pubDate>
            <atom:updated>2024-10-01T00:41:10.530Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9NzEliBw4TflLSWPuyns7g.png" /></figure><p>Kotlin coroutines provide an easy way to handle asynchronous programming in a sequential manner, making it simpler to write code that is both non-blocking and concurrent. They’re designed to simplify tasks like network calls, database operations, or any long-running background work that would traditionally involve callbacks, threads, or RxJava.</p><p>Here’s a primer that covers the basics of coroutines in Kotlin:</p><h4><strong>1. What is a Coroutine?</strong></h4><p>A coroutine is a lightweight thread that can be suspended and resumed without blocking a thread. Instead of blocking the thread during long-running tasks (e.g., network or I/O operations), coroutines suspend the execution at certain points and resume when the task is ready, without holding onto the thread during the waiting period.</p><h4>2. Key Concepts</h4><p><strong>a. Suspending Functions</strong></p><p>A suspending function is a function that can be paused without blocking the thread and resumed later. These functions are marked with the suspend keyword and can only be called from within other suspending functions or coroutines.</p><p>Example:</p><pre>suspend fun fetchData(): String {<br>    delay(1000L)  // Simulates a network request, suspending the coroutine for 1 second<br>    return &quot;Data fetched&quot;<br>}</pre><p>The delay() function is a suspending function that pauses the coroutine for a specified time without blocking the thread.</p><p><strong>b. CoroutineScope</strong></p><p>Coroutines are launched within a CoroutineScope, which defines the lifecycle of the coroutine. When the scope is canceled, all coroutines within that scope are canceled as well.</p><p>Example:</p><pre>CoroutineScope(Dispatchers.IO).launch {<br>    // Coroutine runs in IO dispatcher<br>}</pre><p><strong>c. Dispatcher</strong></p><p>Dispatchers specify the thread or thread pool on which a coroutine will run:</p><ul><li><strong><em>Dispatchers.Main:</em></strong> Runs on the main thread, typically used for UI operations.</li><li><strong><em>Dispatchers.IO:</em></strong> Optimized for I/O operations like file or network access.</li><li><strong><em>Dispatchers.Default:</em></strong><em> </em>Used for CPU-intensive tasks.</li><li><strong><em>Dispatchers.Unconfined:</em></strong> Starts in the current thread but can continue in any thread.</li></ul><p>Example:</p><pre>CoroutineScope(Dispatchers.Main).launch {<br>    // Runs on the main thread<br>    val result = fetchData()<br>    updateUI(result)<br>}</pre><p><strong>3. Launching Coroutines</strong></p><p>There are two main ways to start a coroutine:</p><ul><li><strong><em>launch:</em></strong> Fire-and-forget; the coroutine starts and does not return a result.</li><li><strong><em>async:</em></strong> Starts a coroutine that returns a Deferred result, allowing you to use await() to get the result later.</li></ul><p><strong>a. launch</strong></p><p>The launch function is used to start a coroutine that doesn’t return a result but can run in the background. It is typically used for tasks that don’t need a return value, such as updating the UI or saving data.</p><p>Example:</p><pre>GlobalScope.launch {<br>    // Runs in the background<br>    delay(1000L)<br>    println(&quot;Task complete!&quot;)<br>}</pre><p><strong>b. async</strong></p><p>The async function is used when you need a result from a coroutine. It returns a Deferred object, which you can call await() on to get the result when it’s ready.</p><p>Example:</p><pre>val deferredResult = GlobalScope.async {<br>    // Do some background work and return the result<br>    fetchData()<br>}<br><br>val result = deferredResult.await()  // Wait for the result<br>println(result)</pre><p><strong>4. Suspending vs Blocking</strong></p><p>In traditional asynchronous programming, waiting for a task like a network request would block the thread until the result is ready. Coroutines, on the other hand, allow the code to suspend at a given point, freeing up the thread for other work.</p><ul><li><strong><em>Blocking:</em></strong> The thread is held until the operation completes.</li><li><strong><em>Suspending:</em></strong> The coroutine pauses its execution but does not block the thread.</li></ul><pre>fun blockingFunction() {<br>    Thread.sleep(1000L)  // Blocks the thread for 1 second<br>    println(&quot;Blocking complete&quot;)<br>}<br><br>suspend fun suspendingFunction() {<br>    delay(1000L)  // Suspends the coroutine for 1 second without blocking the thread<br>    println(&quot;Suspending complete&quot;)<br>}</pre><p><strong>5. Structured Concurrency</strong></p><p>Kotlin coroutines emphasize structured concurrency, meaning coroutines launched in a specific scope are tied to that scope’s lifecycle. This helps prevent memory leaks and ensures proper cancellation of coroutines when they are no longer needed.</p><p>Example with runBlocking:</p><pre>fun main() = runBlocking {<br>    launch {<br>        delay(1000L)<br>        println(&quot;Coroutine finished&quot;)<br>    }<br>    println(&quot;RunBlocking scope ends&quot;)<br>}</pre><p>Here, runBlocking blocks the main thread until all coroutines inside its scope complete.</p><p><strong>6. Exception Handling in Coroutines</strong></p><p>Coroutines provide built-in mechanisms for handling exceptions using try-catch blocks. Uncaught exceptions in child coroutines propagate up to their parent scopes.</p><p>Example:</p><pre>CoroutineScope(Dispatchers.Main).launch {<br>    try {<br>        fetchData()<br>    } catch (e: Exception) {<br>        println(&quot;Error: ${e.message}&quot;)<br>    }<br>}</pre><p>For structured concurrency, coroutine scopes automatically handle cancellation of child coroutines if any exception occurs.</p><p><strong>7. Coroutine Builders</strong></p><ul><li><strong><em>launch:</em></strong> Starts a new coroutine without blocking the current thread and returns a Job object, which can be used to cancel the coroutine.</li><li><strong><em>async:</em></strong><em> </em>Starts a new coroutine and returns a Deferred result that can be awaited.</li><li><strong><em>runBlocking: </em></strong>Blocks the current thread and runs the coroutine, often used in testing or top-level main functions.</li><li><strong><em>withContext:</em></strong> Switches to a different dispatcher within a coroutine.</li></ul><pre>suspend fun getData(): String {<br>    return withContext(Dispatchers.IO) {<br>        // Switch to IO dispatcher<br>        fetchData()  // Suspends here without blocking the calling thread<br>    }<br>}</pre><p><strong>8. Coroutine Scopes in Android</strong></p><p>Kotlin coroutines are integrated with Android’s architecture components, such as ViewModel and Lifecycle. Scopes like viewModelScope and lifecycleScope automatically cancel coroutines when the ViewModel or Activity/Fragment is cleared, preventing memory leaks.</p><pre>class MyViewModel : ViewModel() {<br>    fun fetchData() {<br>        viewModelScope.launch {<br>            val result = fetchData()<br>            // Update UI or data<br>        }<br>    }<br>}</pre><p><strong>9. Cancellation</strong></p><p>Coroutines can be canceled by invoking cancel() on a Job or Deferred. They check for cancellation points, like delay(), or can explicitly check with isActive.</p><pre>val job = launch {<br>    repeat(100) { i -&gt;<br>        if (!isActive) return@launch  // Check for cancellation<br>        delay(500L)<br>        println(&quot;Running task $i&quot;)<br>    }<br>}<br>delay(2000L)<br>job.cancel()  // Cancel the coroutine after 2 seconds</pre><p><strong>10. Advanced: Channels and Flow</strong></p><p>For asynchronous streams, Kotlin offers Channels and Flow. Channels are for sending and receiving data between coroutines, while Flow provides a cold, asynchronous stream of data.</p><pre>fun simpleFlow(): Flow&lt;Int&gt; = flow {<br>    for (i in 1..3) {<br>        delay(100L)<br>        emit(i)<br>    }<br>}<br><br>fun main() = runBlocking {<br>    simpleFlow().collect { value -&gt;<br>        println(value)<br>    }<br>}</pre><p><strong>Conclusion</strong></p><p>They allow writing sequential, non-blocking code without the complexity of callbacks or threads. By leveraging suspending functions, coroutine scopes, and structured concurrency, Kotlin offers an elegant solution for managing concurrency and asynchronous tasks in applications, especially on Android.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed792b979854" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>