Files structure in MVVM (Android)
Asked Answered
C

4

29

using MVVM or MVP should i name packages like model, viewmodel, view and put proper classes and interfaces there or is it just a logical structure that should not be visible in classes structure?

Chalfant answered 9/3, 2018 at 19:0 Comment(0)
T
17

If you want to go by the book, the current "correct" way to implement MVVM in Android is the Android Architecture Components set of libraries.

Read more about it here, and try this code lab. These will also show you how to name and place your classes.

But in general, you should go with what matches your app best. For smaller apps I would recommend going with M V P folders, while for bigger, more long-term ones tend to work better with folder-per-feature structure.

Thiel answered 9/3, 2018 at 19:6 Comment(0)
I
15

Google in it's sample Android Architecture project uses Model(Data) V(views) VM(view-models) file structure Google sample sunflower app to show architecture components Probably that's the best approach enter image description here

Irruptive answered 29/8, 2020 at 17:44 Comment(0)
D
11

Additionnaly you may find this resource interesting https://overflow.buffer.com/2016/09/26/android-rethinking-package-structure/ An implementation is visible here https://github.com/SamYStudiO/beaver

Dory answered 10/3, 2018 at 12:34 Comment(1)
That's the first android project structure that actually makes sense to me... Thank you!Glum
S
1

I also would like to indicate watching this TUTORIAL. This guy goes well on teaching about the Architecture MVVM and also uses the ROOM Persistence Library. It is worth giving a look at it.

Sami answered 9/7, 2020 at 0:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.