Android App Architecture Guidelines
- Rigorously define boundaries between modules
- Design lean interfaces e.g. don’t expose more functionality than needed
- Design for offline functionality
- Spend time on what counts, not on reinventing the wheel
- Three core components - model, view, view model (MVVM!)
- Motivation is separation of concerns and increased testability
- Leverages data binding, where view is updated via event “observers” or subscribers
- Decoupling UI (view) from logic enables more flexibility/iteration for design
- Model View Controller (MVC) does not separate concerns well enough for thorough testing, separates Activity from related layout XML which creates issues (in other words, don’t adopt a pattern that fights against the platform)
- Model View Presenter (MVP) if presenter is designed correctly, can be isolated from platform APIs which greatly enhances testing, layout XML and Activity are in View layer which is more natural for Android
- MVVM reduces glue code between view and model, highest degree of separation from the view layer
- Both MVP and MVVM rely on good interface design for keeping layers clearly defined
- Goal of patterns is to make codebase more flexible and maintainable over time (as opposed to an undisciplined approach to design)
- Categories of patterns include - Creational, Structural, Behavioral
- Creational patterns are concerned with how complex objects are created
- Singleton, Builder, Dependency Injection
- Structural patterns are concerned with how objects are composed
- Adapter, Facade
- Interfaces are an important aspect of these patterns
- Behavioral is concered with how objects are coordinated
- This is where MVVM, MVC, MVP come in
- Generally attempting to cleanly separate view, business logic, and data
Additional References
Lesson from Architecting for Android
>> Home