Member-only story

Clean architecture in Android (Jetpack Compose, Kotlin, MVVM) ーPart- 1

Farhan Tanvir
5 min readJan 31, 2022

--

Photo by Danial Igdery on Unsplash

Making an android application is kind of easy( Compared with creating with Clean architecture . Please feel free to debate me 😃) but making an application with clean architecture is another thing. Recently I am learning about clean architecture on Android. Today I will talk (Actually write )about it.

First, we have to know some theories. I know theories are boring. So I will make it as short as possible. Also, I have created a GitHub repository about this. So feel free to check it.

Why do we need clean architecture?

Coding is an art. An application does not mean it works and meets UI/UX requirements. It also needed to be easily understandable, flexible, testable, scalable, and maintainable(Lots of fancy words . I know 😃). For a simple application, it may not be needed but for a robust one, it is mandatory. Clean architecture is a hot topic in mobile application development. Because the complexity in mobile applications is increasing. So as a developer we must have knowledge of this.

Layers of clean Architecture

There are three main layers of clean architecture.

  1. Domain: Execute business logic that is independent of any layer and is just a pure Kotlin package with no android specific dependency. It includes the Model, Use case, etc.
  2. Data: Provide the required data for the application to the domain layer by implementing the interface exposed by the domain layer. It includes Remote / Local data sources, API implementation, etc.
  3. Presentation/ Application: It contains android specific code which executes the UI logic. It includes View, Fragment, activity, dependency injection, etc.

I just describe according to my understanding. If you want to know more please check this blog.

TL;DR

  1. Domain Layer can not access any Layer, Data layer can access only Domain Layer, and App layer can access both.
  2. UseCase is used to take requests and pass data to the request mainly in the Presentation/App layers. UseCase is in the Domain layer.
  3. The domain layer only has Kotlin/Java…

--

--

Farhan Tanvir
Farhan Tanvir

Written by Farhan Tanvir

Believes in learn by doing . Currently working as a software engineer. Love to share Knowledge. https://twitter.com/FarhanTanvirBD

Responses (7)

Write a response