Clean Architecture in Android

Clean Architecture in Android

Clean architecture is a method of software development in which you should be able to identify what a program performs merely by looking at its source code.


Is there a need that we should follow architecture for an Android App development?

The answer would be obviously YES because following good architecture helps in many ways like reducing the development time, easy understanding, low maintenance, etc. 


There are many architectures out there like MVC, MVP, MVVM, VMI


Robert C. Martin, also known as Uncle Bob, came up with the Clean Architecture concept in the year 2012. 

Why Clean Architecture?

  • Separation of Concerns — Separation of code in different modules or sections with specific responsibilities making it easier for maintenance and further modification.
  • Loose coupling — flexible code anything can be easily be changed without changing the system
  • Easily Testable


Clean Architecture just extends the MVVM with an additional layer of use cases. Which contain over-business logic.

In MVVM we contain business logic over ViewModel, so the problem with this is that when we scale the project you get Bulki ViewModel with a lot of lines that get everything. It just feels like a one-man army class. This is the one thing, this clean architecture approach tries to avoid. so now we use the use cases for businesses logics. use cases are kind of a feature of your app, so let's first understand what is feature. 

For example, get user profile data, edit the profile, or you can say update the profile picture. All these would be use cases, so the single action we can do with a single feature is over the use case. The big advantage is that they, on the one hand, are very reusable, so if we have an additional layer with use cases then we reuse that, for example, we have two viewModel and we need the same feature in both so we just call it in both ViewModel or in the other class of application where we need. if we assume we can't have a use-case class so in both ViewModel we write the same code.


Github : sadahacks/ComposeWithCleanArchitectureBaseProject (github.com)

Muhammad Ilyas

SE @Kwanso | AWS Certified ~ DevOps enthusiasts ~ Nest ~ Node.js ~ GraphQL ~ Typescript ~ Serverless - IaC | xNetsol

2y

Keep it up 👌

Like
Reply

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics