AwesomeApp
An Android boilerplate project setup for Rapid Application Development. If you are interested, please read pros-and-cons before start.
Project structure
Module name | Description |
---|---|
app-main | Contains UI and UI manipulation logic. Directly depends on app-core , app-lib , lib-xxx , etc. |
app-core | Business logic layer, abstracts business logic and DataSource . |
app-lib | Library logic layer, independent to business logic |
lib-xxx | Various 3rd party libraries and SDKs |
Component design
Tried to follow the Clean architecture as best as possible. Project structure follows as below:
View (:app-main)
|
ViewModel (:app-main)
|
UseCase (:app-core)
|
Repository (:app-core)
|
DataSource (:app-core)
All DataSources and DTOs must be scoped with internal
visibility for encapsulation.
Roles and responsibilities for components:
-
View: Takes and refines user input, displays internal presentation as recognisible(View, Sound, Vibration, etc) output.
-
ViewModel: Acts as data provider for requests from view. It asks Use cases to prepare required data for user input, and publishes it to an established channel between View and ViewModel. In this project, RxJava acts as such data channel. A composition of various UseCases.
-
UseCase: A common business logic provider for ViewModels - which is a composition of various Repositories. This component takes two key responsibilities:
- Combines various data provided by multiple repositories
- Converts data from repositories(DTO) to domain model.
In this example project, all domain models are exposed as kotlin
interface
s. -
Repository: Data provider for UseCases. A composition of various DataSources. DataSources could be Network, SharedPreferences, Database, Filesystem, etc.
Code quality management
This project is running plugins for code quality management.
Pros and cons
This project configuration has several pros and cons. Basically this complexity for a simple image list download and display app is an overkill indeed. This project is intended to be used at the beginning stage of enterprise level project - which usually be more than 3 developers are working together.
Pros
- TESTABILITY
- MODULARITY
Cons
- REQUIRES DEEP KNOWLEDGE ON GRADLE
- LOTS OF FILES TO MAINTAIN
- DIFFICULT TO UNDERSTAND PROJECT STRUCTURE AT A FIRST GLANCE