https://kotlinlang.org logo
#random
Title
p

Paul Woitaschek

08/28/2019, 7:46 AM
A short discussion on naming (I'm not a native speaker). Let's say I want to express how many % of the daily calorie goal the user consumed on protein. If I have the number in
[0..100]
, I might name the property
proteinPercent
. Does that make sense? How would you name the property if it was in
[0.0..1.0]
?
d

darkmoon_uk

08/28/2019, 7:47 AM
For
0.0..1.0
I would use
dailyProteinIntakeRatio
For
0..100
-
dailyProteinIntakePercent
...without being close to your App of course, could be better names.
p

Paul Woitaschek

08/28/2019, 7:50 AM
Copy code
data class Goal(
  val date: LocalDate,
  val caloriesInKcal: Double,
  val fatIntakeRatio : Double,
  val proteinIntakeRatio : Double,
  val carbIntakeRatio : Double,
  val weightInKg: Double,
  val waterInMl: Double,
  val steps: Int
)
Makes sense to me in that context, thanks!
Ah and AS complains that
carb
is a typo. Is there a better abbreviation?
I dont want to type carbonhydrate 😉
w

wasyl

08/28/2019, 7:52 AM
would
carbs
complain as well?
p

Paul Woitaschek

08/28/2019, 7:52 AM
Yes. But does carbIntakeRatio feel like a typo for a native speaker?
🤷‍♂️ 1
🚫 2
Then ** off android studio, thanks 🙂
w

wasyl

08/28/2019, 7:58 AM
I suppose that’s why you can add custom words to the dictionary 🙂 If it can be shared in the repo, that would be good solution, since clearly
carb
is a word that suits you best
d

darkmoon_uk

08/28/2019, 7:58 AM
The Android Studio dictionary is limited, don't take it as a 'source of truth' for English.
Carbs is an abbreviation, but a common enough one - by all means run with that.
p

Paul Woitaschek

08/28/2019, 8:00 AM
Ah I have another one: What would be good names for "number of digits before the dot" and "number of digits after the dot"?
d

darkmoon_uk

08/28/2019, 8:03 AM
integralDigitCount
and
fractionalDigitCount
?
w

wasyl

08/28/2019, 8:06 AM
or
decimal
for after the dot
Actually since these look like a domain model questions, I’d personally try having a chat/call with your domain expert (typically PO/PM) to ask him about the specification for the task. I’d then use exactly (within reason) the names they use 😄 As long as there is someone who defines the spec, of course
p

Paul Woitaschek

08/28/2019, 8:11 AM
I am my domain expert 😛
👌 1
w

wasyl

08/28/2019, 8:12 AM
In that case no easy way out 😄
e

Eugen Martynov

08/28/2019, 11:30 AM
I read “carbs” term in many books around food and sugars