My code has a place where constant values live that is accessible from everywhere. This makes it easy to get at things that never change without any complicated stuff. I’ve named it Constants. Yep, stayed up all night thinking of that name.
In the constants, there was an engine version number value. I upgraded that from an integer value to a class that wraps up a custom flavor of a canonical version into a 32-bit integer. At first glance this seemed like this was going to give me the version number flexibility I wanted, but instead it instantly blew up 38 of my tests.
Constants is a static class so when the program starts up it is automatically created. In the process it tries to create the version number class. Which in turn tries to use constants that don’t exist yet because they are currently in the middle of being initialized.
So how do you include a constant for the version of your game, if the thing that represents a version number uses constants? In this case, I created a second place to hold a special type of constants called look up tables. By separating them out of the core constants, they can exist separately from constants and be available to create a version number, which can then live in the core constants.
Dizzy yet?
