<?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 Mukesh Yadav on Medium]]></title>
        <description><![CDATA[Stories by Mukesh Yadav on Medium]]></description>
        <link>https://medium.com/@mukesh-yadav?source=rss-5f1f9daa163c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*o73eRYENqeIsrB_YoX0jZg.jpeg</url>
            <title>Stories by Mukesh Yadav on Medium</title>
            <link>https://medium.com/@mukesh-yadav?source=rss-5f1f9daa163c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:42:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mukesh-yadav/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[The Silent LeetCode Killer: How Implicit 32-bit Integer Overflow Ruins Your Elegant Solutions]]></title>
            <link>https://mukesh-yadav.medium.com/the-silent-leetcode-killer-how-implicit-32-bit-integer-overflow-ruins-your-elegant-solutions-e21d40634973?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e21d40634973</guid>
            <category><![CDATA[leetcode]]></category>
            <category><![CDATA[competitive-programming]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[integer-overflow]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Sun, 28 Jun 2026 12:28:21 GMT</pubDate>
            <atom:updated>2026-06-28T12:39:54.265Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*Q5AsQaNdy3hR9q0g" /></figure><p><strong>Leetcode</strong>: <a href="https://leetcode.com/contest/weekly-contest-508/problems/maximum-total-sum-of-k-selected-elements/description/">https://leetcode.com/contest/weekly-contest-508/problems/maximum-total-sum-of-k-selected-elements/description/</a></p><p>Imagine this: You’re in the middle of a competitive programming contest. You spot a leetcode problem, and the solution clicks instantly. You cook up a beautiful, concise, and incredibly readable greedy approach using Kotlin’s idiomatic collections API, dry-run your test cases, and they all pass flawlessly.</p><p>Confident, you hit <strong>Submit</strong>.</p><p><em>Wrong Answer.</em> ❌</p><p>You look at the failing test case. The numbers are huge, and your code is outputting a bizarre result. You look at your variables — your accumulator is clearly marked as a Long.</p><p>What went wrong? You just fell victim to one of the most common and frustrating traps in programming: <strong>Implicit 32-bit Integer Overflow</strong>.</p><h3>The Invisible Trap</h3><p>Let’s look at a snippet of Kotlin code that mirrors a very common greedy problem pattern: maximizing a score by choosing whether to multiply array elements by a changing multiplier or just add them.</p><p>Kotlin</p><pre>fun maxSum(nums: IntArray, k: Int, mul: Int): Long {<br>    var mut_mul = mul<br>    var max_sum = 0L<br>    // Get top (highest) k elements from nums<br>    val top_elements = nums.sortedDescending().take(k)<br>    top_elements.forEach {<br>        val curr_sum = it * mut_mul // &lt;-- THE TRAP<br>        if (curr_sum &lt; 1) // I know I could have choose maxOf, but my thought, anything more than 0 should be contributing postive to max_sum<br>            max_sum += it<br>        else<br>            max_sum += curr_sum<br>        mut_mul--<br>    }<br>    return max_sum<br>}</pre><p>At first glance, this code looks pristine and beautifully simple. max_sum is explicitly declared as a 64-bit Long. It has more than enough room to hold massive numbers up to $9 \times 10^{18}$.</p><p>But when the array contains large values (like $10⁵$) and the multiplier is also large ($10⁵$), the code breaks.</p><h3>Why did it fail?</h3><p>The bug is hiding on this exact line:</p><p>Kotlin</p><pre>val curr_sum = it * mut_mul</pre><p>Even though the variable curr_sum will implicitly infer its type from the result, the <strong>multiplication itself</strong> happens <em>before</em> the assignment.</p><p>Because it is a 32-bit Int from the array and mut_mul is a 32-bit Int, the CPU allocates a 32-bit register to perform the math.</p><ul><li>$10⁵ \times 10⁵ = 10^{10}$ (10 Billion)</li><li>The maximum value a signed 32-bit integer can hold is $2^{31} — 1 \approx 2.14 \times 10⁹$ (2.14 Billion).</li></ul><p>Because 10 Billion exceeds 2.14 Billion, the binary bits overflow into the sign bit. The CPU wraps the number around, turning your massive positive product into a garbage <strong>negative number</strong>.</p><p>By the time that value is evaluated by your if (curr_sum &lt; 1) check, the damage is already done. Your logic sees a negative number, thinks the product is useless, and mistakenly falls back to adding just it instead of the massive multiplied value.</p><h3>The One-Line Fix: Upcasting Early</h3><p>To prevent this, you must force the compiler to perform the math using 64-bit registers <em>before</em> the multiplication happens. You do this by casting the array element to a 64-bit type (Long in Kotlin) right before the operation.</p><p>Here is the corrected, overflow-safe loop keeping your exact logic intact:</p><p>Kotlin</p><pre>top_elements.forEach {<br>    // Fix: Cast &#39;it&#39; to Long FIRST. <br>    // This forces the multiplication to happen in 64-bit space.<br>    val curr_sum = it.toLong() * mut_mul <br>    <br>    if (curr_sum &lt; 1)<br>        max_sum += it<br>    else<br>        max_sum += curr_sum<br>    mut_mul--<br>}</pre><p>Now, Long * Int promotes the entire operation to a 64-bit Long. $10^{10}$ fits easily, your if condition evaluates correctly, and your code passes with flying colors.</p><h3>The Golden Rules for Avoiding Overflow (What I learnt)</h3><p>When grinding platforms like LeetCode, keep these principles in mind:</p><ul><li><strong>Check the Constraints First:</strong> Always look at the bottom of the problem description. If the constraints say array values and multipliers can reach $10⁵$, multiplication results can reach $10^{10}$, meaning 32-bit integers will overflow.</li><li><strong>Intermediate Expressions Matter:</strong> Declaring your final variable (max_sum) as a 64-bit primitive does not protect the math happening along the way.</li><li><strong>Cast on the Leftmost Element:</strong> Don’t write (a * b).toLong(). The damage is already done inside the parentheses. Write a.toLong() * b.</li></ul><h3>Conclusion</h3><p>Implicit integer overflow is a rite of passage for every developer. It doesn’t crash your program with a loud error; it silently corrupts your data and leaves you scratching your head wondering why your perfectly sound logic is failing.</p><p>The next time your clean, human-written solution fails on large inputs, don’t overthink your strategy — look closely at your math operations and remember to <strong>upcast early</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e21d40634973" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Android Development Mistakes I Stopped Making After 7 Years]]></title>
            <link>https://mukesh-yadav.medium.com/10-android-development-mistakes-i-stopped-making-after-7-years-c2bacb9814d0?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2bacb9814d0</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Sat, 27 Jun 2026 11:23:22 GMT</pubDate>
            <atom:updated>2026-06-27T11:23:22.912Z</atom:updated>
            <content:encoded><![CDATA[<p>I Thought My Code Was Good. I Was Wrong.</p><p>10 Android lessons that completely changed the way I build apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cbtkkimVEIDT4H-pjgmbvQ.png" /></figure><h3>Before We Start</h3><p>If you’re looking for another article that says:</p><ul><li>“Use MVVM.”</li><li>“Write clean code.”</li><li>“Use Coroutines.”</li><li>“Follow SOLID.”</li></ul><p>…this isn’t that article.</p><p>Everything you’ll read below is something I learned the hard way — through code reviews, production bugs, debugging sessions, and maintaining my own code months later.</p><p>Let’s start with the lesson that probably saved me from writing hundreds of future bugs.</p><h3>Lesson 1 — Never Use GlobalScope for UI Work</h3><blockquote><em>If your coroutine belongs to a screen, it should die with that screen.</em></blockquote><h3>❌ Don’t</h3><pre>GlobalScope.launch {<br>    repository.fetchUser()<br>}</pre><h3>✅ Do</h3><pre>viewModelScope.launch {<br>    repository.fetchUser()<br>}</pre><p>Or, if you’re inside an Activity or Fragment:</p><pre>lifecycleScope.launch {<br>    repeatOnLifecycle(Lifecycle.State.STARTED) {<br>        viewModel.uiState.collect(::render)<br>    }<br>}</pre><h3>Why?</h3><p>GlobalScope has no idea who started it.</p><p>It doesn’t know about your Activity.</p><p>It doesn’t know about your Fragment.</p><p>It doesn’t know when the user leaves the screen.</p><p>So the coroutine happily keeps running even after the UI has disappeared.</p><p>Best case?</p><p>It wastes resources.</p><p>Worst case?</p><p>It crashes your app by trying to update a screen that no longer exists.</p><h3>How I Learned This</h3><p>I once spent hours debugging a crash that only happened occasionally.</p><p>The feature worked perfectly.</p><p>QA couldn’t reproduce it consistently.</p><p>Eventually, I found the pattern.</p><p>Open the screen.</p><p>Start an API call.</p><p>Rotate the device before the response arrives.</p><p>Boom.</p><p>The old screen was gone.</p><p>The coroutine wasn’t.</p><p>That single bug taught me more about Android lifecycles than any documentation ever did.</p><h3>Takeaway</h3><blockquote><em>Before launching a coroutine, ask yourself:</em></blockquote><blockquote><strong><em>“Who is responsible for cancelling this?”</em></strong></blockquote><p>If you don’t have an answer, you’re probably using the wrong scope.</p><h3>Lesson 2 — If Your ViewModel Is 800 Lines Long, It’s Doing Too Much</h3><blockquote><em>A ViewModel should coordinate the UI, not contain your entire application.</em></blockquote><h3>❌ Don’t</h3><pre>class ProfileViewModel : ViewModel() {<br>    fun loadProfile() {<br>        // API Call<br>        // Validation<br>        // Business Logic<br>        // Analytics<br>        // Mapping<br>        // Sorting<br>        // Error Handling<br>        // UI State Update<br>    }<br>}</pre><h3>✅ Do</h3><pre>class ProfileViewModel(<br>    private val getProfileUseCase: GetProfileUseCase<br>) : ViewModel() {<br>    fun loadProfile() {<br>        viewModelScope.launch {<br>            _uiState.value = getProfileUseCase()<br>        }<br>    }<br>}</pre><h3>Why?</h3><p>The bigger a ViewModel becomes, the harder it is to:</p><ul><li>Understand</li><li>Test</li><li>Reuse</li><li>Review</li><li>Maintain</li></ul><p>Eventually, every new feature feels like adding another brick to an already overloaded building.</p><h3>How I Learned This</h3><p>One of my ViewModels crossed 900 lines.</p><p>Finding anything inside it became painful.</p><p>Merge conflicts became common.</p><p>Unit tests became harder.</p><p>Every bug fix risked breaking something unrelated.</p><p>The funny part?</p><p>I thought I was “keeping everything in one place.”</p><p>I wasn’t.</p><p>I was creating a God Object.</p><p>Today, whenever a ViewModel starts growing rapidly, I take it as a signal — not a success.</p><p>Usually it means some business logic belongs in a Use Case or another layer.</p><h3>Takeaway</h3><blockquote><em>If your ViewModel knows everything, it’s probably doing too much.</em></blockquote><h3>Lesson 3 — Stop Exposing MutableStateFlow</h3><blockquote><em>The UI should observe your state — not modify it.</em></blockquote><h3>❌ Don’t</h3><pre>val uiState = MutableStateFlow(ProfileUiState())</pre><h3>✅ Do</h3><pre>private val _uiState = MutableStateFlow(ProfileUiState())<br>val uiState = _uiState.asStateFlow()</pre><h3>Why?</h3><p>When you expose MutableStateFlow, any class with access to it can change your state.</p><p>That breaks encapsulation.</p><p>It also makes debugging much harder because updates can come from anywhere.</p><p>Keeping the mutable version private gives your ViewModel complete control over state changes.</p><h3>How I Learned This</h3><p>This wasn’t a production bug.</p><p>It was a code review comment.</p><p>At first, I thought,</p><blockquote><em>“Why does this even matter?”</em></blockquote><p>A senior engineer explained something I’ll never forget:</p><blockquote><strong><em>“If everyone can change the state, nobody owns it.”</em></strong></blockquote><p>That one sentence completely changed how I expose data from ViewModels.</p><p>Now, every state object has a single owner.</p><p>And debugging state-related issues has become much easier.</p><h3>Takeaway</h3><blockquote><em>Expose immutable state.</em></blockquote><blockquote><em>Keep mutation private.</em></blockquote><p>Future you will thank you.</p><h3>Lesson 4 — State Is Not an Event</h3><blockquote><em>Use </em><em>StateFlow for </em><strong><em>state</em></strong><em> and </em><em>SharedFlow for </em><strong><em>one-time events</em></strong><em>.</em></blockquote><h3>❌ Don’t</h3><pre>private val _uiState = MutableStateFlow(ProfileUiState())<br>val uiState = _uiState.asStateFlow()<br><br>fun onLoginSuccess() {<br>    _uiState.update {<br>        it.copy(navigateToHome = true)<br>    }<br>}</pre><p>Your UI now has to remember to reset navigateToHome = false.</p><p>After a configuration change, navigation might happen again.</p><h3>✅ Do</h3><pre>private val _uiState = MutableStateFlow(ProfileUiState())<br>val uiState = _uiState.asStateFlow()<br><br>private val _events = MutableSharedFlow&lt;UiEvent&gt;()<br>val events = _events.asSharedFlow()<br><br>fun onLoginSuccess() {<br>    viewModelScope.launch {<br>        _events.emit(UiEvent.NavigateToHome)<br>    }<br>}</pre><h3>Why?</h3><p>One of the biggest architecture mistakes I made was treating <strong>state</strong> and <strong>events</strong> as the same thing.</p><p>They’re not.</p><p>State answers:</p><ul><li>Is loading?</li><li>Current user</li><li>Selected tab</li><li>Theme</li><li>Cart items</li></ul><p>Events answer:</p><ul><li>Navigate</li><li>Show Toast</li><li>Open Dialog</li><li>Show Snackbar</li></ul><p>State exists.</p><p>Events happen.</p><p>Keeping them separate makes your UI predictable.</p><h3>How I Learned This</h3><p>I once fixed the same navigation bug three different times.</p><p>The bug?</p><p>After rotating the device, the app navigated to the next screen again.</p><p>At first I blamed Compose.</p><p>Then Navigation.</p><p>Then StateFlow.</p><p>Turns out…</p><p>The problem was me.</p><p>I was storing a one-time navigation event inside my UI state.</p><p>Once I separated <strong>state</strong> from <strong>events</strong>, the bug disappeared.</p><h3>Takeaway</h3><blockquote><strong><em>State stays. Events happen.</em></strong></blockquote><blockquote><em>Never mix the two.</em></blockquote><h3>Lesson 5 — Don’t Catch Every Exception</h3><blockquote><em>catch (Exception) isn&#39;t error handling. It&#39;s hiding information.</em></blockquote><h3>❌ Don’t</h3><pre>try {<br>    repository.fetchProfile()<br>} catch (e: Exception) {<br>    showError()<br>}</pre><p>Every failure becomes the same.</p><p>No internet?</p><p>Server error?</p><p>401?</p><p>Timeout?</p><p>JSON parsing?</p><p>Your app has no idea.</p><h3>✅ Do</h3><pre>when (val result = repository.fetchProfile()) {<br>    is Result.Success -&gt; {<br>        _uiState.update {<br>            it.copy(profile = result.data)<br>        }<br>    }<br>    is Result.NetworkError -&gt; {<br>        showNoInternet()<br>    }<br>    is Result.Unauthorized -&gt; {<br>        logoutUser()<br>    }<br>    is Result.ServerError -&gt; {<br>        showRetry()<br>    }<br>}</pre><p>Or expose a sealed result from your Repository.</p><pre>sealed interface Result&lt;out T&gt; {<br>    data class Success&lt;T&gt;(<br>          val data: T<br>      ) : Result&lt;T&gt;<br>     data object NetworkError : Result&lt;Nothing&gt;<br>     data object Unauthorized : Result&lt;Nothing&gt;<br>     data object ServerError : Result&lt;Nothing&gt;<br>}</pre><h3>Why?</h3><p>Users don’t care that an exception happened.</p><p>They care whether your app knows what to do next.</p><p>Different failures deserve different experiences.</p><p>Not every error should display:</p><blockquote><em>“Something went wrong.”</em></blockquote><h3>How I Learned This</h3><p>One production issue changed my perspective.</p><p>Users kept reporting:</p><blockquote><em>“The app isn’t working.”</em></blockquote><p>Crash analytics showed almost nothing useful.</p><p>Everything was swallowed inside:</p><pre>catch (Exception)</pre><p>We knew something failed.</p><p>We had no idea <strong>what</strong> failed.</p><p>That was the day I stopped treating every exception the same.</p><h3>Takeaway</h3><blockquote><em>Errors are part of your application’s design.</em></blockquote><blockquote><em>Don’t treat them as an afterthought.</em></blockquote><h3>Lesson 6 — Stop Writing Everything Inside Composables</h3><blockquote><em>A composable should describe the UI — not become your ViewModel.</em></blockquote><h3>❌ Don’t</h3><pre>@Composable<br>fun ProfileScreen() {<br><br>    val repository = UserRepository()<br>    var loading by remember {<br>        mutableStateOf(false)<br>    }<br>    LaunchedEffect(Unit) {<br>        loading = true<br>        repository.fetchProfile()<br>        loading = false<br>    }<br>    // Entire screen...<br>}</pre><h3>✅ Do</h3><pre>@Composable<br>fun ProfileScreen(<br>    uiState: ProfileUiState,<br>    onRetry: () -&gt; Unit<br>) {<br>  when {<br>        uiState.loading -&gt; LoadingView()<br>        uiState.error != null -&gt;<br>            ErrorView(onRetry)<br>        else -&gt;<br>            ProfileContent(uiState.profile)<br>    }<br>}</pre><p>Your ViewModel owns the business logic.</p><p>Your Composable describes the UI.</p><h3>Why?</h3><p>When business logic starts creeping into Composables:</p><ul><li>Preview becomes difficult.</li><li>Testing becomes harder.</li><li>Reusability disappears.</li><li>Every screen turns into a giant function.</li></ul><p>Compose is powerful because UI becomes easy to compose.</p><p>Not because everything lives inside one function.</p><h3>How I Learned This</h3><p>When I first moved from XML to Compose, I treated every Composable like an Activity.</p><p>Network calls.</p><p>Repositories.</p><p>State management.</p><p>Navigation.</p><p>Everything lived together.</p><p>The code worked.</p><p>But previews stopped working.</p><p>Reusable components disappeared.</p><p>Even simple UI changes felt risky.</p><p>Eventually I realized something.</p><p>Compose isn’t just XML written in Kotlin.</p><p>It’s a completely different way of thinking.</p><p>Once I started keeping Composables stateless and focused on rendering UI, everything became simpler.</p><h3>Takeaway</h3><blockquote><strong><em>Composable functions should render UI.</em></strong></blockquote><blockquote><em>Business logic belongs somewhere else.</em></blockquote><h3>Lesson 7 — Testing Doesn’t Slow You Down. Debugging Does.</h3><blockquote><em>Write tests for business logic. Your future self will thank you.</em></blockquote><h3>❌ Don’t</h3><pre>// &quot;I&#39;ll test it manually.&quot;<br>// &quot;QA will catch it.&quot;<br>// &quot;It&#39;s a small change.&quot;</pre><p>We’ve all said this.</p><h3>✅ Do</h3><pre>class LoginViewModelTest {<br>    @Test<br>    fun `login success updates ui state`() = runTest {<br>        val repository = FakeAuthRepository(<br>            Result.Success(User(&quot;Mukesh&quot;))<br>        )<br>        val viewModel = LoginViewModel(repository)<br>        viewModel.login()<br>        assertEquals(<br>            &quot;Mukesh&quot;,<br>            viewModel.uiState.value.user?.name<br>        )<br>    }<br>}</pre><h3>Why?</h3><p>Here’s something I wish someone had told me earlier:</p><blockquote><strong><em>Tests don’t prove your code works.</em></strong></blockquote><blockquote><strong><em>They prove your next change won’t break it.</em></strong></blockquote><p>The first version of any feature is usually easy.</p><p>The fifth modification isn’t.</p><p>Without tests, every refactor feels risky.</p><p>You don’t know what you’re about to break.</p><p>With tests, refactoring becomes much less stressful.</p><h3>How I Learned This</h3><p>I once had to modify a feature I had written almost a year earlier.</p><p>It looked simple.</p><p>A two-line change.</p><p>Instead, it broke three unrelated flows.</p><p>Not because the change was difficult.</p><p>Because I had no confidence.</p><p>Every fix created another bug.</p><p>That was the moment I stopped thinking of tests as “extra work.”</p><p>Now I think of them as insurance.</p><h3>Takeaway</h3><blockquote><em>If you’re short on time, don’t test everything.</em></blockquote><blockquote><em>Test the business logic that would hurt the most if it broke.</em></blockquote><h3>Lesson 8 — Measure Performance. Don’t Guess.</h3><blockquote><em>If you haven’t measured it, you don’t know it’s slow.</em></blockquote><h3>❌ Don’t</h3><pre>&quot;This RecyclerView is probably slow.&quot;<br>&quot;I think Compose is causing lag.&quot;<br>&quot;Let&#39;s optimize everything.&quot;</pre><h3>✅ Do</h3><p>Use tools before making assumptions.</p><ul><li>Layout Inspector</li><li>CPU Profiler</li><li>Memory Profiler</li><li>Macrobenchmark</li><li>Baseline Profiles</li><li>LeakCanary</li></ul><p>Measure first.</p><p>Optimize second.</p><h3>Why?</h3><p>Developers are surprisingly bad at guessing performance problems.</p><p>I’ve blamed Compose when the real issue was an unnecessary API call.</p><p>I’ve blamed Retrofit when the real issue was image loading.</p><p>I’ve blamed animations when the real issue was blocking the main thread.</p><p>The profiler almost always tells a different story.</p><h3>How I Learned This</h3><p>I spent almost an entire day optimizing a screen that “felt slow.”</p><p>I removed unnecessary objects.</p><p>Simplified code.</p><p>Reduced allocations.</p><p>Nothing changed.</p><p>Finally, I opened the profiler.</p><p>Turns out…</p><p>A huge bitmap was being decoded on the main thread.</p><p>Five minutes later, the issue was fixed.</p><p>The optimization I spent hours on?</p><p>It never mattered.</p><h3>Takeaway</h3><blockquote><em>Never optimize based on feelings.</em></blockquote><blockquote><em>Optimize based on data.</em></blockquote><h3>Lesson 9 — Clean Code Isn’t About Following Rules</h3><blockquote><em>Clean code is code that’s easy to change.</em></blockquote><h3>❌ Don’t</h3><p>Obsess over rules like:</p><ul><li>Function must be under 20 lines.</li><li>Every class needs an interface.</li><li>Everything should be abstract.</li><li>Every file should follow the same template.</li></ul><p>Those are guidelines.</p><p>Not laws.</p><h3>✅ Do</h3><p>Instead, ask yourself:</p><ul><li>Is this readable?</li><li>Is this testable?</li><li>Is it obvious why this code exists?</li><li>Can someone modify this without breaking everything?</li></ul><p>That’s what actually matters.</p><h3>Why?</h3><p>Early in my career, I thought Clean Code was about formatting.</p><p>Perfect folder structures.</p><p>Perfect naming.</p><p>Perfect architecture.</p><p>Then I worked on projects where everything looked beautiful…</p><p>…but changing one feature required editing fifteen files.</p><p>That’s not clean.</p><p>That’s complicated.</p><p>Good code reduces cognitive load.</p><p>It doesn’t increase it.</p><h3>How I Learned This</h3><p>One senior engineer once told me something I’ll never forget.</p><blockquote><strong><em>“Your code isn’t clean because it follows SOLID.</em></strong></blockquote><blockquote><strong><em>It’s clean because I don’t need to ask you questions while reading it.”</em></strong></blockquote><p>That completely changed how I review my own code.</p><h3>Takeaway</h3><blockquote><em>Clean code isn’t for the compiler.</em></blockquote><blockquote><em>It’s for the next developer reading it.</em></blockquote><h3>Lesson 10 — Writing Code Is Only Half the Job</h3><blockquote><em>Great engineers don’t just write code.</em></blockquote><blockquote><em>They make everyone else’s job easier.</em></blockquote><h3>Early in my career, I thought my responsibilities ended here:</h3><ul><li>Finish the feature.</li><li>Raise the Pull Request.</li><li>Resolve comments.</li><li>Merge.</li></ul><p>Done.</p><p>Now I think very differently.</p><p>Before I consider any task complete, I ask myself:</p><ul><li>Can QA test this easily?</li><li>Can another developer extend this feature?</li><li>Are the logs useful?</li><li>Will debugging this be easy?</li><li>Does the next person understand what I was thinking?</li></ul><p>Those questions rarely add more than a few minutes.</p><p>But they save hours later.</p><h3>How I Learned This</h3><p>One day I had to investigate a production issue.</p><p>The original developer had already left the company.</p><p>No logs.</p><p>No comments.</p><p>No documentation.</p><p>No tests.</p><p>No clear architecture.</p><p>It took two days to understand what the code was even trying to do.</p><p>A few months later…</p><p>I opened another feature written by a different engineer.</p><p>Everything made sense.</p><p>Clear naming.</p><p>Small functions.</p><p>Helpful logs.</p><p>Tests.</p><p>I fixed the issue in under thirty minutes.</p><p>Same company.</p><p>Same codebase.</p><p>Completely different engineering mindset.</p><p>That’s when I realized something.</p><blockquote><strong><em>The best engineers don’t just optimize code.</em></strong></blockquote><blockquote><strong><em>They optimize collaboration.</em></strong></blockquote><h3>Takeaway</h3><blockquote><em>Every line of code you write becomes someone else’s responsibility.</em></blockquote><blockquote><em>Write it with that person in mind.</em></blockquote><h3>Final Thoughts</h3><p>When I started writing Android apps, I believed becoming a better developer meant learning more libraries.</p><p>Today, I think differently.</p><p>The biggest improvements in my career didn’t come from learning another Jetpack library.</p><p>They came from changing the way I thought.</p><p>The mistakes in this article weren’t failures.</p><p>They were milestones.</p><p>Each bug made me more careful.</p><p>Each code review made me a better teammate.</p><p>Each production issue taught me something no tutorial ever could.</p><p>If you’re just starting your Android journey, you’ll probably make some of these mistakes too.</p><p>That’s okay.</p><p>Everyone does.</p><p>The goal isn’t to write perfect code.</p><p>The goal is to make fewer mistakes than you did yesterday.</p><p>And if you keep doing that consistently…</p><p>You’ll wake up one day and realize you’ve become the engineer your junior self looked up to.</p><h3>Quick Recap</h3><p>✅ Don’t use GlobalScope for UI work.</p><p>✅ Keep ViewModels focused.</p><p>✅ Expose immutable state.</p><p>✅ State ≠ Events.</p><p>✅ Handle errors intentionally.</p><p>✅ Keep Composables responsible for UI.</p><p>✅ Test business logic.</p><p>✅ Measure before optimizing.</p><p>✅ Clean code is maintainable code.</p><p>✅ Great engineers optimize for the next developer — not just the current feature.</p><h3>Thanks for reading! 👋</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2bacb9814d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android in 2026: If You Aren’t Using AppFunctions, Are You Even a Senior Dev? ]]></title>
            <link>https://mukesh-yadav.medium.com/android-in-2026-if-you-arent-using-appfunctions-are-you-even-a-senior-dev-3a87b05b826a?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a87b05b826a</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Thu, 16 Apr 2026 13:09:10 GMT</pubDate>
            <atom:updated>2026-04-16T13:09:10.132Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Google Gemini Live on Pixel 9 Pro XL - AI voice" src="https://cdn-images-1.medium.com/max/1024/0*ys_zeqr1DJysurSt" /><figcaption>Photo by <a href="https://unsplash.com/@amanz?utm_source=medium&amp;utm_medium=referral">Amanz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s be honest. If we are still talking about just RecyclerViews or basic Jetpack Compose in 2026, we are living in the past. 🦖<br>The game has shifted. Android 17 and the latest <strong>Android Studio Ladybug (2026.1.1)</strong> have introduced something that actually makes our lives easier and our apps &quot;<em>Agent-ready</em>&quot;: <strong>AppFunctions</strong>.<br>In this post, let’s deep dive into how to architect your app so that AI Agents (like Gemini) can actually use your features without even opening your UI.</p><p><strong>1.</strong> <strong>The Core Concept</strong>: What is <strong>AppFunction</strong>? 🧠<br>Earlier, we used App Actions or Intents. In 2026, <strong>AppFunctions</strong> allow you to expose specific business logic of your app to the system.<br>Imagine a user saying, &quot;<em>Gemini, track my 5km run in [YourApp].</em>&quot; Your app doesn’t need to open; your <strong>TrackRunFunction</strong> executes in the background.</p><p><strong>2. Setting Up the Schema</strong> 📂<br>First, we need to define our function. We don’t just write a method; we annotate it so the <strong>AppFunction Compiler</strong> can understand it.<br>File: <em>build.gradle.kts</em></p><pre>dependencies {<br>    // The 2026 Essential<br>    implementation(&quot;androidx.appfunctions:appfunctions-compiler:1.1.0-alpha05&quot;)<br>    implementation(&quot;androidx.appfunctions:appfunctions-core:1.1.0-alpha05&quot;)<br>}</pre><p><strong>3. The Implementation:</strong> Let’s Write Some Real Code 💻<br>Instead of burying logic inside a <em>ViewModel</em>, we move the &quot;<em>executable</em>&quot; part to a dedicated class.<br>File: <em>features/tracking/TrackingFunctions.kt</em></p><pre>import androidx.appfunctions.AppFunction<br>import androidx.appfunctions.AppFunctionContext<br><br>class FitnessFunctions {<br><br>    /**<br>     * Exposing a core feature to the Android System.<br>     * Even a Senior Dev needs to keep it idempotent! 🛠️<br>     */<br>    @AppFunction<br>    fun trackWorkout(context: AppFunctionContext, distance: Double, type: String): String {<br>        // High-level Logic: Imagine calling a Repository here<br>        val success = WorkoutRepository.start(distance, type)<br>        <br>        return if (success) {<br>            &quot;Started tracking your $distance km $type. Let&#39;s crush it! 💪&quot;<br>        } else {<br>            &quot;Failed to start. Maybe check your GPS? 🛰️&quot;<br>        }<br>    }<br>}<br><br></pre><p><strong>4. Why this matters for Senior Devs?</strong> 🧐<br>If you are looking at this and thinking, &quot;It’s just a function,&quot; look closer.<br><strong>Decoupling</strong>: Your UI (Compose) and your Logic <strong>(AppFunction)</strong> are now truly separate.<br><strong>Discoverability</strong>: The OS indexes this. Your app becomes part of the global Android Intelligence layer.<br><strong>Efficiency</strong>: No need to handle complex <strong>DeepLink</strong> routing for simple actions.</p><p><strong>5. Integration with Android Studio 2026</strong> 🐝<br>The new <strong>AppFunction</strong> Inspector in Android Studio allows you to test these triggers without even building a mock UI.</p><p><strong>Pro-Tip</strong>: Use the &quot;Agent Simulator&quot; in the bottom panel to see how Gemini interprets your function parameters. If your naming is bad (like fun <em>doStuff())</em>, the AI will fail. Use semantic naming!</p><p><strong>Final Thoughts </strong>💡<br>Android development in 2026 isn’t about how many screens you have. It’s about how many capabilities you expose. Stop building silos; start building functions.</p><p><strong>Next steps for you:</strong><br>Refactor your &quot;<strong>Action</strong>&quot; logic into <em>AppFunction</em> classes.<br>Test them using the new CLI tools.<br><em>Drink more coffee. </em>☕<br>#AndroidDev #Kotlin #AppFunctions #Android17 #MobileArchitecture #SeniorEngineer</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a87b05b826a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scaling Android Apps with AARs & Multi-Repo Integration — A Practical Guide]]></title>
            <link>https://mukesh-yadav.medium.com/scaling-android-apps-with-aars-multi-repo-integration-a-practical-guide-235d7eff7f5e?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/235d7eff7f5e</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[google-play-store]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Mon, 08 Sep 2025 17:19:22 GMT</pubDate>
            <atom:updated>2025-09-08T17:19:22.266Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scaling Android Apps with AARs &amp; Multi-Repo Integration — A Practical Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*zZ2hPUoQKZ7bh0tnA2SQQQ.png" /></figure><p>As Android apps grow, you start facing big challenges:</p><ul><li>Your <strong>login</strong>, <strong>payments</strong>, and <strong>transfer</strong> modules all live in the same repo → chaos.</li><li>Teams want to work independently → frequent conflicts.</li><li>You want to share <strong>reusable SDKs</strong> without copy-pasting code.</li></ul><p>Enter <strong>AARs</strong> and <strong>multi-repo integration</strong>. This guide will show you <strong>how, why, and when</strong> to use both — with full working examples.</p><h3>📦 Part 1: What is an AAR?</h3><p><strong>AAR (Android ARchive)</strong> is like a .jar for Android but richer:</p><ul><li>Contains <strong>code</strong>, <strong>resources</strong>, and <strong>manifest entries</strong>.</li><li>Can include Activities, Services, BroadcastReceivers, but <strong>cannot run standalone</strong>.</li><li>Common use: shipping reusable SDKs (login, payments, analytics) to other teams.</li></ul><h3>🔹 Example: Login Module as an AAR</h3><p><strong>Project Structure</strong></p><pre>MyProject/<br>├── app/           // Host app<br>└── loginlib/      // Library module (produces AAR)</pre><p><strong>loginlib/build.gradle.kts</strong></p><pre>plugins {<br>    id(&quot;com.android.library&quot;)<br>    id(&quot;org.jetbrains.kotlin.android&quot;)<br>}<br><br>android {<br>    namespace = &quot;com.example.loginlib&quot;<br>    compileSdk = 34<br>    defaultConfig { minSdk = 24 }<br>}<br><br>dependencies {<br>    implementation(&quot;androidx.core:core-ktx:1.13.1&quot;)<br>}</pre><p><strong>loginlib/src/main/AndroidManifest.xml</strong></p><pre>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    package=&quot;com.example.loginlib&quot;&gt;<br>    &lt;application&gt;<br>        &lt;activity android:name=&quot;.LoginActivity&quot; android:exported=&quot;true&quot;/&gt;<br>    &lt;/application&gt;<br>&lt;/manifest&gt;</pre><p><strong>loginlib/src/main/java/com/example/loginlib/LoginActivity.kt</strong></p><pre>package com.example.loginlib<br>import android.os.Bundle<br>import androidx.appcompat.app.AppCompatActivity<br>import android.widget.*<br>class LoginActivity : AppCompatActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br><br>        val layout = LinearLayout(this).apply { orientation = LinearLayout.VERTICAL }<br>        val username = EditText(this).apply { hint = &quot;Username&quot; }<br>        val password = EditText(this).apply { hint = &quot;Password&quot; }<br>        val btn = Button(this).apply { text = &quot;Login&quot; }<br>    <br>        btn.setOnClickListener {<br>            Toast.makeText(this, &quot;Hello ${username.text}&quot;, Toast.LENGTH_SHORT).show()<br>        }<br>        <br>        layout.addView(username)<br>        layout.addView(password)<br>        layout.addView(btn)<br>        setContentView(layout)<br>    }<br>}</pre><p><strong>Build the AAR</strong></p><pre>./gradlew :loginlib:assembleRelease</pre><p>Output:</p><pre>loginlib/build/outputs/aar/loginlib-release.aar</pre><p><strong>Consume in another app</strong></p><pre>implementation(files(&quot;libs/loginlib-release.aar&quot;))<br><br>startActivity(Intent(this, com.example.loginlib.LoginActivity::class.java))</pre><h3>🔹 Why plugins are repeated?</h3><ul><li><strong>Root </strong><strong>build.gradle.kts</strong></li></ul><pre>plugins {<br>    id(&quot;com.android.application&quot;) version &quot;8.4.0&quot; apply false<br>    id(&quot;com.android.library&quot;) version &quot;8.4.0&quot; apply false<br>    id(&quot;org.jetbrains.kotlin.android&quot;) version &quot;1.9.24&quot; apply false<br>}</pre><p>Declares <strong>plugin versions</strong> globally (no immediate application).</p><ul><li><strong>Module </strong><strong>build.gradle.kts</strong></li></ul><pre>plugins {<br>    id(&quot;com.android.library&quot;)<br>    id(&quot;org.jetbrains.kotlin.android&quot;)<br>}</pre><p>Actually <strong>applies the plugin</strong> to that module.</p><ul><li><strong>settings.gradle.kts</strong></li></ul><pre>include(&quot;:app&quot;, &quot;:loginlib&quot;)</pre><p>Declares <strong>which modules exist</strong> in the project.</p><p>✅ Root = versions, Settings = modules, Module = apply plugin.</p><h3>🏗️ Part 2: Multi-Repo Integration</h3><p>Large teams often maintain separate repos:</p><ul><li>login-service</li><li>payment-service</li><li>transfer-service</li></ul><p>We want to <strong>integrate these repos without publishing AARs every change</strong>.</p><h3>🔹 Option 1: Git Submodules</h3><pre>git submodule add https://github.com/org/payment-service libs/payment</pre><p>settings.gradle.kts</p><pre>include(&quot;:app&quot;, &quot;:payment&quot;)<br>project(&quot;:payment&quot;).projectDir = file(&quot;libs/payment&quot;)</pre><p>Now :app directly depends on the <strong>source code</strong> of payment module. No AAR required, immediate reflection of changes.</p><h3>🔹 Option 2: Gradle Composite Builds</h3><p>Modern and cleaner solution. In your settings.gradle.kts:</p><pre>include(&quot;:app&quot;)<br><br>includeBuild(&quot;../payment-service&quot;) {<br>    dependencySubstitution {<br>        substitute(module(&quot;com.example:payment&quot;))<br>            .using(project(&quot;:payment&quot;))<br>    }<br>}</pre><ul><li>If payment-service repo exists locally → Gradle uses it.</li><li>Otherwise → Gradle fetches published artifact.</li></ul><p>This allows <strong>fast iteration + versioned fallback</strong>.</p><h3>🎯 When to Use What</h3><p><strong>AAR</strong> <br>Ship stable, versioned SDKs (Login SDK, Payments SDK) for external teams.</p><p><strong>Multi-Repo<br></strong>Independent repos need frequent changes integrated into main app (Login, Payment, Transfer).</p><h3>🧑‍💻 Interview Tips</h3><p><strong>Q: Why repeat plugins across root and modules?</strong></p><ul><li>Root = version management</li><li>Module = actual application</li></ul><p><strong>Q: Why AAR vs multi-repo?</strong></p><ul><li>AAR = stable SDK distribution</li><li>Multi-repo = active collaboration without publishing</li></ul><p><strong>Q: Can AAR contain Activities?</strong></p><ul><li>Yes, but host app decides when to launch them.</li></ul><p><strong>Q: How do you scale Android apps for multiple teams?</strong></p><ul><li>Use <strong>AARs</strong> for stable SDKs</li><li>Use <strong>multi-repo integration</strong> for active development</li><li>Combine both → stable releases + flexible dev workflow</li></ul><p>💡 Next time you’re building a <strong>Login + Payment + Transfer module</strong> for your billion-user app, ask:</p><blockquote><em>“Do I want this feature as a reusable SDK (AAR) or active source module (multi-repo)?”</em></blockquote><p>That decision will dictate your project structure, build system, and collaboration workflow. 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=235d7eff7f5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interview question: “How to Secure Android Applications and Build Apps for a Billion Users” ]]></title>
            <link>https://mukesh-yadav.medium.com/interview-question-how-to-secure-android-applications-and-build-apps-for-a-billion-users-babdb286db13?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/babdb286db13</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[architecture]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Sun, 07 Sep 2025 10:33:48 GMT</pubDate>
            <atom:updated>2025-09-07T10:33:48.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VS4chMylsBXOd1Cw.png" /></figure><p>When preparing for senior Android interviews, one question often comes up:</p><blockquote><strong><em>“How would you secure an Android application and make it scalable for a billion users?”</em></strong></blockquote><p>This is a loaded question, touching <strong>security</strong>, <strong>performance</strong>, and <strong>scalability</strong>. Below, we’ll break it down in a <strong>Q&amp;A format</strong> so you can answer confidently in interviews and apply best practices in real-world projects.</p><h3>🔐 Security Best Practices</h3><h3>Q1. How do you protect against MITM (Man-In-The-Middle) attacks?</h3><ul><li>Always use <strong>HTTPS (TLS 1.2/1.3)</strong>.</li><li>Implement <strong>SSL Pinning</strong> (certificate or public key pinning).</li></ul><p>📌 Example using <strong>OkHttp with SSL pinning</strong>:</p><pre>val certificatePinner = CertificatePinner.Builder()<br>    .add(&quot;yourdomain.com&quot;, &quot;sha256/AAAAAAAAAAAAAAAAAAAAA...&quot;)<br>    .build()<br><br>val okHttpClient = OkHttpClient.Builder()<br>    .certificatePinner(certificatePinner)<br>    .build()</pre><p>If you use <strong>Apollo GraphQL / Retrofit</strong>, inject this okHttpClient.</p><h3>Q2. How do you secure API communication?</h3><ul><li>Use <strong>OAuth 2.0 / JWT</strong> for authentication.</li><li>Add <strong>HMAC signature</strong> for sensitive APIs.</li><li>Always send <strong>tokens in headers</strong>, never in query params.</li><li>Rotate API keys regularly.</li></ul><p>📌 Example of signed request:</p><pre>val timestamp = System.currentTimeMillis().toString()<br>val dataToSign = &quot;$timestamp:$userId&quot;<br>val signature = hmacSha256(secretKey, dataToSign)<br><br>val request = Request.Builder()<br>    .url(https://medium.com/&quot;https://api.bank.com/secure&quot;)<br>    .addHeader(&quot;X-Timestamp&quot;, timestamp)<br>    .addHeader(&quot;X-Signature&quot;, signature)<br>    .build()</pre><h3>Q3. How do you protect sensitive data locally?</h3><ul><li>Use <strong>EncryptedSharedPreferences</strong> or <strong>EncryptedFile</strong>.</li><li>Never store raw tokens or passwords.</li><li>Use <strong>SQLCipher</strong> for Room DB.</li></ul><p>📌 Example:</p><pre>val masterKey = MasterKey.Builder(context)<br>    .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)<br>    .build()<br><br>val sharedPrefs = EncryptedSharedPreferences.create(<br>    context,<br>    &quot;secure_prefs&quot;,<br>    masterKey,<br>    EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,<br>    EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM<br>)</pre><h3>Q4. How do you prevent reverse engineering?</h3><ul><li>Enable <strong>R8 + ProGuard</strong> (obfuscation &amp; shrinking).</li><li>Use <strong>NDK (C++ native code)</strong> for sensitive logic.</li><li>Sign builds with <strong>Play App Signing</strong>.</li></ul><p>📌 proguard-rules.pro example:</p><pre>-dontwarn javax.annotation.**<br>-keep class com.bank.app.** { *; }</pre><h3>Q5. How do you prevent memory leaks?</h3><ul><li>Use <strong>LeakCanary</strong> for detection.</li><li>Avoid holding references to Context in singletons.</li><li>Prefer viewLifecycleOwner.lifecycleScope over GlobalScope.</li></ul><p>📌 Example:</p><pre>viewLifecycleOwner.lifecycleScope.launch {<br>    viewModel.loadData()<br>}</pre><h3>⚡ Performance &amp; Scalability</h3><h3>Q6. How do you keep app size small?</h3><ul><li>Use <strong>R8</strong> (shrinker + optimizer).</li><li>Split APKs by ABI (abiFilters).</li><li>Use <strong>VectorDrawables</strong> instead of PNGs.</li></ul><p>📌 build.gradle:</p><pre>android {<br>    defaultConfig {<br>        ndk {<br>            abiFilters &quot;armeabi-v7a&quot;, &quot;arm64-v8a&quot;<br>        }<br>    }<br>    buildFeatures {<br>        shrinkResources true<br>    }<br>}</pre><h3>Q7. How do you handle background tasks securely &amp; efficiently?</h3><ul><li>Use <strong>WorkManager</strong> for retryable, persistent tasks.</li><li>Use <strong>Coroutines</strong> for lightweight async work.</li></ul><p>📌 Example:</p><pre>class SyncWorker(appContext: Context, params: WorkerParameters) :<br>    CoroutineWorker(appContext, params) {<br>    override suspend fun doWork(): Result {<br>        return try {<br>            api.syncSecureData()<br>            Result.success()<br>        } catch (e: Exception) {<br>            Result.retry()<br>        }<br>    }<br>}</pre><h3>Q8. How do you handle permissions?</h3><ul><li>Request permissions <strong>just-in-time</strong>, not at launch.</li><li>Never ask unnecessary permissions.</li><li>Use <strong>scoped storage</strong> for file access.</li></ul><p>📌 Example:</p><pre>ActivityResultContracts.RequestPermission()</pre><h3>Q9. How do you build responsive UIs for billions of users?</h3><ul><li>Use <strong>Jetpack Compose</strong> (lightweight &amp; declarative).</li><li>Handle different screen sizes &amp; orientations.</li><li>Use <strong>LazyColumn / Paging3</strong> for large datasets.</li></ul><p>📌 Example with Paging3 + Compose:</p><pre>val pager = Pager(PagingConfig(pageSize = 20)) {<br>    UserPagingSource(api)<br>}<br><br>val lazyPagingItems = pager.flow.collectAsLazyPagingItems()<br><br>LazyColumn {<br>    items(lazyPagingItems) { user -&gt;<br>        Text(user.name)<br>    }<br>}</pre><h3>🏦 Additional Banking/Payment Guidelines</h3><ol><li><strong>Disable screenshots</strong> for sensitive screens:</li></ol><pre>window.setFlags(<br>  WindowManager.LayoutParams.FLAG_SECURE,<br>  WindowManager.LayoutParams.FLAG_SECURE<br>)</pre><ol><li><strong>Detect root/jailbreak devices</strong> and block transactions.</li><li><strong>Monitor app integrity</strong> (SafetyNet / Play Integrity API).</li><li><strong>Multi-factor authentication (MFA)</strong> for high-value transactions.</li><li><strong>Session timeout &amp; re-authentication</strong> for critical flows.</li><li><strong>Crash-free experience</strong> → Billion-user apps can’t afford crashes. Use Crashlytics.</li></ol><h3>✅ Interview Tip</h3><p>When asked <em>“How to secure and scale an Android app for a billion users?”</em>, structure your answer like this:</p><ol><li><strong>Secure Communication</strong> → HTTPS, SSL Pinning, signed requests.</li><li><strong>Secure Local Data</strong> → EncryptedSharedPreferences, SQLCipher.</li><li><strong>Reverse Engineering Protection</strong> → Obfuscation, NDK.</li><li><strong>Memory &amp; Performance</strong> → LeakCanary, R8, WorkManager, Paging.</li><li><strong>User Privacy &amp; Permissions</strong> → Ask minimally, scoped storage.</li><li><strong>UI &amp; UX</strong> → Jetpack Compose, responsive, offline-first.</li><li><strong>Banking-specific</strong> → FLAG_SECURE, root detection, Play Integrity.</li></ol><p>This <strong>systematic answer</strong> will impress interviewers.</p><p>👉 Here’s an <strong>ASCII diagram </strong>and <strong>PNG </strong>diagram</p><pre>                    ┌──────────────────────────────────┐<br>                    │          Secure Banking App      │<br>                    └──────────────────────────────────┘<br>                                 │<br>          ┌──────────────────────┼──────────────────────┐<br>          │                      │                      │<br>   ┌─────────────┐        ┌─────────────┐        ┌───────────────┐<br>   │   UI Layer  │        │ Data Layer  │        │ Security Layer │<br>   └─────────────┘        └─────────────┘        └───────────────┘<br>          │                      │                      │<br> ┌───────────────────┐   ┌─────────────────────┐  ┌──────────────────────┐<br> │ Jetpack Compose   │   │ Repository Pattern  │  │ SSL Pinning / HMAC   │<br> │ Responsive &amp;      │   │ UserRepo, TxRepo    │  │ Play Integrity API   │<br> │ Accessible UI     │   │                     │  │ Root/Jailbreak check │<br> └───────────────────┘   └─────────────────────┘  └──────────────────────┘<br>          │                      │                      │<br> ┌───────────────────┐   ┌─────────────────────┐  ┌──────────────────────┐<br> │ Paging3 / LazyCol │   │ Room (SQLCipher)    │  │ EncryptedSharedPrefs │<br> │ WorkManager for   │   │ Encrypted local DB   │  │ FLAG_SECURE Screens  │<br> │ background sync   │   │ Caching &amp; Offline    │  │ ProGuard / R8        │<br> └───────────────────┘   └─────────────────────┘  └──────────────────────┘<br>                                 │<br>                      ┌────────────────────────────┐<br>                      │     Network Layer (API)    │<br>                      │  OkHttp + Retrofit/Apollo  │<br>                      │  - HTTPS (TLS 1.3)         │<br>                      │  - Signed Requests (JWT)   │<br>                      │  - Rate Limiting           │<br>                      └────────────────────────────┘<br>                                 │<br>                      ┌────────────────────────────┐<br>                      │   Backend Services (Bank)  │<br>                      │  - Identity/Auth (OAuth2)  │<br>                      │  - Transaction Service     │<br>                      │  - Fraud Detection Engine  │<br>                      └────────────────────────────┘</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*C9sLuMEFxTv6UVK-sijWdg.png" /></figure><h3>🔑 Key Takeaways from the Diagram:</h3><ol><li><strong>UI Layer</strong> → Jetpack Compose ensures responsive UI; FLAG_SECURE protects sensitive screens.</li><li><strong>Data Layer</strong> → Repository pattern abstracts API/DB, while Room with SQLCipher secures local storage.</li><li><strong>Security Layer</strong> → SSL Pinning, HMAC signatures, Play Integrity, and EncryptedSharedPrefs guard against attacks.</li><li><strong>Background Work</strong> → WorkManager handles secure retries (e.g., transaction sync).</li><li><strong>Network Layer</strong> → Uses OkHttp + Retrofit/Apollo with HTTPS, JWT, and signed requests.</li><li><strong>Backend</strong> → OAuth2 for authentication, fraud detection, and transaction validation.</li></ol><p>Thanks ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=babdb286db13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Push Notification vs  Deep Link in Android — Complete Guide with End-to-End Code]]></title>
            <link>https://mukesh-yadav.medium.com/push-notification-vs-deep-link-in-android-complete-guide-with-end-to-end-code-72a03491e184?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/72a03491e184</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[deeplink]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[fcm]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Sun, 07 Sep 2025 10:03:21 GMT</pubDate>
            <atom:updated>2025-09-07T10:03:21.022Z</atom:updated>
            <content:encoded><![CDATA[<h3>📬 Push Notification vs 🔗 Deep Link in Android — Complete Guide with End-to-End Code</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tA2PUR89jBG2kSKB.png" /></figure><p>Mobile apps often need to bring users back into the app with context. Two powerful tools help us here:</p><ul><li><strong>Push Notifications</strong> (server-driven messages shown in system tray)</li><li><strong>Deep Links</strong> (URLs that open specific screens in your app)</li></ul><p>They may sound similar, but their roles are different. And in practice, they often work <em>together</em>.</p><p>In this post, we’ll cover:</p><p>🔍 What Push Notifications and Deep Links are<br> ⚡ When to use each<br> 🏗️ Complete implementation (with latest code)<br> 📜 Manifest changes required<br> 🧠 Interview-ready insights</p><h3>🔍 Push Notifications — What &amp; Why</h3><p>A <strong>push notification</strong> is a message sent from a server to the user’s device. It’s shown even if the app is in background or killed.</p><p><strong>Use cases:</strong></p><ul><li>Reminders (“Your order is ready 🚚”)</li><li>Promotions (“Flash sale: 50% off 🎉”)</li><li>Engagement (“New message from Alice 💬”)</li></ul><p>Under the hood, Android apps typically use <strong>Firebase Cloud Messaging (FCM)</strong>.</p><h3>🛠️ Implementation: Push Notifications with FCM</h3><h4>1. Add Firebase to your project</h4><ul><li>Go to <a href="https://console.firebase.google.com/">Firebase Console</a> → Create project.</li><li>Add Android app (provide package name).</li><li>Download google-services.json → place in app/.</li></ul><p>In <strong>project-level build.gradle</strong>:</p><pre>dependencies {<br>    classpath(&quot;com.google.gms:google-services:4.4.2&quot;)<br>}</pre><p>In <strong>app-level build.gradle</strong>:</p><pre>plugins {<br>    id(&quot;com.google.gms.google-services&quot;)<br>}<br><br>dependencies {<br>    implementation(&quot;com.google.firebase:firebase-messaging:24.0.0&quot;)<br>}</pre><h4>2. Configure Manifest</h4><pre>&lt;manifest&gt;<br>    &lt;application<br>        android:allowBackup=&quot;true&quot;<br>        android:supportsRtl=&quot;true&quot;<br>        android:theme=&quot;@style/Theme.MyApp&quot;&gt;<br>        &lt;!-- Firebase messaging service --&gt;<br>        &lt;service<br>            android:name=&quot;.MyFirebaseMessagingService&quot;<br>            android:exported=&quot;false&quot;&gt;<br>            &lt;intent-filter&gt;<br>                &lt;action android:name=&quot;com.google.firebase.MESSAGING_EVENT&quot; /&gt;<br>            &lt;/intent-filter&gt;<br>        &lt;/service&gt;<br>    &lt;/application&gt;<br>&lt;/manifest&gt;</pre><h4>3. Create Messaging Service</h4><pre>@HiltAndroidApp // if using Hilt<br>class MyApp : Application()<br>class MyFirebaseMessagingService : FirebaseMessagingService() {<br><br>   override fun onMessageReceived(remoteMessage: RemoteMessage) {<br>     super.onMessageReceived(remoteMessage)<br>         val title = remoteMessage.notification?.title ?: &quot;Default Title&quot;<br>         val body = remoteMessage.notification?.body ?: &quot;Default Body&quot;<br>         // Optional: Handle custom data<br>         val deepLink = remoteMessage.data[&quot;deeplink&quot;]<br>         showNotification(title, body, deepLink)<br>    }<br><br>   private fun showNotification(title: String, body: String, deepLink: String?) {<br>        val intent = if (deepLink != null) {<br>            Intent(Intent.ACTION_VIEW, Uri.parse(deepLink))<br>        } else {<br>            Intent(this, MainActivity::class.java)<br>        }<br>        <br>        val pendingIntent = PendingIntent.getActivity(<br>            this,<br>            0,<br>            intent,<br>            PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE<br>        )<br><br>        val channelId = &quot;my_channel_id&quot;<br>        val builder = NotificationCompat.Builder(this, channelId)<br>            .setSmallIcon(R.drawable.ic_notification)<br>            .setContentTitle(title)<br>            .setContentText(body)<br>            .setContentIntent(pendingIntent)<br>            .setAutoCancel(true)<br><br>        val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager<br>        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) {<br>            manager.createNotificationChannel(<br>                NotificationChannel(channelId, &quot;Default&quot;, NotificationManager.IMPORTANCE_HIGH)<br>            )<br>        }<br>        manager.notify(1, builder.build())<br>    }<br>}</pre><p>👉 Notice how we can attach a <strong>deep link</strong> so that tapping the notification opens a specific screen.</p><h3>🔗 Deep Links — What &amp; Why</h3><p>A <strong>deep link</strong> is a URI (like myapp://profile/123) that opens a specific screen in your app.</p><p><strong>Use cases:</strong></p><ul><li>Open product page directly from email campaign</li><li>Navigate to chat screen from a notification</li><li>Support universal links (like <a href="https://myapp.com/profile/123)">https://myapp.com/profile/123)</a></li></ul><h3>🛠️ Implementation: Deep Link</h3><h4>1. Add Intent Filter in Manifest</h4><pre>&lt;activity<br>    android:name=&quot;.MainActivity&quot;<br>    android:exported=&quot;true&quot;&gt;<br>    &lt;intent-filter android:autoVerify=&quot;true&quot;&gt;<br>        &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;<br>        &lt;!-- Custom scheme --&gt;<br>        &lt;data android:scheme=&quot;myapp&quot; android:host=&quot;profile&quot; /&gt;<br>        &lt;!-- App link --&gt;<br>        &lt;data android:scheme=&quot;https&quot; android:host=&quot;myapp.com&quot; android:pathPrefix=&quot;/profile&quot; /&gt;<br>    &lt;/intent-filter&gt;<br>&lt;/activity&gt;</pre><p>👉 This means:</p><ul><li>myapp://profile/123 will open the app.</li><li>https://myapp.com/profile/123 will also open the app (if verified).</li></ul><h4>2. Handle Deep Link in Activity</h4><pre>class MainActivity : ComponentActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        val uri = intent?.data<br>        if (uri != null) {<br>            when {<br>                uri.toString().startsWith(&quot;myapp://profile&quot;) ||<br>                uri.toString().startsWith(&quot;https://myapp.com/profile&quot;) -&gt; {<br>                    val userId = uri.lastPathSegment<br>                    navigateToProfile(userId)<br>                }<br>            }<br>        }<br>        setContent {<br>            MyApp()<br>        }<br>    }<br>    private fun navigateToProfile(userId: String?) {<br>        // Pass userId to your Compose Navigation graph<br>        Log.d(&quot;DeepLink&quot;, &quot;Open profile for userId=$userId&quot;)<br>    }<br>}</pre><h3>🎨 Push Notification + Deep Link Together</h3><p>This is where the magic happens.</p><ul><li>The <strong>server sends a push notification</strong> with a deeplink field in payload.</li><li>The <strong>app receives it</strong> in FirebaseMessagingService.</li><li>The notification <strong>launches a deep link</strong> when tapped.</li></ul><p>👉 This creates a seamless flow from <em>system tray → specific screen in app</em>.</p><h3>🧠 Interview Insights</h3><ul><li><strong>Push Notification</strong> = transport mechanism (server → device).</li><li><strong>Deep Link</strong> = navigation mechanism (intent → screen).</li><li>They often <strong>work together</strong>. Push drives re-engagement, deep link gives context.</li><li>Key Manifest points:</li><li>Push: register FirebaseMessagingService.</li><li>Deep link: add &lt;intent-filter&gt; with VIEW.</li><li>Security: validate incoming deep link URIs (to avoid malicious links).</li><li>Latest best practice: use <strong>Navigation Component’s deepLink support</strong> with Compose instead of manual parsing when possible.</li></ul><h3>📌 Final Thoughts</h3><ul><li>Use <strong>Push Notifications</strong> to re-engage users with timely updates.</li><li>Use <strong>Deep Links</strong> to land users in the right context.</li><li>Combine them for best UX: “New message from Alice” → tapping takes you straight to chat with Alice.</li></ul><p><strong>Push = bring user back. Deep Link = take them to the right place.</strong></p><p>Cheers 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72a03491e184" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Apollo GraphQL with Kotlin on Android — Queries & Mutations Made Easy]]></title>
            <link>https://mukesh-yadav.medium.com/apollo-graphql-with-kotlin-on-android-queries-mutations-made-easy-bcd60f31e38f?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcd60f31e38f</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[compose-ui]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Sun, 07 Sep 2025 09:34:56 GMT</pubDate>
            <atom:updated>2025-09-07T09:34:56.638Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Apollo GraphQL with Kotlin on Android — Queries &amp; Mutations Made Easy</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*GEOyBvSr2aPGySJC.jpg" /></figure><p>GraphQL has been gaining popularity because of its <strong>flexibility</strong>: you can ask the server for <em>exactly what you need</em>, nothing more, nothing less.</p><p>If you’re used to Retrofit for REST APIs, you’ll love using <strong>Apollo GraphQL Client</strong> with Kotlin — it gives you <strong>type-safe models</strong> directly from your .graphql queries.</p><p>In this post, we’ll cover:</p><p>🔍 Setting up Apollo in your project<br> 📂 Writing GraphQL queries &amp; mutations<br> ⚡ Building a repository for data access<br> 🎨 Using it in Jetpack Compose<br> 🧠 Best practices along the way</p><h3>🔧 Step 1: Add Apollo Dependencies</h3><p>In your <strong>app/build.gradle.kts</strong>:</p><pre>plugins {<br>    id(&quot;com.apollographql.apollo3&quot;).version(&quot;3.8.2&quot;) // latest Apollo version<br>    id(&quot;com.android.application&quot;)<br>    kotlin(&quot;android&quot;)<br>}<br><br>apollo {<br>    service(&quot;service&quot;) { // &quot;service&quot; can be any name<br>        packageName.set(&quot;com.example.graphql&quot;)<br>    }<br>}<br><br>dependencies {<br>    implementation(&quot;com.apollographql.apollo3:apollo-runtime:3.8.2&quot;)<br>}</pre><p>In your <strong>project-level build.gradle.kts</strong>:</p><pre>plugins {<br>    id(&quot;com.apollographql.apollo3&quot;).version(&quot;3.8.2&quot;) apply false<br>}</pre><p>👉 apply false here just means the plugin is declared globally but only applied in modules where you actually need it (like your Android app module).</p><h3>📂 Step 2: Create a GraphQL Query</h3><p>Inside: src/main/graphql/com/example/graphql/GetUsers.graphql</p><pre>query GetUsers {<br>  users {<br>    id<br>    name<br>    email<br>  }<br>}</pre><p>Apollo will automatically generate a <strong>GetUsersQuery</strong> class.</p><h3>🌐 Step 3: Setup Apollo Client</h3><p>Create a singleton for your Apollo Client (like you do with Retrofit):</p><pre>object ApolloInstance {<br>    private const val BASE_URL = &quot;https://your-api-url.com/graphql&quot;<br><br>    val apolloClient: ApolloClient by lazy {<br>        ApolloClient.Builder()<br>            .serverUrl(BASE_URL)<br>            .build()<br>    }<br>}</pre><h3>📦 Step 4: Repository with Queries</h3><p>Here’s how to fetch users and a single user by ID:</p><pre>class UserRepository {<br>    private val apollo = ApolloInstance.apolloClient<br><br>    suspend fun getUsers(): List&lt;GetUsersQuery.User&gt; {<br>        val response = apollo.query(GetUsersQuery()).execute()<br>        return response.data?.users ?: emptyList()<br>    }<br><br>    suspend fun getUserById(id: String): GetUserByIdQuery.User? {<br>        val response = apollo.query(GetUserByIdQuery(id)).execute()<br>        return response.data?.user<br>    }<br>}</pre><p>👉 Notice that <strong>the base URL never changes</strong>. Different .graphql files give you different generated queries.</p><h3>➕ Step 5: Adding a Mutation</h3><p>Create src/main/graphql/com/example/graphql/AddUser.graphql:</p><pre>mutation AddUser($name: String!, $email: String!) {<br>  addUser(name: $name, email: $email) {<br>    id<br>    name<br>    email<br>  }<br>}</pre><p>Apollo will generate AddUserMutation.</p><p>Now extend your repository:</p><pre>suspend fun addUser(name: String, email: String): AddUserMutation.AddUser? {<br>    val response = apollo.mutation(AddUserMutation(name, email)).execute()<br>    return response.data?.addUser<br>}</pre><h3>🧑‍💻 Step 6: ViewModel Integration</h3><pre>class UserViewModel : ViewModel() {<br>    private val repo = UserRepository()<br><br>    private val _users = MutableStateFlow&lt;List&lt;GetUsersQuery.User&gt;&gt;(emptyList())<br>    val users: StateFlow&lt;List&lt;GetUsersQuery.User&gt;&gt; = _users<br><br>    fun loadUsers() {<br>        viewModelScope.launch {<br>            _users.value = repo.getUsers()<br>        }<br>    }<br><br>    fun addNewUser(name: String, email: String) {<br>        viewModelScope.launch {<br>            val newUser = repo.addUser(name, email)<br>            if (newUser != null) {<br>                _users.value = _users.value + GetUsersQuery.User(<br>                    id = newUser.id,<br>                    name = newUser.name,<br>                    email = newUser.email,<br>                )<br>            }<br>        }<br>    }<br>}</pre><h3>🎨 Step 7: UI with Jetpack Compose</h3><pre>@Composable<br>fun UserScreen(viewModel: UserViewModel = viewModel()) {<br>    val users by viewModel.users.collectAsState()<br><br>    Column {<br>        Button(onClick = {<br>            viewModel.addNewUser(&quot;John Doe&quot;, &quot;john@example.com&quot;)<br>        }) {<br>            Text(&quot;Add User&quot;)<br>        }<br><br>     LazyColumn {<br>            items(users) { user -&gt;<br>                Text(text = &quot;${user.name} - ${user.email}&quot;)<br>            }<br>        }<br>    }<br>}</pre><h3>🧠 Key Takeaways</h3><p>✅ Apollo generates type-safe Kotlin models from your queries.<br> ✅ You only need <strong>one base URL</strong> for GraphQL — queries &amp; mutations decide what you fetch.<br> ✅ Works seamlessly with coroutines, Flow, and Jetpack Compose.</p><h3>📌 Final Thoughts</h3><p>Moving from Retrofit to Apollo GraphQL is surprisingly smooth.<br> Instead of juggling multiple endpoints, you simply write <strong>queries/mutations</strong> and let Apollo handle the heavy lifting.</p><p>Next time you’re building an Android app, consider GraphQL if:</p><ul><li>Your REST APIs are too chatty</li><li>You need only specific fields from a response</li><li>You want type-safety and fewer null checks</li></ul><p>Apollo + Kotlin + Compose = 🚀 developer happiness!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcd60f31e38f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Kotlin Interview Prep: 60 Questions to Refresh Your Brain ☕️]]></title>
            <link>https://mukesh-yadav.medium.com/kotlin-interview-prep-60-questions-to-refresh-your-brain-%EF%B8%8F-215e381d685a?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/215e381d685a</guid>
            <category><![CDATA[kotlin-coroutines]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Thu, 04 Sep 2025 20:39:40 GMT</pubDate>
            <atom:updated>2025-09-04T20:39:40.861Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*fKFWqFjwzKfiEX2DHafmrA.png" /></figure><p>So you’ve got a Kotlin interview coming up? Or maybe you just want to flex on your Java friends with data class jokes? Either way, here’s your crash course: 6<strong>0 Kotlin interview questions with crisp answers</strong>.</p><p>Think of this as your morning coffee ☕ meets Kotlin brain gym 🏋️ — short, to the point, and sprinkled with examples.</p><h3>🧑‍💻 Kotlin Interview Prep (Part 1): Basics &amp; Core Concepts 🚀</h3><p>Kotlin interviews often start with the <strong>foundations</strong> — the “bread and butter” stuff every Kotlin dev should know. So let’s warm up with 10 fundamental questions that will refresh your brain and (hopefully) impress your interviewer.</p><h3>1. What is Kotlin? 🤔</h3><p>Kotlin is a <strong>modern, statically typed programming language</strong> developed by JetBrains.</p><ul><li>Runs on the <strong>JVM</strong>.</li><li>Can be compiled to <strong>JavaScript</strong> or <strong>native</strong>.</li><li>Famous for <strong>conciseness</strong>, <strong>null safety</strong>, and <strong>seamless Java interop</strong>.</li></ul><p><em>(In short: Kotlin is like Java, but with fewer keystrokes and more happiness.)</em></p><h3>2. What are the key advantages of Kotlin over Java? ⚡</h3><ul><li>✅ Null safety</li><li>✅ Data classes</li><li>✅ Extension functions</li><li>✅ Higher-order functions</li><li>✅ Coroutines for async programming</li><li>✅ Smart casts</li><li>✅ Less boilerplate, more expressive syntax</li></ul><p><em>(Translation: fewer </em><em>; tears and more developer smiles.)</em></p><h3>3. How does Kotlin handle null safety? 🚫☠️</h3><p>By default, types are <strong>non-nullable</strong>.</p><ul><li>Use ? for nullable types (String?).</li><li>Handle with:</li><li>Safe call ?.</li><li>Elvis operator ?:</li><li>Non-null assertion !! (⚠️ risky!)</li></ul><pre>val name: String? = &quot;Alice&quot;<br>println(name?.length ?: 0) // prints 5</pre><h3>4. Explain the difference between val and var. 🔑</h3><ul><li>val → read-only (immutable). Once set, can’t change.</li><li>var → read-write (mutable). Can be reassigned.</li></ul><p>💡 Think:</p><ul><li>val = your <strong>birth date</strong> (fixed).</li><li>var = your <strong>mood</strong> (changes daily).</li></ul><h3>5. What is a data class in Kotlin? 📦</h3><p>A <strong>data class</strong> is meant to <strong>hold data</strong>. Kotlin generates:</p><ul><li>equals()</li><li>hashCode()</li><li>toString()</li><li>copy()</li><li>componentN()</li></ul><p>Example:</p><pre>data class User(val name: String, val age: Int)<br><br>fun main() {<br>    val user1 = User(&quot;Alice&quot;, 30)<br>    val user2 = User(&quot;Alice&quot;, 30)<br>    <br>    println(user1 == user2)         // true<br>    println(user1.copy(age = 31))   // User(name=Alice, age=31)<br>}</pre><h3>6. What are smart casts? 🧠</h3><p>Kotlin automatically casts variables after type checks. No need for redundant cast() calls.</p><pre>fun printLength(obj: Any) {<br>    if (obj is String) {<br>        // auto-cast to String<br>        println(&quot;Length: ${obj.length}&quot;)<br>    }<br>}</pre><h3>7. What is a when expression? How is it different from Java’s switch? 🎛️</h3><p>when is <strong>more powerful than switch</strong>:</p><ul><li>Works as <strong>expression</strong> or <strong>statement</strong>.</li><li>Supports <strong>type checks</strong>, <strong>range checks</strong>, and more.</li></ul><pre>fun describe(obj: Any): String = when (obj) {<br>    1 -&gt; &quot;One&quot;<br>    &quot;Hello&quot; -&gt; &quot;Greeting&quot;<br>    is Long -&gt; &quot;Long&quot;<br>    !is String -&gt; &quot;Not a String&quot;<br>    else -&gt; &quot;Unknown&quot;<br>}</pre><h3>8. Primary vs Secondary Constructors 🏗️</h3><ul><li><strong>Primary constructor</strong>: Declared in class header. Main initializer.</li><li><strong>Secondary constructor</strong>: Declared with constructor inside class. Must delegate to primary.</li></ul><pre>class Person(val name: String) { // Primary<br>    var age: Int = 0<br><br>constructor(name: String, age: Int) : this(name) { // Secondary<br>        this.age = age<br>    }<br>}</pre><h3>9. What is the init block? 🏁</h3><p>init runs after the <strong>primary constructor</strong> but before secondary constructors. Used for extra initialization logic.</p><pre>class MyClass(name: String) {<br>    val className: String<br><br>init {<br>        className = &quot;Class: $name&quot;<br>        println(&quot;Initializing MyClass with name: $name&quot;)<br>    }<br>}</pre><h3>10. Difference between == and === ⚔️</h3><ul><li>== → <strong>Structural equality</strong> (calls equals()).</li><li>=== → <strong>Referential equality</strong> (same memory reference).</li></ul><pre>val a = &quot;Kotlin&quot;<br>val b = &quot;Kotlin&quot;<br>println(a == b)   // true<br>println(a === b)  // true (same interned string reference)</pre><p>👉 That’s Part 1! You’ve now refreshed the <strong>basics</strong>: Kotlin’s syntax, constructors, null safety, and some common pitfalls. Next, we’ll level up with <strong>functions, lambdas, and scope functions</strong> (a.k.a. Kotlin’s favorite party tricks 🎉).</p><h3>🎯 Kotlin Interview Prep (Part 2): Functions &amp; Lambdas 🐑➡️🐺</h3><p>After the <strong>basics</strong>, the interviewer will usually dive into <strong>functions and lambdas</strong> — the stuff that makes Kotlin fun, expressive, and sometimes confusing. Let’s explore 10 common Q&amp;A with examples.</p><h3>11. What is a higher-order function? 🧠</h3><p>A <strong>higher-order function</strong> is a function that either:</p><ul><li>Takes another function as a parameter, or</li><li>Returns a function as a result.</li></ul><p>They’re great for abstracting patterns and writing concise code.</p><h3>12. Example of a higher-order function 🛠️</h3><pre>fun operateOnNumbers(a: Int, b: Int, operation: (Int, Int) -&gt; Int): Int {<br>    return operation(a, b)<br>}<br><br>fun main() {<br>    val sum = operateOnNumbers(5, 3) { x, y -&gt; x + y }<br>    println(&quot;Sum: $sum&quot;) // Sum: 8<br><br>    val product = operateOnNumbers(5, 3) { x, y -&gt; x * y }<br>    println(&quot;Product: $product&quot;) // Product: 15<br>}</pre><h3>13. What is a lambda function? 🌀</h3><p>A <strong>lambda function</strong> is a <strong>concise way to define an anonymous function</strong> (a function without a name).</p><ul><li>Can be passed around as values.</li><li>Often used with higher-order functions.</li></ul><h3>14. How do you define a lambda function? ✍️</h3><p>Syntax:</p><pre>{ parameters -&gt; body }</pre><p>Examples:</p><pre>val sumLambda: (Int, Int) -&gt; Int = { a, b -&gt; a + b }<br>val greetingLambda: (String) -&gt; Unit = { name -&gt; println(&quot;Hello, $name!&quot;) }<br>val noParamLambda: () -&gt; String = { &quot;No parameters&quot; }<br><br>println(sumLambda(10, 20)) // 30<br>greetingLambda(&quot;World&quot;)    // Hello, World!<br>println(noParamLambda())   // No parameters</pre><h3>15. What is the it keyword in lambdas? 🧍</h3><p>If a lambda has only <strong>one parameter</strong>, Kotlin lets you skip naming it and use the implicit it.</p><pre>val numbers = listOf(1, 2, 3, 4, 5)<br>val doubled = numbers.map { it * 2 } // &#39;it&#39; = current element<br>println(doubled) // [2, 4, 6, 8, 10]</pre><p><em>(Because sometimes naming things is the hardest part in programming 😅)</em></p><h3>16. What is a function type in Kotlin? 🔤</h3><p>A <strong>function type</strong> represents the signature of a function (its params + return type).</p><pre>// Function type: takes two Ints, returns Int<br>val operation: (Int, Int) -&gt; Int = { a, b -&gt; a + b }<br><br>// Function type: takes String, returns Unit<br>val printer: (String) -&gt; Unit = { message -&gt; println(message) }</pre><h3>17. What is a trailing lambda? 🎒</h3><p>If the <strong>last parameter</strong> of a function is a function type, you can place the lambda <strong>outside the parentheses</strong>. Cleaner syntax!</p><pre>fun execute(times: Int, action: () -&gt; Unit) {<br>    repeat(times) { action() }<br>}<br><br>fun main() {<br>    // Without trailing lambda<br>    execute(3, { println(&quot;Hello&quot;) })<br><br>    // With trailing lambda<br>    execute(2) {<br>        println(&quot;World&quot;)<br>    }<br>}</pre><h3>18. When would you use apply and with? 🛠️</h3><ul><li><strong>apply</strong> → configure an object and return it. (this = object)</li><li><strong>with</strong> → perform operations on an object and return the lambda result. (this = object)</li></ul><pre>val person = Person(&quot;Alice&quot;).apply {<br>    age = 30<br>    // this refers to the Person object<br>}<br><br>val result = with(person) {<br>    println(&quot;Name: $name, Age: $age&quot;)<br>    age + 5 // returns 35<br>}<br>println(result)</pre><h3>19. Explain let and run. 🔎</h3><ul><li><strong>let</strong> → great for <strong>null checks</strong>; returns lambda result. (it = object)</li><li><strong>run</strong> → like let but uses this; often for init or combining expressions.</li></ul><pre>val nullableName: String? = &quot;Bob&quot;<br>nullableName?.let {<br>    println(&quot;Hello, $it&quot;) // only runs if non-null<br>}<br><br>val greeting = &quot;Hello&quot;.run {<br>    toUpperCase() // this = &quot;Hello&quot;<br>}<br>println(greeting) // HELLO<br><br>val computedValue = run {<br>    val x = 10<br>    val y = 20<br>    x + y<br>}<br>println(computedValue) // 30</pre><h3>20. What is also? 🪞</h3><p><strong>also</strong> is used for <strong>side-effects</strong> (like logging). Returns the original object. (it = object)</p><pre>val numbers = mutableListOf(1, 2, 3)<br>val doubledNumbers = numbers.map { it * 2 }<br>    .also {<br>        println(&quot;Processed list: $it&quot;) // logging side-effect<br>    }<br><br>println(doubledNumbers) // [2, 4, 6]</pre><p>👉 That’s <strong>Part 2</strong> done! You now have a solid grasp of <strong>functions, lambdas, and scope functions</strong>. In interviews, this is where Kotlin starts feeling more expressive than Java. Next up: <strong>Advanced Features (inline, extension functions, coroutines)</strong>. 🚀</p><h3>⚡ Kotlin Interview Prep (Part 3): Advanced Features 🚀</h3><p>By now, you’ve mastered <strong>basics, functions, and lambdas</strong>. Now let’s explore some of Kotlin’s <strong>advanced superpowers</strong> — extension functions, inline tricks, and coroutines. These are the concepts that make Kotlin stand out from Java.</p><h3>21. What are extension functions in Kotlin? Why are they useful?</h3><p>👉 Extension functions let you <strong>add new functions to existing classes</strong> without inheriting or using design patterns like <strong>Decorator</strong>.<br> They make code more <strong>readable, reusable, and expressive</strong>.</p><h3>22. Example of extension functions 🛠️</h3><pre>fun String.addExclamation(): String {<br>    return &quot;$this!&quot;<br>}<br><br>fun List&lt;Int&gt;.product(): Int {<br>    return if (isEmpty()) 1 else fold(1) { acc, i -&gt; acc * i }<br>}<br><br>fun main() {<br>    println(&quot;Hello&quot;.addExclamation()) // Hello!<br>    val numbers = listOf(1, 2, 3, 4)<br>    println(numbers.product()) // 24<br>}</pre><p>No need for <strong>utility classes</strong> anymore — just extend what you need! 🎉</p><h3>23. What is the inline keyword in Kotlin? When should you use it?</h3><p>The <strong>inline</strong> keyword is a <strong>performance optimization hint</strong>.<br> When used on a function, the compiler replaces calls to that function with the <strong>actual body of the function</strong> at the call site.</p><p>✅ Use it when:</p><ul><li>The function is a <strong>higher-order function</strong> (takes lambdas).</li><li>You want to avoid creating function objects.</li><li>You need <strong>non-local returns</strong> from the lambda.</li></ul><h3>24. Example of an inline function ⏱️</h3><pre>inline fun measureTime(block: () -&gt; Unit) {<br>    val start = System.nanoTime()<br>    block()<br>    val end = System.nanoTime()<br>    println(&quot;Time taken: ${(end - start) / 1_000_000.0} ms&quot;)<br>}<br><br>fun main() {<br>    measureTime {<br>        var sum = 0<br>        for (i in 1..1_000_000) {<br>            sum += i<br>        }<br>        println(&quot;Sum: $sum&quot;)<br>    }<br>}</pre><h3>25. What is a non-local return in an inline function?</h3><p>In an <strong>inline function</strong>, a return inside the lambda can exit <strong>not just the lambda</strong>, but also the <strong>enclosing function</strong>.</p><pre>inline fun runWithCondition(condition: Boolean, action: () -&gt; Unit) {<br>    if (condition) {<br>        action()<br>    }<br>}<br><br>fun foo() {<br>    runWithCondition(true) {<br>        println(&quot;Inside lambda&quot;)<br>        return // Exits foo() completely<br>    }<br>    println(&quot;This will NOT print&quot;)<br>}<br><br>fun main() {<br>    foo()<br>}</pre><p>This is called a <strong>non-local return</strong>.</p><h3>26. What is noinline? When would you use it?</h3><p>noinline prevents specific lambda parameters in an inline function from being inlined.</p><p>👉 Use it when:</p><ul><li>You need to <strong>store the lambda in a variable</strong>.</li><li>You need to <strong>pass it to another function</strong> that isn’t inline.</li></ul><pre>inline fun myInlineFunction(<br>    inlinedLambda: () -&gt; Unit,<br>    noinline noInlinedLambda: () -&gt; Unit<br>) {<br>    inlinedLambda() // inlined<br>    val storedLambda = noInlinedLambda // can be stored/passed around<br>    storedLambda()<br>}</pre><h3>27. What is crossinline? When would you use it?</h3><p>crossinline prevents <strong>non-local returns</strong> in an inline lambda while still inlining the code.<br> This is useful if the lambda is executed in another context (like a thread).</p><pre>inline fun postDelayed(delayMillis: Long, crossinline action: () -&gt; Unit) {<br>    Thread {<br>        Thread.sleep(delayMillis)<br>        action() // Cannot return from here<br>    }.start()<br>}<br><br>fun foo() {<br>    println(&quot;Starting foo&quot;)<br>    postDelayed(1000) {<br>        println(&quot;Delayed action&quot;)<br>        // return // ❌ Not allowed with crossinline<br>    }<br>    println(&quot;Ending foo&quot;)<br>}</pre><h3>28. What are coroutines in Kotlin?</h3><p>Coroutines are <strong>lightweight threads</strong> for <strong>asynchronous programming</strong>.<br> They let you write <strong>non-blocking code</strong> in a <strong>sequential style</strong>, avoiding callback hell.</p><p>Use them for:</p><ul><li>Network calls</li><li>Database queries</li><li>Parallel processing</li></ul><h3>29. What is a suspend function?</h3><p>A <strong>suspend function</strong> can be <strong>paused and resumed later</strong> without blocking the thread.</p><ul><li>Can only be called from another <strong>suspend function</strong> or a <strong>coroutine builder</strong> (launch, async).</li><li>Forms the <strong>building blocks of coroutines</strong>.</li></ul><h3>30. Difference between launch and async? ⚡</h3><ul><li><strong>launch</strong> → Fire-and-forget. Returns a Job.</li><li><strong>async</strong> → Computes a result. Returns a Deferred&lt;T&gt; (a lightweight future).</li></ul><pre>fun main() = runBlocking {<br>    val job = launch {<br>        delay(1000)<br>        println(&quot;Launch done&quot;)<br>    }<br><br>    val deferred = async {<br>        delay(1000)<br>        &quot;Result from async&quot;<br>    }<br><br>    job.join()<br>    println(deferred.await()) // Result from async<br>}</pre><h3>📌 Wrap-Up</h3><p>In this part, you learned:</p><ul><li>✨ Extension functions (make classes smarter without inheritance).</li><li>⚡ Inline, noinline, crossinline (performance + lambda control).</li><li>🚀 Coroutines (async programming the Kotlin way).</li></ul><p>Next up → <strong>Part 4: Object-Oriented Programming &amp; Delegates</strong> 🌊</p><h3>🏗️ Kotlin Interview Prep (Part 4): OOP &amp; Delegates 🎭</h3><p>So far, we’ve covered <strong>basics, functions, lambdas, and advanced features</strong>. Now it’s time to dive into <strong>object-oriented programming</strong> and <strong>delegates</strong> — two pillars that make Kotlin powerful, expressive, and concise.</p><p>Here are Q&amp;A (31–50) you’ll want to master.</p><h3>31. What is an abstract class in Kotlin?</h3><p>An <strong>abstract class</strong>:</p><ul><li>Cannot be instantiated directly.</li><li>Can contain both <strong>abstract members</strong> (to be implemented by subclasses) and <strong>concrete members</strong> (with implementation).</li><li>Useful when you need a <strong>common base</strong> with shared logic.</li></ul><h3>32. What is an interface in Kotlin? Can it have default implementations?</h3><p>An <strong>interface</strong> defines a <strong>contract</strong> of behavior.</p><ul><li>It can declare <strong>abstract functions</strong>.</li><li>It can also provide <strong>default implementations</strong> (since Kotlin 1.0).</li><li>But unlike abstract classes, it <strong>cannot hold state</strong>.</li></ul><h3>33. Explain the open keyword in Kotlin.</h3><p>By default, Kotlin classes and functions are <strong>final</strong>.<br> Use <strong>open</strong> to make them extendable or overridable.</p><h3>34. What is the purpose of sealed classes?</h3><p>A <strong>sealed class</strong> restricts inheritance:</p><ul><li>All subclasses must be declared in the <strong>same file</strong>.</li><li>Enables <strong>exhaustive </strong><strong>when expressions</strong>, so the compiler ensures all cases are handled.</li></ul><pre>sealed class Result<br>class Success(val data: String) : Result()<br>class Error(val message: String) : Result()<br><br>fun handleResult(result: Result) {<br>    when (result) {<br>        is Success -&gt; println(&quot;Success: ${result.data}&quot;)<br>        is Error -&gt; println(&quot;Error: ${result.message}&quot;)<br>    }<br>}</pre><h3>35. What is an enum class in Kotlin?</h3><p>An <strong>enum class</strong> defines a <strong>fixed set of constants</strong>.<br> Unlike Java enums, Kotlin enums can have <strong>properties and methods</strong>.</p><pre>enum class Color(val hex: String) {<br>    RED(&quot;#FF0000&quot;),<br>    GREEN(&quot;#00FF00&quot;),<br>    BLUE(&quot;#0000FF&quot;);<br><br>    fun printHex() {<br>        println(&quot;Hex code: $hex&quot;)<br>    }<br>}<br><br>fun main() {<br>    println(Color.RED)         // RED<br>    Color.GREEN.printHex()     // Hex code: #00FF00<br>}</pre><h3>36. Explain the concept of generics in Kotlin.</h3><p><strong>Generics</strong> let you create reusable classes, functions, and interfaces that work with <strong>different types safely</strong>.<br> Example: List&lt;T&gt;, Map&lt;K, V&gt;.</p><h3>37. What is type variance (in, out) in Kotlin generics?</h3><ul><li><strong>out (covariance)</strong> → Producer. You can <strong>return</strong> type T, but not consume it. (List&lt;Cat&gt; is assignable to List&lt;Animal&gt;).</li><li><strong>in (contravariance)</strong> → Consumer. You can <strong>consume</strong> type T, but not produce it. (Comparator&lt;Animal&gt; is assignable to Comparator&lt;Cat&gt;).</li></ul><p>👉 Think: <strong>Producer = out, Consumer = in</strong>.</p><h3>38. What are delegates in Kotlin?</h3><p><strong>Delegates</strong> let you implement the <strong>delegation pattern</strong> easily.<br> They allow a class or property to hand over its implementation to another object.</p><h3>39. How do you implement property delegation?</h3><p>Use the <strong>by keyword</strong>.</p><pre>import kotlin.properties.Delegates<br><br>class MyClass {<br>    var name: String by Delegates.observable(&quot;No Name&quot;) { prop, old, new -&gt;<br>        println(&quot;Name changed from $old to $new&quot;)<br>    }<br><br>    val lazyValue: String by lazy {<br>        println(&quot;Computing lazy value...&quot;)<br>        &quot;Hello, Lazy!&quot;<br>    }<br>}<br><br>fun main() {<br>    val mc = MyClass()<br>    mc.name = &quot;Alice&quot;   // Name changed from No Name to Alice<br>    println(mc.lazyValue) // Computing lazy value... Hello, Lazy!<br>    println(mc.lazyValue) // Hello, Lazy! (cached)<br>}</pre><h3>40. Explain Delegates.observable and Delegates.vetoable.</h3><ul><li><strong>observable</strong> → Executes a callback whenever a property changes.</li><li><strong>vetoable</strong> → Like observable, but you can <strong>reject changes</strong> by returning false.</li></ul><h3>41. How do you implement class (interface) delegation?</h3><p>You can <strong>delegate an entire interface implementation</strong> using by.</p><pre>interface Logger {<br>    fun log(message: String)<br>}<br><br>class ConsoleLogger : Logger {<br>    override fun log(message: String) = println(&quot;Console: $message&quot;)<br>}<br><br>class FileLogger : Logger {<br>    override fun log(message: String) = println(&quot;File: $message&quot;)<br>}<br><br>class App(logger: Logger) : Logger by logger {<br>    fun run() {<br>        log(&quot;Application started.&quot;)<br>    }<br>}<br><br>fun main() {<br>    App(ConsoleLogger()).run() // Console: Application started.<br>    App(FileLogger()).run()    // File: Application started.<br>}</pre><h3>42. When would you use lazy delegate?</h3><p>Use lazy when:</p><ul><li>Initialization is <strong>expensive</strong>.</li><li>Value may <strong>not always be needed</strong>.</li><li>You want <strong>thread-safe initialization</strong>.</li></ul><h3>43. What is the purpose of the by keyword?</h3><ul><li>Used for <strong>delegation</strong> (property &amp; class).</li><li>Also appears in enum entry definitions (rare case).</li></ul><h3>44. What is a companion object in Kotlin?</h3><p>A <strong>companion object</strong> is:</p><ul><li>A singleton object tied to a class.</li><li>Used for <strong>factory methods, constants, and utilities</strong>.</li><li>Similar to <strong>static members</strong> in Java.</li></ul><pre>class MyFactory {<br>    companion object {<br>        const val DEFAULT_NAME = &quot;Default&quot;<br>        fun create(): MyFactory = MyFactory()<br>    }<br>}<br><br>fun main() {<br>    val instance = MyFactory.create()<br>    println(MyFactory.DEFAULT_NAME)<br>}</pre><h3>45. Difference between object declaration and companion object?</h3><ul><li><strong>object declaration</strong> → Creates a standalone <strong>singleton instance</strong>.</li><li><strong>companion object</strong> → Declared inside a class, belongs to that class.</li></ul><h3>46. How do you define top-level functions and properties?</h3><p>Declare them <strong>outside any class</strong> in a Kotlin file.</p><pre>// MyFile.kt<br>val PI = 3.14159<br><br>fun greet(name: String) {<br>    println(&quot;Hello, $name&quot;)<br>}</pre><p>Compiled to static methods in MyFileKt.class.</p><h3>47. What is type inference in Kotlin?</h3><p>The compiler can <strong>deduce types automatically</strong>, so you don’t need to declare them.</p><pre>val message = &quot;Hello&quot; // String<br>val number = 10       // Int<br>val sum = message + number // String</pre><h3>48. Explain the infix keyword.</h3><p>infix allows calling functions in a <strong>fluent, operator-like style</strong>.</p><p>Rules:</p><ul><li>Must be <strong>member</strong> or <strong>extension</strong> functions.</li><li>Must have <strong>a single parameter</strong>.</li></ul><pre>infix fun Int.add(other: Int): Int = this + other<br>fun main() {<br>    println(10.add(5)) // Regular call<br>    println(10 add 5)  // Infix call<br>}</pre><h3>49. What are Destructuring Declarations?</h3><p>They allow you to <strong>unpack objects into variables</strong>.<br> Works automatically for <strong>data classes</strong> and map entries.</p><pre>data class Point(val x: Int, val y: Int)<br><br>fun main() {<br>    val point = Point(10, 20)<br>    val (myX, myY) = point<br>    println(&quot;x: $myX, y: $myY&quot;)<br><br>    val map = mapOf(&quot;name&quot; to &quot;Alice&quot;, &quot;age&quot; to 30)<br>    for ((key, value) in map) {<br>        println(&quot;$key = $value&quot;)<br>    }<br>}</pre><h3>50. How can you interact with Java code from Kotlin, and vice-versa?</h3><p>Kotlin has <strong>seamless Java interoperability</strong>:</p><ul><li><strong>Kotlin → Java</strong>: Call Java methods, access fields, use libraries directly.</li><li><strong>Java → Kotlin</strong>: Call Kotlin functions/properties like normal Java methods.</li><li>Use annotations like @JvmStatic, @JvmOverloads, @JvmField to fine-tune how Kotlin code appears in Java.</li></ul><h3>📌 Wrap-Up</h3><p>In this part, we explored:</p><ul><li>🔑 Abstract, interfaces, sealed, and enums.</li><li>🌀 Generics with variance (in, out).</li><li>⚡ Delegates (lazy, observable, vetoable, class delegation).</li><li>🧩 Companion objects, infix, destructuring, and Java interop.</li></ul><p>You now have a <strong>solid OOP + Delegates foundation</strong> in Kotlin 🎯.</p><p>Next → <strong>Part 5: Kotlin Coroutines Deep Dive</strong> 🌊</p><h3>🌊 Kotlin Interview Prep (Part 5): Coroutines Deep Dive</h3><p>In the last part, we explored <strong>OOP &amp; Delegates</strong>.<br> Now let’s dive into <strong>Coroutines</strong> — one of Kotlin’s biggest strengths.</p><p>Here’s everything you need to know for interviews 👇</p><h3>51. What is a CoroutineScope?</h3><ul><li>A <strong>CoroutineScope</strong> defines the <strong>lifecycle</strong> of coroutines.</li><li>It ties coroutines to a <strong>Job</strong> and a <strong>Dispatcher</strong>.</li><li>When the scope is canceled, all coroutines launched in it are canceled.</li></ul><h3>52. What are Coroutine Builders in Kotlin?</h3><p>Coroutine builders <strong>start coroutines</strong>. The most common ones are:</p><ul><li>launch → fire-and-forget (returns Job).</li><li>async → returns a result (Deferred&lt;T&gt;).</li><li>runBlocking → blocks the current thread (used for testing/main entry points).</li></ul><h3>53. Difference between launch and async?</h3><ul><li><strong>launch</strong> → No return value. Returns a Job.</li><li><strong>async</strong> → Returns a Deferred&lt;T&gt;. Call .await() to get result.</li></ul><pre>val scope = CoroutineScope(Dispatchers.Default)<br><br>scope.launch {<br>    println(&quot;Running with launch&quot;)<br>}<br><br>val result = scope.async {<br>    42<br>}<br>println(&quot;Async result: ${result.await()}&quot;)</pre><h3>54. What is Structured Concurrency?</h3><p>Structured concurrency ensures:</p><ul><li>Coroutines <strong>run within a defined scope</strong>.</li><li>When the scope is canceled, all coroutines inside are canceled.</li><li>No orphaned coroutines floating around.</li></ul><h3>55. Explain SupervisorJob vs Job.</h3><p>Feature Job ✅ SupervisorJob 🛡️ Cancels siblings on failure ✅ Yes ❌ No Exception isolation ❌ No ✅ Yes Use case Batch processing UI rendering</p><h3>56. How do you handle exceptions in coroutines?</h3><ul><li>Use <strong>try/catch</strong> inside the coroutine.</li><li>Use a <strong>CoroutineExceptionHandler</strong> for global handling.</li></ul><pre>val handler = CoroutineExceptionHandler { _, exception -&gt;<br>    println(&quot;Caught: $exception&quot;)<br>}<br><br>val scope = CoroutineScope(Dispatchers.Main + handler)<br><br>scope.launch {<br>    throw RuntimeException(&quot;Boom!&quot;)<br>}</pre><h3>57. Difference between withContext and launch.</h3><ul><li><strong>withContext</strong>: Suspends current coroutine, switches context, <strong>returns a result</strong>.</li><li><strong>launch</strong>: Starts a new coroutine, doesn’t return result.</li></ul><pre>val data = withContext(Dispatchers.IO) {<br>    apiCall()<br>}</pre><h3>58. What is Dispatchers.IO, Dispatchers.Main, Dispatchers.Default?</h3><ul><li><strong>IO</strong> → For blocking I/O (API calls, DB).</li><li><strong>Main</strong> → For UI updates.</li><li><strong>Default</strong> → For CPU-intensive work (sorting, calculations).</li></ul><h3>59. What is coroutineScope vs supervisorScope?</h3><ul><li><strong>coroutineScope</strong>: Cancels <strong>all children</strong> if one fails.</li><li><strong>supervisorScope</strong>: Failure of one child does <strong>not affect others</strong>.</li></ul><h3>60. What are best practices for coroutines in Android?</h3><p>✅ Use viewModelScope in ViewModels.<br> ✅ Use lifecycleScope in Activities/Fragments.<br> ✅ Always cancel coroutines in onDestroy (if using custom scope).<br> ✅ Switch to Dispatchers.IO for background tasks.<br> ✅ Keep UI updates on Dispatchers.Main.</p><h3>📌 Wrap-Up</h3><p>In this part, we explored:</p><ul><li>⚡ CoroutineScope, builders (launch, async, runBlocking).</li><li>🧩 Structured concurrency with Job &amp; SupervisorJob.</li><li>🚨 Exception handling with try/catch &amp; CoroutineExceptionHandler.</li><li>🎯 Context switching with withContext.</li><li>📱 Best practices for Android apps.</li></ul><p>You’re now <strong>kotlin-coroutine ready for interviews</strong> 🎯</p><p>I’m tired now, just follow or clap or whatever</p><p><a href="https://www.linkedin.com/in/mukesh-yadav-ramharsh/">https://www.linkedin.com/in/mukesh-yadav-ramharsh/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=215e381d685a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Kotlin Coroutines: Job vs SupervisorJob — Deep Dive with Real-World Examples]]></title>
            <link>https://mukesh-yadav.medium.com/kotlin-coroutines-job-vs-supervisorjob-deep-dive-with-real-world-examples-92899216d506?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/92899216d506</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[kotlin-coroutines]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[asyncawait]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Thu, 04 Sep 2025 19:47:33 GMT</pubDate>
            <atom:updated>2025-09-04T19:47:33.402Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧵 Kotlin Coroutines: Job vs SupervisorJob — Deep Dive with Real-World Examples</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y9lyTZiUxWcGethq" /></figure><p>Kotlin Coroutines are a powerful tool for asynchronous programming. But managing coroutine lifecycles effectively is just as important as launching them.</p><p>Two key players in this space are <strong>Job</strong> and <strong>SupervisorJob</strong>.<br> They may look similar, but their behavior in <strong>failure scenarios</strong> is drastically different.</p><p>In this post, we’ll explore:</p><ul><li>🔍 What Job and SupervisorJob are</li><li>⚡ How they differ in practice</li><li>🏗️ Real-world use cases</li><li>🧠 Best practices for using them effectively</li></ul><h3>🔍 What is a Job?</h3><p>A <strong>Job</strong> in Kotlin represents a cancellable unit of work. It’s the backbone of coroutine lifecycle management.</p><p><strong>Key Features:</strong></p><ul><li>Cancels <strong>all child coroutines</strong> if any one of them fails.</li><li>Can be manually cancelled.</li><li>Works with CoroutineScope to enforce <strong>structured concurrency</strong>.</li></ul><h3>Example: Failure Cancels All</h3><pre>val job = Job()<br>val scope = CoroutineScope(Dispatchers.Default + job)<br><br>scope.launch {<br>    delay(1000)<br>    println(&quot;Task 1 completed&quot;)<br>}<br><br>scope.launch {<br>    delay(500)<br>    throw RuntimeException(&quot;Task 2 failed&quot;)<br>}</pre><p>👉 In this case, <strong>Task 1 will be cancelled</strong> when Task 2 fails.</p><h3>🧭 What is a SupervisorJob?</h3><p>A <strong>SupervisorJob</strong> is a special type of Job that <strong>isolates failures</strong>.</p><p><strong>Key Features:</strong></p><ul><li>Failure in one child does <strong>not</strong> cancel siblings.</li><li>Great for <strong>independent tasks</strong> (like UI rendering).</li><li>Still supports structured concurrency.</li></ul><h3>Example: Failure Does Not Cancel Others</h3><pre>val supervisorJob = SupervisorJob()<br>val scope = CoroutineScope(Dispatchers.Default + supervisorJob)<br><br>val task1 = scope.launch {<br>    delay(1000)<br>    println(&quot;Task 1 completed&quot;)<br>}<br><br>val task2 = scope.launch {<br>    delay(500)<br>    throw RuntimeException(&quot;Task 2 failed&quot;)<br>}<br><br>runBlocking {<br>    joinAll(task1, task2)<br>}</pre><p>👉 Here, <strong>Task 1 completes successfully</strong>, even though Task 2 fails.</p><h3>🏗️ Real-World Use Cases</h3><h3>🛠️ Job: Batch Processing (All-or-Nothing)</h3><p>Imagine a backend service that processes a batch of user data. If <strong>any part fails</strong>, you want to cancel the entire operation.</p><pre>val job = Job()<br>val scope = CoroutineScope(Dispatchers.IO + job)<br><br>scope.launch { processUserData(&quot;User A&quot;) }<br>scope.launch { processUserData(&quot;User B&quot;) }<br>scope.launch { processUserData(&quot;User C&quot;) }</pre><p>👉 If <strong>User B fails</strong>, the entire batch is cancelled.</p><h3>🎨 SupervisorJob: UI Rendering (Independent Tasks)</h3><p>In a mobile app, multiple UI components load independently. If one fails, others should still render.</p><pre>val supervisorJob = SupervisorJob()<br>val scope = CoroutineScope(Dispatchers.Main + supervisorJob)<br><br>scope.launch { loadHeader() }<br>scope.launch { loadContent() }<br>scope.launch { loadFooter() }</pre><p>👉 Even if loadContent() fails, <strong>header and footer still render</strong>.</p><h3>🧠 Best Practices</h3><h3>✅ Use Job when:</h3><ul><li>Tasks are <strong>tightly coupled</strong></li><li>Failure in one should cancel all</li><li>You’re doing <strong>transactional or batch operations</strong></li></ul><h3>✅ Use SupervisorJob when:</h3><ul><li>Tasks are <strong>independent</strong></li><li>You need resilience to failure</li><li>You’re working with <strong>UI or microservices</strong></li></ul><h3>🛡️ Exception Handling</h3><p>Always use a CoroutineExceptionHandler with launch coroutines:</p><pre>val handler = CoroutineExceptionHandler { _, exception -&gt;<br>    println(&quot;Caught: ${exception.message}&quot;)<br>}<br><br>val scope = CoroutineScope(Dispatchers.Default + SupervisorJob() + handler)<br><br>scope.launch {<br>    throw RuntimeException(&quot;Oops!&quot;)<br>}</pre><h3>🧼 Cleaning Up Resources</h3><p>When you’re done, always cancel your scope to avoid memory leaks:</p><pre>scope.cancel()</pre><h3>🧾 Summary</h3><pre>+-----------------------------+-----------------+------------------+<br>| Feature                     | Job             | SupervisorJob    |<br>+-----------------------------+-----------------+------------------+<br>| Cancels siblings on failure | Yes             | No               |<br>| Use case                    | Batch processing| UI rendering     |<br>| Exception isolation         | No              | Yes              |<br>| Structured concurrency      | Yes             | Yes              |<br>+-----------------------------+-----------------+------------------+</pre><h3>📌 Final Thoughts</h3><p>Understanding the difference between Job and SupervisorJob is essential for writing <strong>robust and scalable Kotlin applications</strong>.</p><ul><li>Use <strong>Job</strong> for all-or-nothing workflows (like batch jobs).</li><li>Use <strong>SupervisorJob</strong> when tasks are independent and should survive sibling failures.</li></ul><p>Next time you’re working with Kotlin Coroutines, ask yourself:<br> 👉 <em>Do my tasks fail together or independently?</em><br> That answer will guide whether Job or SupervisorJob is the right tool. 🚀</p><h3>🚶‍➡️For me if I’m coming back: reference</h3><pre>val supervisorJob = SupervisorJob()<br>val scope = CoroutineScope(Dispatchers.Main + supervisorJob)<br><br>// Simulated background API call<br>suspend fun fetchHeaderData(): String = withContext(Dispatchers.IO) {<br>    delay(500) // pretend network delay<br>    &quot;Header from API&quot;<br>}<br><br>suspend fun fetchContentData(): String = withContext(Dispatchers.IO) {<br>    delay(1000) // pretend network delay<br>    throw RuntimeException(&quot;Content API failed!&quot;)<br>}<br><br>suspend fun fetchFooterData(): String = withContext(Dispatchers.IO) {<br>    delay(700)<br>    &quot;Footer from API&quot;<br>}<br><br>// UI rendering tasks<br>fun renderHeader(header: String) = println(&quot;Rendered: $header&quot;)<br>fun renderContent(content: String) = println(&quot;Rendered: $content&quot;)<br>fun renderFooter(footer: String) = println(&quot;Rendered: $footer&quot;)<br><br>// Launching independent UI updates<br>scope.launch {<br>    val header = fetchHeaderData()<br>    renderHeader(header)<br>}<br><br>scope.launch {<br>    val content = fetchContentData()<br>    renderContent(content)<br>}<br><br>scope.launch {<br>    val footer = fetchFooterData()<br>    renderFooter(footer)<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92899216d506" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Hilt in Your Android Project: The Easy Way! & Build Variants]]></title>
            <link>https://mukesh-yadav.medium.com/setting-up-hilt-in-your-android-project-the-easy-way-build-variants-0c5665ad13f2?source=rss-5f1f9daa163c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0c5665ad13f2</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[dagger-hilt]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[dagger-2]]></category>
            <dc:creator><![CDATA[Mukesh Yadav]]></dc:creator>
            <pubDate>Tue, 26 Mar 2024 09:56:02 GMT</pubDate>
            <atom:updated>2024-03-26T09:59:46.654Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting Up Hilt in Your Android Project: The Easy Way! &amp; Build variant🚀</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tiWh_Pj00Kra8eY8" /></figure><p>Hey Android devs! 🤓 Are you tired of manually managing your dependency injections and looking for a simpler way? Let’s get started! 🛠️<br>So, I’ll separate this in two parts.<br><strong>1. Simple setup with retrofit.<br>2. Separating the retrofit module or network module then use it everywhere and see flavors (build variants).</strong><br>So, let&#39;s start the first part. Before that I’m assuming you know DI concept and its benefits. btw Hilt is built on Dagger 2, it is easy and less cumbersome.</p><ol><li><strong>Adding dependencies.<br>Note: </strong>Hilt uses <a href="https://developer.android.com/studio/write/java8-support">Java 8 features</a>. To enable Java 8 in your project, add the following to the app/build.gradle file</li></ol><pre>//First, add the hilt-android-gradle-plugin plugin to your project&#39;s root build.gradle file<br>plugins {<br>  id(&quot;com.google.dagger.hilt.android&quot;) version &quot;2.44&quot; apply false<br>}<br><br>//Apply the Gradle plugin and add these dependencies in your app/build.gradle file:<br>plugins {<br>  kotlin(&quot;kapt&quot;)<br>  id(&quot;com.google.dagger.hilt.android&quot;)<br>}<br><br>dependencies {<br>  implementation(&quot;com.google.dagger:hilt-android:2.44&quot;)<br>  kapt(&quot;com.google.dagger:hilt-android-compiler:2.44&quot;)<br>}<br><br>// Allow references to generated code<br>kapt {<br>  correctErrorTypes = true<br>}</pre><p><strong>2. Create Hilt Modules 📚<br></strong>Now, let’s create Hilt modules to provide dependencies. You can create separate modules for different parts of your app, making it easier to manage dependencies.</p><pre>@Module<br>@InstallIn(SingletonComponent::class)<br>object NetworkModule {<br><br>    @Provides<br>    @Singleton<br>    fun provideOkHttpClient(): OkHttpClient {<br>        val loggingInterceptor = HttpLoggingInterceptor().apply {<br>            level = HttpLoggingInterceptor.Level.BODY<br>        }<br><br>        return OkHttpClient.Builder()<br>            .addInterceptor(loggingInterceptor)<br>            .build()<br>    }<br><br>    @Provides<br>    @Singleton<br>    fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {<br>        return Retrofit.Builder()<br>            .baseUrl(&quot;https://api.example.com/&quot;) // Base URL can be dynamic or passed as a parameter<br>            .client(okHttpClient)<br>            .addConverterFactory(GsonConverterFactory.create())<br>            .build()<br>    }<br><br>    @Provides<br>    @Singleton<br>    fun provideApiService(retrofit: Retrofit): ApiService {<br>        return retrofit.create(ApiService::class.java)<br>    }<br>}<br><br>// Adding example of ApiService here only just for reference<br><br>interface ApiService {<br>    @GET(&quot;endpoint&quot;)<br>    suspend fun fetchData(): ResponseData // Replace ResponseData with your actual response data class<br>}</pre><p><strong>3</strong>.<strong> Enable Hilt in Application and provide annotation at proper place<br>1. </strong>Annotate your Application class with @HiltAndroidApp to enable Hilt:<br>Now we are ready to inject into Activity or view Model. <br>2. For activity/fragment use annotate with @AndroidEntryPoint 3. For view Model use @HiltViewModel Let’s see how in short example of both</p><pre>//Important step to enable hilt<br>@HiltAndroidApp<br>class MyApplication : Application() {<br>    // Your application code<br>}<br><br>@AndroidEntryPoint<br>class MyFragment : Fragment() {<br>    // Example<br>     @Inject<br>    lateinit var apiService: ApiService<br>    // Your fragment code<br>}<br><br>@HiltViewModel<br>class MyViewModel @Inject constructor(private val apiService: ApiService) : ViewModel() {<br>    // Your ViewModel code<br>}</pre><p>Awesome!! we have setup the Hilt in android project.<br>Lets’s see what we did and remember it<br>1. Add necessary dependencies.<br>2. Create Module.<br>3. Enable hilt by annotating @HiltAndroidApp <br>4. Inject in activity or viewmodel but annotate them with @AndroidEntryPoint and @HiltViewModel<br>That’s it. Keep it simple. We don&#39;t want to behave like NASA scientist like others after setting up Hilt.</p><p><strong>==============================================================</strong></p><p><strong>So this is the part 2 with build variants.</strong></p><p>In this we will separate the network module from service module because it is always good to keep things aside which comes less in picture but there instance we need everywhere.<br>So we should keep them in core/common/main module. so all the other module can get access to these. Like Room database, Retrofit, Objects OkHttps instance.<br>Let’s see.</p><pre>@Module<br>@InstallIn(SingletonComponent::class)<br>object NetworkModule {<br><br>    @Provides<br>    @Singleton<br>    fun provideOkHttpClient(): OkHttpClient {<br>        val loggingInterceptor = HttpLoggingInterceptor().apply {<br>            level = HttpLoggingInterceptor.Level.BODY<br>        }<br><br>        return OkHttpClient.Builder()<br>            .addInterceptor(loggingInterceptor)<br>            .build()<br>    }<br><br>    @Provides<br>    @Singleton<br>    fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {<br>        val baseUrl = BuildConfig.BASE_URL // Access BASE_URL defined in build configuration<br>        return Retrofit.Builder()        // Keep eye on this. it will into the<br>            .baseUrl(baseUrl)            // picture again<br>            .client(okHttpClient)<br>            .addConverterFactory(GsonConverterFactory.create())<br>            .build()<br>    }<br>}<br><br>//Creating 2 different service module<br><br>@Module<br>@InstallIn(SingletonComponent::class)<br>object ApiServiceModule {<br><br>    @Provides<br>    @Singleton<br>    fun provideApiService(retrofit: Retrofit): ApiService {<br>        return retrofit.create(ApiService::class.java)<br>    }<br>}<br><br>@Module<br>@InstallIn(SingletonComponent::class)<br>object AnotherApiServiceModule {<br><br>    @Provides<br>    @Singleton<br>    fun provideAnotherApiService(retrofit: Retrofit): AnotherApiService {<br>        return retrofit.create(AnotherApiService::class.java)<br>    }<br>}<br><br>//Create separate interfaces for different API services:<br><br>interface ApiService {<br>    @GET(&quot;endpoint&quot;)<br>    suspend fun fetchData(): ResponseData // Replace ResponseData with your actual response data class<br>}<br><br>interface AnotherApiService {<br>    @GET(&quot;another-endpoint&quot;)<br>    suspend fun fetchAnotherData(): AnotherResponseData // Replace AnotherResponseData with your actual response data class<br>}<br><br>//Use like this<br><br>@HiltViewModel<br>class CombinedViewModel @Inject constructor(<br>    private val apiService: ApiService,<br>    private val anotherApiService: AnotherApiService<br>) : ViewModel() {<br><br>    fun fetchDataAndAnotherData() {<br>        viewModelScope.launch {<br>            try {<br>                // Fetch data from ApiService<br>                val responseData = apiService.fetchData()<br>                // Handle response data<br>                <br>                // Fetch data from AnotherApiService<br>                val anotherResponseData = anotherApiService.fetchAnotherData()<br>                // Handle another response data<br><br>            } catch (e: Exception) {<br>                // Handle error<br>            }<br>        }<br>    }<br>}</pre><p>Hehe, we are set now ❤</p><p>Now let’s talk about variant or flavor of app, we don&#39;t have to go deep as of now. What necessary(common) is what we should be aware of. <br>So we have to test our app in dev, preprod and prod<br>So the main thing changes is BASE url, end URL will remains same most of the time. and we are not going to change the url before every build.<br>So let’s see this how we can achieve this.</p><h3>Step 1: Define Base URLs in gradle.properties</h3><p>Open your gradle.properties file and define different base URLs for each build variant:</p><pre># Debug Build Variant<br>debugBaseUrl=https://api.example.com/debug/<br><br># Release Build Variant<br>releaseBaseUrl=https://api.example.com/release/</pre><h3>Step 2: Access Base URLs in build.gradle</h3><p>Access the base URLs defined in gradle.properties in your build.gradle file:</p><pre>android {<br>    buildTypes {<br>        getByName(&quot;debug&quot;) {<br>            buildConfigField(&quot;String&quot;, &quot;BASE_URL&quot;, &quot;\&quot;${debugBaseUrl}\&quot;&quot;)<br>        }<br>        getByName(&quot;release&quot;) {<br>            buildConfigField(&quot;String&quot;, &quot;BASE_URL&quot;, &quot;\&quot;${releaseBaseUrl}\&quot;&quot;)<br>        }<br>    }<br>}</pre><p>Remember, when i said to keep eye on “val baseUrl = BuildConfig.BASE_URL” above ??<br>So here it comes again in picture. we can get base url from this line when we generate different variant.</p><p>And read in depth on <a href="https://developer.android.com/build/build-variants">Configure build variants | Android Studio | Android Developers</a></p><p>That’s All for today. Do 👏 👏 ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0c5665ad13f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>