https://kotlinlang.org logo
#android
Title
# android
k

kevin.cianfarini

07/22/2019, 10:56 PM
I've heard conflicting views on this, but should I be avoiding the Kotlin synthetics for binding views?
j

jw

07/23/2019, 12:45 AM
Well that's because it's opinion based. And by asking the question again, you'll get the same set of differing opinions.
I vote no, if it matters.
r

rkeazor

07/23/2019, 2:20 AM
I second that. For every piece of technology/framework/library/language/architecture , There is always at least 10 devs that hate it😂
p

pg

07/27/2019, 11:33 AM
As far as I know, kotlin's synthetic view binding is hated due to no view caching in some cases. Despite of it, I like synthetics, always simpler than delegates / annotations or whatever. In my opinion workaround for mentioned cases may be something like this: val btn : Button = xx_yy_button Although not tested by myself yet.
j

jw

07/27/2019, 11:50 AM
It also lacks safety that the references are actually from the layout you're using and are present in every configuration of that layout.
🤔 2
r

rkeazor

07/28/2019, 11:19 AM
@pg are you sure about that? I believe there is caching... look at section on view caching
k

kevin.cianfarini

08/07/2019, 2:26 PM
@jw when you say you vote no, do you mean I shouldn't avoid them or I should avoid them? I'm assuming no
j

jw

08/07/2019, 2:26 PM
Avoid
k

kevin.cianfarini

08/07/2019, 2:27 PM
gotcha, thanks