`Where do you keep your Extension methods?`
# android
v
Where do you keep your Extension methods?
p
In a single file if there are less numbers of extensions. If there are more, I create one file per type.
v
So if you need extension for Context you will create Context.kt and put everything there? That’s what I am currently doing
but I was thinking maybe somehow prefix that file ex:
_Context.kt
or
ContextExt.kt
or
ExtContext.kt
p
No prefixes. Just
Contexts.kt
. I personally use plurals, your personal preferences can be bit different.
👍 2
In case you need example, here is a utility library, and I arrange extension classes just like it’s arranged in this library https://github.com/PrashamTrivedi/UtilsLibrary
u
I like ContextExt.kt
v
I like more
_Context.kt
not self explanatory name of-course, can be also
Context+.kt
?
s
I like way with only "classname" for name file with Extensions, bcs if u package named extensions or utils , you probably will have all files like ContextExtensions.kt, Some1Extensions.kt, Some2Extensions.kt etc.
c
My team does the following:
<Type>Extensions.kt
So for Context it’d be
ContextExtensions.kt
p
@Cody Engel This is my second favorite style. 🙂
v
Thanks all ! Yes I also like ContextExtensions.kt
👍 1
👍
w
we also do <Type>Extensions.kt. We do a lot of navigation by navigate to file, so the name needs to be descriptive enough to know exactly what we're getting. We have a pretty big team, and this helps avoid confusion.
👍 1
i
ContextExtensions.kt