A Guide to the Architecture Design Process for Mobile Applications
This article outlines a systematic approach to mobile architecture design, covering goals, when to create new architectures, requirement analysis, business flow mapping, pattern discovery, layering, modularization, lifecycle interfaces, verification, and evolution, illustrated with a Feed scenario and code examples.
Introduction
In practice we often discuss architecture design topics around specific business scenarios, but rarely the design process itself, leaving engineers unsure when to refactor or how to judge a solution.
Preliminary Thoughts
Before tackling architecture we must ask two questions: what is the goal of architecture design, and when is a new architecture needed?
Architecture Design Goals
The goal is to support business change, handling horizontal growth (more features) and vertical depth (deeper functionality), while keeping the system usable and adaptable.
When Is a New Architecture Needed?
Often the existing architecture suffices; deeper analysis and incremental refactoring are cheaper than a full rewrite. New architecture is required when a brand‑new business demands a separate system or when existing architecture cannot accommodate new requirements without degrading stability.
Architecture Design Process
The process mirrors software development stages and includes requirement analysis, business flow mapping, pattern identification, layering, modularization, verification, and evolution.
Requirement Analysis
Collect all requirements and current problems, turning them into use cases; the article uses a Feed scenario as an example.
Mapping Business Flow
Transform use cases into a functional flow, identifying key roles (Page, DataSource, List, CardDelegate, Card) and their responsibilities.
Focusing on Core Issues
Identify which parts of the flow address core problems (e.g., page state handling, card delegation) and ignore peripheral concerns.
Problem Splitting
Separate the flow into two independent sub‑problems: page state management and card delegation, allowing them to be solved independently.
Finding Patterns
Search for existing patterns (state machines, classic design patterns, MVVM, modular/component architectures) or create new ones. For the Feed example, page state uses MVVM with a state‑machine, and card delegation uses the Delegate pattern.
Layering
Three‑Layer Rule From bottom to top: Ability/Infrastructure layer, Framework/Domain layer, Strategy/Application layer.
Applying this to the Feed scenario yields a layered view of the list container, card delegate framework, and strategy components.
Modularization
Modules encapsulate functionality at the same layer, often using SPI (Service Provider Interface) with dependency injection. The article shows a ListContext interface as an example.
public interface ListContext {
fun registerService(cls: Class, service: Any)
}More advanced lifecycle‑aware modules are defined with generic State and Event types:
public interface LifecycleObserver
{
fun onStateChanged(state: S, event: E)
}
public interface LifecycleInterceptor
{
fun intercept(old: S, event: E): S
}
public interface Lifecycle
{
val currentState: S
fun addInterceptor(interceptor: LifecycleInterceptor
)
fun addObserver(observer: LifecycleObserver
)
}Module Communication Trade‑offs
Discusses string routing, event bus, and SPI, weighing coupling versus flexibility.
Startup Flow Orchestration Example
Uses a Stage‑Play model to orchestrate splash screens, privacy dialogs, and other startup steps, illustrating how layered and modular design simplifies complex flow control.
Architecture Verification
Verification includes use‑case coverage, extensibility checks, adherence to design principles (e.g., minimal definition), performance impact, and usability considerations.
Architecture Evolution
Good architecture evolves; migration strategies include building a new layer atop the old one or designing a new architecture that covers all existing use cases before gradual replacement.
Conclusion
Effective architecture design follows a disciplined process: requirement analysis, business flow mapping, pattern discovery, layered and modular design, verification, and careful evolution.
Team Introduction
The article is authored by the Bytedance Xigua Video client team, inviting readers to learn more or apply for positions.
Watermelon Video Tech Team
Technical practice sharing from Watermelon Video
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.