I'd say this is not the "naming things" that's hard. Beyond picking a common identifier format in the team, there are at least two dimensions that are much harder:
- The language dimension - choice of words, that are good enough for the purpose, and not confusing. For example, "Manager" is as ambiguous as it gets, it can mean many thing, except we've been using it long enough that there's a more specific shape of meaning[0] for that word in code/program architecture contexts - so you still would use it instead of, say "Coordinator", which would raise all kinds of questions that "Manager" no longer does.
- The epistemological dimension - whether the word you chose correctly names the concept you meant, and whether the concept you meant is actually the right one to describe the thing you're trying to describe. Ultimately, this is the hard thing at the root of philosophy. In practice, it manifests like e.g. choice between digging into some obscure branches of mathematics to correctly name the thing "endofunctor" or something, or calling it "Square" and saying "fuck it, we'll clarify the exceptions in the comments".
--
[0] - I mean "more specific" in the sense it's distinct from the other meanings and somewhat narrow - but still it's fuzzy as heck and you can't describe it fully in words; it's basically tacit knowledge.
I try to name things descriptively in simple terms and often end up with NamesAboutThisLong, once they get too long i know the thing is doing too much and some refactoring is needed for readability.
I also avoid letting the reader make assumptions. HasPlayerJumpedRecently is bad. What does recently mean? HasPlayerJumpedInLastTenMs is better, even if it's a bit long...Which highlights that it should probably be refactored into a more flexible value; MsSincePlayerLastJumped.
If you arent assuming a time var wth Ms is milliseconds you aren't doing games dev so that one slides with me.
Wow cool, you just summed up something I’ve found myself doing subconsciously in the past few years. Thanks!
I use to be quite fond of short identifiers, especially ones the make the signs “line up”… until I worked with code long enough that I forgot what I did and had to read it again.
That's a great example. Personally, even beyond gamedev, units are an exception for me - they need to be somewhere, whether in type or in identifier name (or ideally both), or else bad things happen.
But that's what I meant by the epistemological aspect - what is "recently"? Still, "LastTenMs" is arguably even worse - why ten? Did you really mean "since last frame"? Then say "SinceLastFrame". Did you mean "since 2x update time delta"? Then maybe make a PlayerJumpCooldown constant, but then maybe it's not about cooldowns, so... here's when I'd probably say screw this, let's just track MsSincePlayerLastJumped and add a HasPlayerJumpedRecently() -> bool as a helper, with a fat interface comment explaining what "recently" means - and go back to talk with the game designers to give a more specific name for the "recently" thing here.
Point being, this is deceptively hard - doubly so because going all perfectionist about it is also bad.
I admit my example is slightly contrived and LastTen still raises questions re frames and time handling, especially as its so small, oops! Lets pretend i said LastHundred and its using a framerate independent method.
If i were to helperise it with a bool I'd use the intent for the bool, CanPlayerJumpAgain or something (again...contrived example).
- The language dimension - choice of words, that are good enough for the purpose, and not confusing. For example, "Manager" is as ambiguous as it gets, it can mean many thing, except we've been using it long enough that there's a more specific shape of meaning[0] for that word in code/program architecture contexts - so you still would use it instead of, say "Coordinator", which would raise all kinds of questions that "Manager" no longer does.
- The epistemological dimension - whether the word you chose correctly names the concept you meant, and whether the concept you meant is actually the right one to describe the thing you're trying to describe. Ultimately, this is the hard thing at the root of philosophy. In practice, it manifests like e.g. choice between digging into some obscure branches of mathematics to correctly name the thing "endofunctor" or something, or calling it "Square" and saying "fuck it, we'll clarify the exceptions in the comments".
--
[0] - I mean "more specific" in the sense it's distinct from the other meanings and somewhat narrow - but still it's fuzzy as heck and you can't describe it fully in words; it's basically tacit knowledge.