How do you name your Dao method in kotlin? `foo(),...
# announcements
u
How do you name your Dao method in kotlin?
foo(), getFoo(), loadFoo(), findFoo()
?
m
I use
getFoo()
for in memory access and
fetchFoo()
for network/database
👍 1
v
Why not make it a property?
m
Eh you could. Personal preference. Easier mocking with tests. Also allows you to mutate the value before returning in the getter. You could do that with a property, but feels better in a function, in my opinion
v
You can easily have a custom getter for the property and do any mutation you want. I usually do it like this: "does it return you some value for the class and not take a parameter => property" if it needs parameters or the returned value is just a side-effect or status value and the main purpose for the "thing" is to do something, then method. 🙂
👍 1
u
properties are annoying on Daos since they often have parameters, and I dont like mixing props and funcs fooDao.findById() etc .. so .. find? 🐤 lol
I see Room documentation mixing
load
and
find
in the same sample