Colton Idle
11/08/2021, 5:58 PMis at the start of a boolean name in kotlin?
Basically need to create a bool called isDebug but arguing with myself if it should be debug or isDebug .Klitos Kyriacou
11/08/2021, 6:08 PMisDebug() then Kotlin creates a property called isDebug. So, yes, add the is prefix.Richard Gomez
11/08/2021, 6:10 PMval isGoodPractice = trueShawn
11/08/2021, 6:37 PMis as a prefix makes sense (in order to make code read more expressively) but using it indiscriminately is basically just Hungarian notation with extra stepsShawn
11/08/2021, 6:46 PMdebug flag to some kind of config, then you go to use it, which results in the callsite looking like this
if (config.isDebug) {
...
}
which reads like “if the config is debug, then…“, which doesn’t really make a whole lot of sense. You might try to make it a bit more descriptive like this
if (config.isDebugMode)
but really, I think that just makes it obvious that you should omit is in this case, and just write something like this
if (config.debugEnabled)
I’d try to reserve usage of is in cases where the boolean describes the state of its container or otherwise actually makes a conditional read more sensiblyShawn
11/08/2021, 6:47 PMthanksforallthefish
11/09/2021, 6:56 AMdebug generates a method getDebug(), calling it isDebug generates isDebug() . depending on what library you use (or is you want your library to be used in java) I think the second convention is more solid (naming convention for boolean getters is - or at least was, honestly not sure anymore - isMyBool)Tobias Suchalla
11/09/2021, 2:57 PMhas as in Node.hasChildren. So I'd say it depends a bit on your preference and whether you want the special Java interop or not.