Another "which is better" question, I know these are highly subjective. My definition for better would be:
All of the Android blueprints use package-by-feature:
https://github.com/googlesamples/android-architecture
/tasks
/addedittask
/taskdetail
and all of the architecture components samples using package by layer:
https://github.com/googlesamples/android-architecture-components
/db
/model
/ui
/persistence
I'm confused because at the bottom of the Architecture Components site, it actually has links to the Android MVP and MVVM blueprint samples, which seems to me to be contradictory.
Based on Android Architecture guide, and on Clean Architecture, I would suggest this approach
data/
model/
remote/
local/
Repository
domain/
usecases/
GetUserListUseCase
presentation/
screen1/
screen1Activity
screen1Fragment
screen1ViewModel
screen2/
screen2Activity
screen2Fragment
screen2ViewModel
core
common/
di/
More here: https://www.toptal.com/android/android-apps-mvvm-with-clean-architecture
I think it depends on project size. Also in different companies team use different approaches.
I prefer to use in a small project second type of package managing.
If you want to reuse ModelView component, just keep them in feature packages. And maybe with this type:
/db
feature1/
feature2/
/model
feature1/
feature2/
/ui
/persistence
feature1/
feature2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With