getButterfly Logo getButterfly

Have you ever used the same code two or more times in different projects? What’s your excuse for not turning it into a library or a framework?

While working as a code wrangler or a programmer, you inherently run into the same issue multiple times. You need to create a function, a class or a routine to do something trivial (or not) for each of your projects. As an example, I could say a database connection layer, or a CRUD system, or a user authentication library. It would be handy (and time saving) to have one ready to use. Remember your previous project? You coded a complete one. Now it’s time to reuse it and improve it in the process.

If it’s still possible, you can also update your previous one and add some documentation.

And this is how you code your own library and, next time you’ll need it, it will be there, documented and ready to plug and play. This is relative, though, and I try to keep my libraries as decoupled from the parent project as possible. This might not be that easy the first time you code it, but the second time you find out exactly what you need to turn into a variable or to convert into an array or to group into a different block of functions.

I have some examples of my own. I have an internal database layer called nuuk (still unpublished) and a user authentication module (already used for an affiliate system, a project management application and a wishlist module, all for different clients). After using the authentication code three times, it became very versatile and I have a configuration file ready to be populated with the current project’s details.

That reminds me to update my nuuk database layer.

Subscribe to getButterfly Blog

Once a week or so we send an email with our best content. We never bug you, we just send you our latest piece of content.

If you found any value in this post, agree, disagree, or have anything to add - please do. I use comments as my #1 signal for what to write about. Read our comment policy before commenting! Comments such as "Thank you!", "Awesome!", "You're the man!" are either marked as spam or stripped from URL.

Leave a Reply

Your email address will not be published. Required fields are marked *