A Sample Project for your Android Interview Assignment

Murat Can Bur

This article 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.


Application Architecture

  • 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.

Package Structure

data

The data package contains networking classes, database classes, entity models, network request and response model.

domain

The domain package contains our business objects and contains the Use Case classes used to interact with these from other packages.

ui

The UI package contains UI components of the application. UI package has child packages that are organized as feature-by-layer.

Dagger Architecture

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

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.

Unit Testing

ViewModels, ViewStates, UseCases classes should be tested. Unit tests should test the main logic, following the “Given-When-Then” structure.

https://github.com/muratcanbur/ProjectX/blob/master/app/src/test/java/co/icanteach/projectx/PopularTvShowsTestSuite.kt

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 template based on layered architecture using Dagger2 and Architecture Components. PRs are welcome!

Murat Can Bur

Written by

Blogger, Android Developer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade