Skip to content
tezvyn:

Kotlin

225 bites tagged Kotlin — interview questions with model answers, and 60-second explainers.

Android & Kotlin2 min read

Room: Querying Relational Data Without Manual Joins

Room lets you query related objects without writing raw SQL joins, mapping one-to-many or many-to-many relationships into nested objects. This is key for fetching a user and their posts in one go.

Android & Kotlin2 min read

App-Specific Storage: Your App's Private Locker

Think of app-specific storage as a private locker for your app's data, automatically cleaned up on uninstall. Use it for cache, settings, or internal data. The footgun: assuming this data is permanent—it's deleted when the user uninstalls.

Android & Kotlin2 min read

Room Database Migrations: Evolving Your Schema Safely

A Room migration is a renovation plan for your database. When you change your schema, you provide SQL instructions to upgrade existing user data without loss, preventing crashes on app updates. The footgun is forgetting to increment the database version.

Android & Kotlin2 min read

Room Type Converters: Teach Your Database New Tricks

Room Type Converters are translators for your database, teaching it to store types it doesn't natively understand, like `Date`. They let you persist simple objects by converting them to primitives like `Long`. The footgun is faking object relations with them.

Android & Kotlin2 min read

Preferences DataStore: The Safe SharedPreferences

Preferences DataStore is Android's modern way to save simple key-value data. It uses Kotlin's Flow to read data asynchronously, preventing UI freezes. Use it for user settings, but remember you can't read values synchronously like with SharedPreferences.

Android & Kotlin2 min read

Room Database: SQL Made Simple on Android

Room is an abstraction layer over SQLite that lets you work with Kotlin/Java objects, not raw SQL. It's the standard for local data persistence in Android, like caching network data.

Android & Kotlin2 min read

Room DAO: Your App's Type-Safe SQL Interface

A Room DAO is an interface that translates your method calls into SQL queries. It's how your Android app's code talks to its local database without writing boilerplate. The footgun is putting business logic in a DAO; it should only access data.

Android & Kotlin2 min read

Room Entity: Your Database Table as a Kotlin Class

A Room Entity is a data class that maps to a database table; each object is a row, each property a column. Use it to define your local SQLite schema in Android. The footgun: forgetting the `@PrimaryKey` annotation, which is required for Room to manage.

Android & Kotlin2 min read

Navigation Safe Args: Type-Safe Navigation in Android

Navigation Safe Args generates code to prevent runtime crashes when passing data between Android screens. It replaces error-prone Bundle manipulation with type-safe classes. Use it to pass user IDs or item details. The footgun: don't pass large objects.

Android & Kotlin2 min read

Deep Linking with Android's Navigation Component

Deep linking with the Navigation Component treats app screens like URL-addressable pages. It's for handling push notifications or web links that go to specific content.

Android & Kotlin2 min read

Repository Pattern: Your App's Single Source of Truth

The Repository Pattern acts as a mediator for your app's data, fetching from sources like a network or database. Use it to separate your UI from data-fetching logic, like caching. The footgun is putting business logic here; it's for data operations only.

Android & Kotlin2 min read

Compose UI Testing: Find Nodes, Assert State, Perform Actions

Compose UI tests treat your UI as a node tree. You find nodes by properties (like text or a test tag), assert their state (e.g., 'is displayed'), and perform actions like clicks. Use it to verify composables react correctly to state changes or user input.

Android & Kotlin2 min read

CompositionLocal: Implicitly Pass Data Down the UI Tree

CompositionLocal is like CSS inheritance for your UI tree, letting you pass data down implicitly without parameter drilling. It's ideal for ambient data like theming or localization. The footgun is overusing it, which makes components harder to test.

Android & Kotlin2 min read

Compose Side-Effects: Escaping the Pure Function

Compose functions should be pure, but apps must interact with the world. Side-effect APIs are controlled escape hatches to run non-UI code, like network calls or showing Toasts, from within a composable's lifecycle. The footgun is calling this logic directly.

Android & Kotlin2 min read

Navigation in Compose

Navigation in Compose treats screens as state. You define a graph of composables, each with a string 'route', and navigate by changing the current route. It's ideal for single-activity apps.

Android & Kotlin2 min read

Theming in Compose: Style from a Single Source

Theming in Compose is like a CSS stylesheet for your app. You define colors, typography, and shapes once in a central `Theme` composable, and it cascades down. Use it for light/dark modes and brand consistency.

Android & Kotlin2 min read

Lazy Layouts: Compose's Answer to Efficient Lists

Lazy layouts in Jetpack Compose render only the list items visible on screen, avoiding memory crashes from large datasets. Use them for long lists like feeds or galleries, but remember to provide a `key` to prevent UI glitches when data changes.

Android & Kotlin2 min read

Recomposition: Smart UI Updates in Compose

Recomposition is how Compose redraws your UI. It intelligently re-runs only the functions whose state has changed, avoiding a full screen refresh. This is triggered automatically when a `State` object that a composable reads is updated.

Android & Kotlin2 min read

State in Jetpack Compose: The UI's Memory

In Compose, state is any value that can change over time. The UI is a direct function of this state; when the state updates, the UI automatically redraws (recomposes) to match. The main footgun is not "hoisting" state, which makes components hard to test.

Android & Kotlin2 min read

Jetpack Compose Modifiers: Styling Your UI

Think of Modifiers as a chain of instructions that style and add behavior to your UI components. They're used for everything from setting padding and size to handling clicks.

Android & Kotlin2 min read

Compose Layouts: Build UI by Describing It

Describe your UI, and Compose draws it. Use `Column` and `Row` to position elements, then augment them with modifiers. The footgun is coding before you've broken the visual design into reusable parts, leading to a tangled mess.

Android & Kotlin2 min read

Composable Functions: Building UI with Kotlin Functions

Composable functions are Kotlin functions that describe your UI. Instead of creating View objects, you call functions like `Text` to build a UI tree. They are the core of Jetpack Compose for building Android UIs declaratively.

Android & Kotlin2 min read

Android View Animation: A Blueprint for Motion

Think of Android's view-based animations as a pre-written score. You define the animation (the "score") in an XML file, then apply it to a View (the "instrument") in your code. This is used for animating properties like alpha or translation on UI elements.

Android & Kotlin2 min read

Handling Android UI Events: Listeners and Callbacks

Think of UI event handling as setting tripwires. You attach a "listener" object to a UI element, and when a user interacts with it, your listener's code (the "callback") is triggered. This is how you make buttons and lists interactive.

Get Kotlin bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.