Stephen Siapno Help

Android Architecture

Android Clean Architecture

Apppresentation layerApp Componentdomain layerdata layerViewModelUI ComponentUseCaseRepositoryDataSourceSourceDataRepositoryAPIdatabaseother packagesusesdependsdependsinjectimplementsdependsimplementscan depend oncan depend oncan depend on

Conclusion

Modularization

UI android libraryApppresentation layerkotlin core librarydomain layerandroid data librarydata layerUI ComponentApp ComponentViewModelUseCaseRepositoryDataSourceSourceDataRepositoryAPIdatabaseother packagesusesusesdependsdependsimplementsinjectdependsimplementscan depend oncan depend oncan depend on

Conclusion

Model View ViewModel (MVVM)

MVVM Diagram 1

ViewViewModelModel1. invoke4. observe result2. invoke3. return result

MVVM Diagram 2

AppViewApp ComponentViewModelmodelUI ComponentViewModelsDataSourceSourceDataRepositoryRepositoryAPIdatabaseother packagesusesdependsinjectimplementsdependsimplementscan depend oncan depend oncan depend on

Conclusion

Model View Intent (MVI)

MVI Diagram 1

ViewViewModelModel1. invoke intent4. observe state2. invoke3. return the result

MVI Diagram 2

ViewViewViewModelViewModelRepositoryRepositoryEvent Handling1observe state2onIntentHandle Intent3handleIntent4get the needed API5return the data6return resultResult to State7reduce resultToState8return stateShow state9state changes

MVI Diagram 3

AppViewApp ComponentViewModelmodelUI ComponentViewModelsDataSourceSourceDataRepositoryRepositoryAPIdatabaseother packagesusesdependsinjectimplementsdependsimplementscan depend oncan depend oncan depend on

Conclusion

Choosing the Right Architecture

Selecting the appropriate architecture for your project is crucial and largely depends on factors such as project size and scalability goals.

There are various approaches to structuring your project, each with its own benefits and considerations.

Below, I outline my preferred approaches and considerations for selecting the appropriate architecture based on the project's size.

For Small projects

1st Approach

MVVM

2nd Approach

MVIMVVM

3rd Approach

Modularization

For Medium to Large projects

4th Approach

ModularizationMVVM

5th Approach

Clean ArchitectureMVVM

6th Approach

Clean ArchitectureMVIMVVM

7th Approach

ModularizationMVIMVVM

For Large to Enterprise projects

8th Approach

ModularizationClean ArchitectureMVIMVVM

Reflection

Selecting the right architecture is a crucial decision that can significantly impact the success of your project. By considering factors such as project size, scalability, and specific requirements, you can choose an architecture that best fits your needs.

Whether it's modularization, clean architecture, MVVM, or MVI, each approach offers unique benefits and considerations. Remember to continuously evaluate and adapt your architecture as your project evolves to ensure scalability, maintainability, and overall success.

Last modified: 07 March 2024