Clean Architecture - Kotlin, MVVM, Use cases

Overview

CleanArchitecture

Screenshot

Is Clean Architecture only MVVM ?

NO, MVVM is a part of clean architecture. MVVM includes Model, View and ViewModel and in addition to this, Clean architecture has one more layer which is USE CASES.

What is a USE CASE & Why do we need them ?

In MVVM, we use to put all our business logic into our ViewModels but the problem with that is, the bigger your project gets, the more number of ViewModels you have and all your business logic is divided into various viewModels. That’s where clean architecture comes into the picture, we use USE CASES instead of ViewModels for all our Business logic.

Now, we understood why do we need use cases? But What are Use Cases?

Screenshot

Use case is an action we can do within a feature.

For ex. We have feature called “Profile” which can have actions such as

  • Getting user profile data
  • Updating user profile photo
  • Editing user profile

All the above are USE CASES of a feature.

Advantages of Use Cases :

  1. Helps removing code Duplication : Now if we want to get User Profile data in two different ViewModels, we can easily call one method from our USE_CASE class instead of putting the same method in two separate ViewModels.

  2. Screaming Architecture : The term “screaming architecture” is used when we can, just by looking at a new project at a glance, get the core idea of what the project does and what it is about. Similarly, Use Case should be made in a way that anyone can understand just by looking at the class name that what it does . For ex. GetUsersUseCase is used to get list of users from a data source.

Screenshot

HOW SHOULD YOU DIVIDE YOUR PROJECT ?

The code is divided into three separate layers:

  1. Presentation Layer which includes all UI stuff, Composables, XMLs, Views & ViewModels.

Screenshot

  1. Domain Layer contains our Business Logic (most important our USE CASES)

Screenshot

  1. Data Layer contains our data, all our Databases and Repository Implementation.

Screenshot


Screenshot

You might also like...
Template for MVVM Architecture Clean Code.
Template for MVVM Architecture Clean Code.

Template for MVVM Architecture. This is basic template for android app follwing MVVM architecture and latest tech stack. You don't need to create and add basic code and depency for start project using MVVM architecture. Just use this template and boost your productivity.

Followed best practices, MVVM, clean architecture and coroutines.
Followed best practices, MVVM, clean architecture and coroutines.

GitHub Profiles Video Walktrough Using Github public API allows users to search Github profiles through the username. It shows the necessary informati

MVVM RECIPE ANDROID APP Is an app where I show how to use MVVM, retrofit, dagger hilt, coroutine, liveData, Kotlin, navigation component, and so on...
MVVM RECIPE ANDROID APP Is an app where I show how to use MVVM, retrofit, dagger hilt, coroutine, liveData, Kotlin, navigation component, and so on...

MVVM RECIPE ANDROID APP Is an app where I show how to use MVVM, retrofit, dagger hilt, coroutine, liveData, kotlin, navigation component, and so on...

📝 A demo todo/notes app which demonstrates the use of MVVM architecture, Navigation Component Library, Room Database, LiveData, Coroutines
📝 A demo todo/notes app which demonstrates the use of MVVM architecture, Navigation Component Library, Room Database, LiveData, Coroutines

📝 MyNotes A demo notes/todo app which demonstrates the use of MVVM architecture, Navigation Component Library, Room Database, LiveData, Coroutines et

A more lightweight and simpler to use MVVM architecture for Android.
A more lightweight and simpler to use MVVM architecture for Android.

A more lightweight and simpler to use MVVM architecture for Android, Data and views are two-way bound.

A full-featured framework that allows building android applications following the principles of Clean Architecture.

EasyMVP A powerful, and very simple MVP library with annotation processing and bytecode weaving. EasyMVP eliminates the boilerplate code for dealing w

Template for using Clean Architecture Concepts in Android
Template for using Clean Architecture Concepts in Android

AndroidCleanArchitecture Template for using Clean Architecture Concepts in Android We have separated the layers into three main group Presentation/App

Playground project built with MVVM with Clean Artchitect to try out new tech in Android 🌍

Clean-MVVM-Playground Playground project built with MVVM with Clean Artchitect to try out new tech in Android 🌍 Features 🕹 100% Kotlin Following MVV

MVVM + Clean + Hilt + Mockk

Android - MarvelApp What is this repository for? This repository is to show you my skills programming native Android. If you are interested in my prof

Owner
Deepanshi bajaj
Contributed in all aspects of Android App lifecycle from research and planning through deployment and post launch support.
Deepanshi bajaj
Chat App MVVM + Clean ArchitectureChat App MVVM + Clean Architecture

Chat App MVVM + Clean Architecture This Android application built using MVVM + Clean Architecture architecture approach and is written 100% in Kotlin.

null 2 Nov 18, 2022
🎯 Einsen is a prioritization app that uses Eisenhower matrix technique as workflow to prioritize a list of tasks & built to Demonstrate use of Jetpack Compose with Modern Android Architecture Components & MVVM Architecture.

?? Einsen Einsen is a prioritization app that uses Eisenhower matrix technique as workflow to prioritize a list of tasks & built to Demonstrate use of

Sanju S 835 Nov 23, 2022
📊 A Minimal Expense Tracker App built to demonstrate the use of modern android architecture component with MVVM Architecture

Expenso ?? A Simple Expense Tracker App ?? built to demonstrate the use of modern android architecture component with MVVM Architecture ?? . Made with

Sanju S 804 Nov 29, 2022
An android app built using Kotlin following Multi-Module Clean Architecture MVVM

RickyandMorty An android app built using Kotlin that consumes RickyadMorty API to display characters.It has been built following Clean Architecture Pr

Kibet 14 Sep 2, 2022
JeTaxi is built on Clean Architecture-MVVM with Kotlin and follows modern android development trends.

JeTaxi is built on Clean Architecture-MVVM with Kotlin and follows modern android development trends. Also, It uses some of Jetpack and popular libraries. These are Kotlin Coroutine-Flow, kotlinx.serialization, Hilt, Compose, Accompanist, Retrofit2, OkHttp3, Chucker, MockWebServer, Truth.

Tolga Bolatcan 13 Nov 2, 2022
AAC MVVM + Clean Architecture + Coroutine Flow

GithubBrowser MVVM Clean Architecture Sample AAC MVVM + Clean Architecture + Coroutine Flow 본 샘플 프로젝트는 https://github.com/omjoonkim/GitHubBrowserApp 을

Jeonguk-JayDev 18 May 25, 2022
An Android Template with MVVM and Clean Architecture

MVVMTemplate ??‍ A simple Android template that lets you create an Android project quickly. How to use ?? Just click on button to create a new repo st

Hossein Abbasi 525 Nov 25, 2022
A simple Cat Search app, performed the search by cat breed name, using MVVM clean Architecture.

CatSearchApp A simple Cat Search app, performed the search by cat breed name, using MVVM clean Architecture. The App is using the The Cat Api for sear

Mansingh Bhati 2 Oct 20, 2022
Image Search used MVVM with Clean Architecture

ImageSearchCleanArch Readme In this project I used MVVM with Clean Architecture. MVVM provides a clean separation of concerns between user interface a

null 2 Jun 14, 2022
Retrieve Data from an API using MVVM Clean Architecture and Jetpack Compose

MVVM Clean Architecture Demo Retrieve Data from an API using MVVM Clean Architecture and Jetpack Compose. It simply shows a list of movies fetched fro

Daniel Kago 2 Sep 16, 2022