- follow the rules from Architecture guidelines recommended by Google.
- use latest Android Components, like ViewModel, LiveData and Data Binding.
- keep Activity only responsible for UI related code
- ViewModel provides data required by the UI class
- Repository Layer provides data to ViewModel classes. (single source of truth)
- unit tests for testing the main logic, following the “Given-When-Then” structure.
- Handling subscribeOn in the Repository Layer and the observeOn in the ViewModel
Same entity should not be spread across all layers of the application. We need to create remote model for our Remote Data Source and UI models for our UI Layer.
The data package contains networking classes, database classes, entity models, network request and response model.
The domain package contains our business objects and contains the Use Case classes used to interact with these from other packages.
The UI package contains UI components of the application. UI package has child packages that are organized as feature-by-layer.
Although Dagger is not required for a simple application, it is always a good idea to use Dagger for dependency injection. When you are writing the task, you should consider your code is always expected to change and you should design your app to make changes requires minimal.
RxJava has become one of the most important skill for Android development. Retrofit can be used very easily with RxJava.
Although It does have a “huge learning curve”, after a few days of trying you’re good to go.
ViewModel, LiveData, DataBinding
We can take advantage of using Architecture Components and Data Binding Library. The layouts in the app can bind to the data in the Architecture Components.
We could expose a
LiveData<ViewState> from the ViewModel.
ViewState should contain information about whether the data is currently loading, has loaded successfully or failed. [Resource]
Expose network status using a
Resource class that encapsulate both the data and its state.
Guide to app architecture | Android Developers
This guide encompasses best practices and recommended architecture for building robust, production-quality apps. This…
ViewModels, ViewStates, UseCases classes should be tested. Unit tests should test the main logic, following the “Given-When-Then” structure.
Worth to mention;
Lately, I created a project to provide a basic example,
This repository might be a starting point for building Android interview tasks. There is also providing a basic sample…
This repository might be a starting point for building Android interview tasks. There is also providing a basic sample template based on layered architecture using Dagger2 and Architecture Components. PRs are welcome!