How to maintain a personal reusable code library

github logo ・1 min read

Hello devs,

Today I wanted to start a little debate about reusable code. As a (web) developer and more specifically a data analyst, I always find myself searching for old code that I wrote, to copy 'n' past it in my newest project.

I was thinking about making a library just for myself but most of the time, the context changed (even slightly) with the years, and it's quite hard sometimes to reimplement the copied method.

So, what are your little tricks about it? Do you build an entire API that you reuse all the time? Or maybe you have a use huge list of method references wrote in Markdown on an old HDD?

twitter logo DISCUSS (3)
markdown guide
 

I had this issue recently because of a couple of modules I wanted to reuse. I thought about creating a shared repository in Github and then pull it from both projects but it was too much of a hassle. I ended up copying over the modules and their tests in the new project.

So my technique is still copy and paste. Keep in mind that they might evolve differently (and in the end they did) so creating a shared library for so little functionality wasn't worth it.

Creating a library might be worth it if you keep working with the same technology in different projects or with a team.

I would consider the mono repo architecture for shared code also.

 

I understand your point and it is what I thought too. Creating and keeping a personal library up-to-date is too much work for what it's worth.

And about using the same technology, I have to find a way to mix different languages at the same place.

So what I did until know (but it can be time consuming), is to force myself to write a good external documentation for most of my projects, through private repo for example. And then search on them when I want to recreate something similar.
I'm saying this because sometimes find the class/method within the code can be tough.

 

I keep a mental list of terms to Google to find MDN articles and whatnot.

I'm trying to get better about keeping actual snippets, but I'd need it to be readily available at work and home, so it's hard finding a solution for that. I have a home Mac and a work Mac, so cross-platform isn't a problem, but I technically am not able to have external media or cloud storage at work (the outlaw does not apply to Macs, but I want to respect the rule at least), and notebooks aren't searchable.

Classic DEV Post from Mar 29

Speed of Voice - The Pace of Your Presentation Can Heavily Impact How Well it Lands

Learn how to control the pace of your voice in your presentation to land your message

Rospars Quentin profile image