https://kotlinlang.org logo
#announcements
Title
# announcements
u

ursus

03/11/2021, 4:13 AM
How do you name your Dao method in kotlin?
foo(), getFoo(), loadFoo(), findFoo()
?
m

Matt Rea

03/11/2021, 4:20 AM
I use
getFoo()
for in memory access and
fetchFoo()
for network/database
👍 1
v

Vampire

03/11/2021, 8:36 AM
Why not make it a property?
m

Matt Rea

03/11/2021, 3:50 PM
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

Vampire

03/11/2021, 4:13 PM
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

ursus

03/12/2021, 2:47 AM
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
7 Views