Common Static Classes
Michael Christensen-Calvin / October 2023 (118 Words, 1 Minutes)
Common Helper Functions
When I was working on a fairly large mobile game team all working out of a single codebase, at certain points we would realize that all of us had reinvented the wheel a bunch of times solving the same problems. This lead to repeating very similar code in many places in the project. Besides being ugly and a waste of time ,it also made it very annoying to optimize further down the road. This lead to us having a standard practice of creating a series of static Common*.cs classes where shared oft-repeated code could live. (e.g. CommonMath.cs, CommonVector.cs, CommonText.cs, etc..) Anytime we were doing code-reviews if we saw something that looked like it would need to get repeated, we would make a note of moving it into a Common class, and that would get resolved before we merged that PR into the main branch.
Even while working solo, I have tried to maintain this practice, as it can be very helpful down the road. Not only do I have a built up library of easy to access functions that do what I want, but if I find an optimization down the road there is a good chance I can just update the Common class, and everywhere that was using it would benefit from that optimziation.
These classes live in a seperate repo that I have and bring in as a submodule to all of my game projects (this same repo holds all my global funcitonality, like PlayFab login/auth flows, AudioSource management, etc..).
It has a bunch of stuff in it that make me not want to make it into a public repo as-is, but I’ll probably try to post some of my classes in case they are useful to others: