Hi, I'm a Compose newbie. What's the convention fo...
# compose
m
Hi, I'm a Compose newbie. What's the convention for naming functions that replace their Material Design equivalents, e.g. I have a nice custom
TextField
, so what should I call it? Is the convention to just rely on package namespacing and keep the same names?
k
For your own usage, or as a library to be used in other apps?
m
Own usage
k
Doesn't matter then, as long as you know which one is which
s
We use
HedvigFoo
where
Hedvig
is the company/app name. Now In Android app does the same with
NiAFoo
components existing
They’ve gone a step further by adding some lint checks to make sure not to use the “wrong” component, and use the
NiA
alternative instead Can take a look here https://github.com/android/nowinandroid/tree/main/lint/src/main/java/com/google/samples/apps/nowinandroid/lint/designsystem
m
I was thinking that might be the answer....
s
The answer is whatever you want it to be, as Kirill suggests. But the app/company name is a sane default provided the name is convenient to write all the time 😅 Otherwise if your design system has a name, that’d be the best option imo
m
If you later decide to switch from a built in control to a customized one, that's a global search/replace?
s
I’d do it more for consistency and to have all devs know what to start typing to get the right autocompletion options. That’s the big win imo
c
@Stylianos Gakis NICE! I can just copy that lint check for my own purposes too. Thank you!
s
Yep, the NiA repo has been a gift that keeps on giving for me. And not even for production code (that too though), but I’ve changed a bunch of stuff in our repo around gradle, convention plugins, CI setup and so on, all from looking at that repo 😅
c
oh yeah. convention plugins is super high on my list to learn. i should probably just jump into it as it can't be that hard... can it? lol
s
It’s not even that hard no. It looked super daunting before getting into it, but the NiA repo proved that it’s actually very straightforward. You can look at the list that they have there. Or can even look at the ones I’ve made after taking inspiration from it. Applying ktlint Applying apollo-kotlin Applying a jvm library Applying an Android library And so on, you can look at the rest too.