I'm looking for some wisdom on writing Kotlin libr...
# announcements
f
I'm looking for some wisdom on writing Kotlin libraries, specifically for Android in my case, specifically for helping write the couple of apps that I support. Sometimes I feel like it's too hard to balance what goes in the library and what goes in the app, or the libraries are too small and not worth it. Any tips?
1
b
Even if the library is a single package, it's worth it if that means not maintaining multiple copies of that code in the projects. Have a look at npm, there are thousands of single function packages that are widely used
n
This thread should be moved to #android.
b
Why? Android has nothing to do with the question
👍 1
m
Why the - reaction? It’s a perfectly legit question about library design.
f
thx folks, because of timezone I think the replies showed up after my Friday was finished. There's a significant overhead of having and editing and building new versions of libraries. I'm not familiar with npm libraries development cycles when tightly or loosely coupled with application development, So I can't say if that argument is reasonable or not to my goals.
m
Personally, I wouldn’t take npm’s trend of single-function libraries as a virtuous example, quite the opposite in fact, as the left-pad incident showed! What you need to consider is how much common code exists between the apps that could go into the library. I wouldn’t put UI code into the lib, because that would probably need to change independently from one app to the other. Surely I would group together common logic, configuration and utilities, pretty much anything you have duplicated between the code bases and think it could be shared. Keep in mind that you’re creating a lib specific to your apps, so you don’t need to design it for a general usage, like Guava for example.
1
💯 1
b
I was talking more from internal libraries side of thing. Basically as a way to maintain DRY code
f
Yep it's all internal use at the moment , and my biggest goal is Dev speed and avoid repetition