3 ms·
Code reuse is a powerful feeling of productivity in programming, however in many cases the pains outweigh the gains. After making several npm packages, I've le
by gitgud 7y ago
Code reuse is a powerful feeling of productivity in programming, however in many cases the pains outweigh the gains.
After making several npm packages, I've learnt that you need to put yourself in another frame of mind to reuse code. Here's some concrete steps in order to create good reusable components.
0. Ask yourself if this is this worth the overhead of code reuse???
1. Think from the perspective of the user of the component (because you will be the user in most cases), what's the most logical way to use and customise this thing?
2. Simplify the getting started as much as possible, it's much harder to reuse if it's complex to add to a project.
3. Remove as many dependencies as possible, this makes it simpler, lighter weight and allows more options for users of the package, (they can use different versions etc..).
4. Try to make an MVP and iterate on it.
5. Strive for backwards compatibility where ever possible.
There's probably many more good points I'm missing, but that's a few that I think are important.