What naming conventions do you use for your game's variables?

Please don’t use this terminology.

4 Likes

Ah, I probably didn’t give enough context for that sentence: that was talking about being consistent in your naming, and the problems you might run into in coming up with rules that let everybody be consistent in the same way without having to guess, or getting it wrong regularly. Do you call it revoke or revert or repeal or rescind or abrogate or overturn? Pick one and stick to it.

Maybe that’s a bad example. Is it more important that it’s an open-end wrench, or a stainless-steel wrench, or a Stanley-brand wrench? Have a convention (for a given project, at least) about which you’re going to use for the name, so that someone can look at the thing and be able to predict the variable name without guessing. That kind of thing.

I can’t say I’ve really had the opposite problem where it’s hard to find any qualities to name a value after. Though I guess maybe some temporary in-between values have that problem. I feel like that’s usually a code smell though: a symptom that you’re trying to name the wrong thing and maybe you should break up the problem differently?

2 Likes

Thanks, that makes more sense. My opinion is that rigid consistency is less important than naming which conveys the information you need for the particular bit of code at hand. Being wildly inconsistent is to be avoided, but trying to create a scheme which prevents even slight variations is probably not worth it.

This is a good example of the kind where I mentioned refactoring being important. The absolute identity of the object and all its properties are less important to naming than a description of the thing that is of value for the piece of code at hand. If you have giant blocks of code where a single variable is being used in lots of different ways and depending on many properties of the thing held by the variable, then your code needs to be restructured into more specific pieces, i.e. functions, classes, modules, whatever. This prevents the “stainless-steel left-handed wrench with a rubber handle belonging to Bob” variable naming problem. This also resolves much of the need to have a globally acceptable naming scheme.

I agree completely.

3 Likes