Architecture
376 bites tagged Architecture — interview questions with model answers, and 60-second explainers.
Dependency Injection: Your Objects Shouldn't Create Their Own Helpers
Instead of creating its own helpers (like a network client), an object receives them from an outside source. This is crucial for building testable Android apps, as it lets you swap a real `UserRepository` with a fake one during tests.
Android's Domain Layer: Your Business Logic's Home
The Domain Layer is an optional buffer between your UI and data layers, housing reusable business logic. Use it for complex logic or simple rules shared by multiple screens, keeping your ViewModels lean. The footgun is overusing it for every simple data fetch.
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's UI Layer: Displaying Data, Handling Events
The UI layer is what users see and touch. It displays app data on screen and sends user input like taps to your business logic. It's used in every screen, from login forms to media players.
ViewModel: Surviving Android Configuration Changes
A ViewModel acts like a durable backpack for your UI's data, surviving the destruction and recreation of an Activity during a screen rotation. It holds UI state, like user input or fetched data, preventing data loss.
Android's Task and Back Stack Explained
Think of the back stack as a stack of plates (screens). A "Task" is the entire stack for a user's workflow. The system manages this stack, but you can control it for custom navigation. The biggest footgun is misusing launch modes, which breaks back button.
LiveData: Lifecycle-Aware Data Observation
LiveData is a data holder that only notifies active UI components. It connects your ViewModel's data to your UI, preventing crashes and memory leaks by respecting the Android lifecycle.
Android ViewModel: Survive Screen Rotations
A ViewModel is a lifecycle-aware data holder that separates your UI's state from its controller. It keeps data alive during configuration changes like screen rotations, preventing data loss and repeated network calls.
Android Services: Running Work Without a UI
An Android Service is a component for long-running background tasks, even when the user isn't in your app. Use it for tasks like playing audio or syncing data.
Customer Data Platform (CDP): Your Customer's Single Source of Truth
A Customer Data Platform (CDP) creates a single, persistent profile for each customer by unifying data from siloed sources. It's used for real-time personalization and AI-driven marketing. The footgun is confusing it with a CRM, which manages relationships.
Contract Testing: Test Interfaces, Not Integrations
Contract testing ensures services work together without slow integration tests. It's a formal agreement where a 'consumer' defines its needs, and a 'provider' proves it can meet them.
SOLID Principles: Writing Maintainable Object-Oriented Code
SOLID principles are five design rules for writing maintainable object-oriented code. They guide you toward creating flexible systems that are easy to change. The footgun is treating them as rigid laws, leading to over-engineered and complex solutions.
Emergent Architecture: Build Just Enough, Just in Time
Emergent architecture lets design evolve as you build, prioritizing adaptation over upfront planning. It's used in agile teams where requirements are unclear.
How does positional encoding work in transformers?
This tests your understanding of why Transformers need explicit position data. A great answer explains that self-attention is permutation-invariant, meaning it sees inputs as an unordered set. Positional encodings—vectors derived from sine and cosine functions—are then added to the input embeddings to inject sequence order. A red flag is simply saying 'it adds position' without explaining why this is necessary or how it's done.
Encoder-Only vs. Decoder-Only vs. Encoder-Decoder Transformers?
This tests your ability to connect transformer architecture to specific NLP tasks. A great answer explains how each model's attention mechanism dictates its use: encoder-only (bidirectional attention) for understanding content, decoder-only (causal attention) for text generation, and encoder-decoder for sequence-to-sequence tasks like translation. The key red flag is failing to explain the *why* behind the task suitability—the attention mechanism.
Why are MoE models larger but cheaper to run?
This tests your understanding of sparse activation versus dense models. A great answer defines Mixture-of-Experts (MoE) as a system with a router and multiple expert sub-networks, explaining that only a fraction of the total parameters are activated for any given token, which drastically reduces computational cost (FLOPs) during inference. A red flag is describing MoE as a simple ensemble without mentioning the sparse routing mechanism that enables its efficiency.
Get Architecture bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.