Skip to content
tezvyn:

All bites

The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.

4330 bites

Page 194

Hot vs. Cold Streams: `StateFlow` vs. `Flow`
Android & Kotlin2 min read

Hot vs. Cold Streams: `StateFlow` vs. `Flow`

Tests your grasp of stream lifecycles. A great answer defines cold Flow (lazy, per-collector) vs. hot StateFlow (shared, active), then uses a ViewModel UI state scenario to show why StateFlow is correct for surviving configuration changes.

Hot vs. Cold Streams: StateFlow vs. Flow in Android
Android & Kotlin2 min read

Hot vs. Cold Streams: StateFlow vs. Flow in Android

This tests your grasp of stream lifecycles. A great answer defines cold Flow (lazy, per-collector) vs. hot StateFlow (active, shared state) and uses a ViewModel UI state scenario. A red flag is mischaracterizing a Flow as a one-time operation.

What is a CoroutineDispatcher and when to use Default versus IO?
Android & Kotlin2 min read

What is a CoroutineDispatcher and when to use Default versus IO?

This tests thread pool selection and the CPU versus IO distinction. A strong answer maps CoroutineDispatcher to the thread pool, Default to CPU work, IO to blocking IO, and Main to the UI thread.

What is a CoroutineDispatcher and when do you use each type?
Android & Kotlin2 min read

What is a CoroutineDispatcher and when do you use each type?

Tests your grasp of coroutine threading. A dispatcher manages which threads a coroutine runs on. Explain Main for UI, Default for CPU-intensive work, and IO for blocking operations. A red flag is mixing up IO and Default or using Unconfined.

What is a CoroutineDispatcher and when to use IO vs Default?
Android & Kotlin2 min read

What is a CoroutineDispatcher and when to use IO vs Default?

Tests your grasp of thread pool strategy for CPU vs. I/O-bound tasks. A good answer defines Dispatchers, contrasts the fixed-size Default pool (for CPU work) with the larger IO pool (for blocking I/O), and gives clear examples.

Explain Kotlin's declaration-site variance with in and out
Android & Kotlin2 min read

Explain Kotlin's declaration-site variance with in and out

Out T means covariant producer (read), in T means contravariant consumer (write), removing wildcard noise.

Explain Kotlin's declaration-site variance with `in` and `out`
Android & Kotlin2 min read

Explain Kotlin's declaration-site variance with `in` and `out`

This tests your grasp of type systems and API design. Explain how out (covariance/producer) and in (contravariance/consumer) provide type safety at the declaration site, simplifying usage. A red flag is confusing variance with immutability.

Explain Kotlin's declaration-site variance with in and out
Android & Kotlin2 min read

Explain Kotlin's declaration-site variance with in and out

This tests your grasp of generic type safety and API design. Explain that out marks covariant producers (e.g., List<out E>) and in marks contravariant consumers, then contrast this cleaner declaration-site model with Java's repetitive use-site wildcards.

Android & Kotlin2 min read

How do buffer, conflate, and collectLatest manage Kotlin Flow backpressure?

Backpressure is fast emit vs slow collect; buffer() suspends the producer when full, conflate() drops stale values, and collectLatest() cancels active collection to…

Explain backpressure in Kotlin Flows and its management operators
Android & Kotlin3 min read

Explain backpressure in Kotlin Flows and its management operators

This tests your understanding of Flow's pull-based nature and performance tuning. A great answer defines suspension as the default backpressure, then details how buffer, conflate, and collectLatest optimize it.

Explain backpressure in Kotlin Flows and its management operators
Android & Kotlin2 min read

Explain backpressure in Kotlin Flows and its management operators

This tests your understanding of Flow's sequential nature and strategies for decoupling producers and consumers. Explain default suspension, then detail buffer(), conflate(), and collectLatest(). A red flag is confusing conflate() with collectLatest().

Describe coroutine cancellation mechanics and cooperative suspend functions
Android & Kotlin2 min read

Describe coroutine cancellation mechanics and cooperative suspend functions

Tests cooperative cancellation mechanics. cancel() sets a Job to cancelling; suspend functions check this at suspension points and throw CancellationException, yet a tight non-suspending loop never checks and keeps running.

How does coroutine cancellation work internally?
Android & Kotlin2 min read

How does coroutine cancellation work internally?

Tests your grasp of cooperative cancellation. A good answer explains that cancel() sets a flag, suspend functions check it and throw CancellationException, and non-suspending loops need manual isActive checks.

How does coroutine cancellation work internally?
Android & Kotlin2 min read

How does coroutine cancellation work internally?

This tests your grasp of cooperative cancellation. Explain that cancel() sets a flag, causing a CancellationException at the next suspension point. A non-suspending loop must explicitly check isActive to stop.

What is a reified type parameter in Kotlin?
Android & Kotlin2 min read

What is a reified type parameter in Kotlin?

Tests JVM type erasure and inline function mechanics. Strong answer: reified preserves generic types at runtime via inline expansion, enabling is T checks without Class<T> passing. Red flag: claiming reified works without inline or outside functions.

What is a reified type parameter in Kotlin?
Android & Kotlin2 min read

What is a reified type parameter in Kotlin?

Tests your grasp of JVM type erasure and Kotlin's solution. Explain that reified makes a generic type accessible at runtime inside an inline function, avoiding manual Class passing. A red flag is failing to link reified directly to inline functions.

Explain Kotlin's `reified` type parameters and their use case
Android & Kotlin2 min read

Explain Kotlin's `reified` type parameters and their use case

Tests your grasp of JVM type erasure and Kotlin's solution. A great answer defines reified as making a generic type's Class accessible at runtime, explains this requires an inline function to substitute the type at the call site, and shows an example.

How would you implement a type-safe Kotlin DSL for a UI Form?
Android & Kotlin2 min read

How would you implement a type-safe Kotlin DSL for a UI Form?

Tests Kotlin DSL scoping with lambda receivers and extensions. Strong answers sketch a Form builder using initTag, explain T.() -> Unit implicit this for child elements, and add DslMarker to block scope leaks. Red flag: describing it as simple method chaining.

Implement a type-safe DSL for a UI component in Kotlin
Android & Kotlin2 min read

Implement a type-safe DSL for a UI component in Kotlin

This tests your ability to design clean, hierarchical APIs using Kotlin's idiomatic features. A great answer defines model classes, then uses higher-order functions with lambdas with receiver to create a nested structure, and mentions @DslMarker for scope…

Implement a type-safe DSL in Kotlin for a UI component
Android & Kotlin2 min read

Implement a type-safe DSL in Kotlin for a UI component

Tests understanding of Kotlin's type-safe builders via lambdas with receivers. A great answer defines model classes, creates a top-level builder function taking a Receiver.() -> Unit lambda, and defines nested builder methods.