Maybe a bit out of case, but I see mostly naming c...
# android
a
Maybe a bit out of case, but I see mostly naming convention like
UserListFragment
,
UserDetailsFragment
,
UserListAdapter
,
UserListViewModel
. Now if I have all these open in Android studio I find it a lot harder to find which one is adapter, which is ModelView. Why not go with
FragmentUserList
,
AdapterUserList
,
ViewModelUserList
?
l
Then you open another ViewModel, another Adapter, another Fragment, and you have trouble finding which one is which…
a
hmmm... now this is a good point
So I guess I'd better go with the way I see in projects, the NameFragment, NameAdapter and so on
Thank you for your input.
In java I used the package name pojo to store the data classes, for kotlin could it be poko?
l
You can also just search a class by typing the
PascalCase
initials like
PC
, or
PasC
to quickly find what you're looking for. I used to code without tabs at all and was quite fine with that.
What do you call the "package name pojo", and what do you call "to store the data classes"?
a
I will try, thank you. I am figthing to do the switch to kotlin and I want to do things the right way. In my project structure there is a package mypackage.com.pojo where I store classes like class User, class Product and so on. POJO = Plain old java object
l
Oh, I usually call the subpackage
model
(as long as it's not part of a library, in which case I pick the package name more thoughtfully)
👍 1
a
Thank you very much for you help and time!
I am trying to figure out kotlin, jetpack and MVVM
l
@Alin B. Maybe the sample of an Android Library I am migrating to AndroidX can help you: https://github.com/LouisCAD/Splitties/tree/androidx-refactor
a
Wow, that looks like quite a project
l
Better understood in your IDE
a
👍 1
l
This can serve as a playground projet where you try things
Android-Sunflower: Good starting point too 👌
a
I did undertand how room works, room entities, the repository and ViewModel but I need to see how to properly continue with ViewModel->Fragment or activity and data binding according to MVVM pattern
I believe that I need data binding so the Fragment uses the ViewModel data but probably also get the events from fragment (like onClick) back to ViewModel to handle it there
l
You either use ViewModel data from a Fragment/Activity and edit the Views accordingly, or you can use databinding, or you can use a custom class that your Fragment/Activity instantiates
a
I see that DataBinding is recommended as it avoids using findviewbyid and updating manually
I'll see how LiveData and Observable gets mixed in VIewModel... these are new concepts for me so I need to digest them very well
l
You can see in the project I linked there are other ways of avoiding
findViewById(…)
😉
a
Are you using MVVM?
l
Sort of, when it makes sense. I avoid having too much logic in Activities, I use ViewModels, top level functions and #coroutines
a
Thank you very much for all your help and links! Time to get to study.