Another code-cleaning exercise

Project Page Next project post Post History

I recently made a post about coding better helper tools, where I explained how I was able to speed up project build times significantly by making some helper functions more efficient. It really sped up development and build times, particularly for my larger projects.

Today, I spent some time reworking my main library file. This file has a bunch of functions I made that can be regularly used by different projects. See, this library file I can put into any project. And I can call the functions in it anywhere in any project. It's a really handy way of writing something once that everything else can use - that is, you don't need to write the same code twice for two different (or more) projects.

I redesigned the file quite a bit. I also collated a few other files I had made and added their functions into the library file. It means I now have one source of truth, and I can make my own 'library' functions that can be used in any project I add the file to.

I even went so far as adding in code that lets me add or remove many of these functions from projects, on a per-project basis, so that functions that weren't used in a project can be ignored at build times. This can help speed build times up a little, but it can also help make the end project file size smaller. I've now got it down to basically one line of code that lets the compiler know what parts of my single library file to include, and what parts to ignore, when compiling a project.

This has made how I use my library functions much more global and efficient. It's also made the build times a little quicker, and made the end compiled project file size a tad smaller across the board.

Like the previous post on coding better helper tools, this has been a worthwhile exercise. It's helped me standardise my project structures, and made working with code that utilises the same thing much more efficient and easier to work with.

Another really worthwhile code-cleaning exercise! I'm quietly enjoying this. I really feel I've got something good brewing here.