When programming I accumulate code snippets and utility classes. I want to store those for practical future use.
The question briefly is what is the best way to do this. More elaborate with an example:
When writing code we keep reusing our nice tidbits to cover common tasks. However in order to make our projects open source, say with git on github, this tidbits also need to be available. I was wondering how to best do this.
- Do I make my personal utilities repo that projects can add as submodules in git?
- Or do I make separate git repos for each tidbit, so a project can add a specific version of a specific tidbit as a submodule. (this addresses a problem with utility libraries like boost, which get huge even though your program might only need a small portion of it)
- Or do I combine both into a a utility repo with submodules where the external projects can have the utility repo as a submodule? What happens if they want to use version x of tidbit a and version y of tidbit b? Could be nice just to have a centralized overview?
Like all public code, snippets like that should be light, fast, tested, portable, documented and preferably relatively self contained. Now I find this nice code somewhere and it uses CTASSERT, which is not portable.
What should I do?
- I can use boost static_assert, but that adds a major dependency to a little code snippet, because boost is not trivial, and on my system it compiles to about 2GB. To make things worse, it also adds this dependency to every project using the snippet which provides some quite basic functionality. Further, boost as far as I know has no git repo, so a project can not automatically take care of this dependencies with a submodule.
- Do I make another snippet and pull my own compile time assert with the silly side-effect of reinventing the wheel and creating more code doing things that boost already does.
Im looking forward to hearing how you solve this problem, and general thoughts and guidelines.