Variable naming conventions, general + specific or specific + general

I am trying to figure out what is best in terms of naming conventions, as I seem to come across this dilemma all too often. Should I start by naming variables starting with the general part or the specific part.

Example:

baseUnitsRegen;
deltaUnitsRegen;
timeDelayUnitsRegen;

or

unitsRegenBase;
unitsRegenDelta;
unitsRegenTimeDelay;

Both have pros and cons in my mind, as the first example will make it easier to select from the IntelliSense suggestion. On the other hand, the second example it is easier to access a group of variables by typing unitsRegen, you will see everything that has to do with that.

Is there a convention for naming things similar to this?

The general naming convention that microsoft suggests is putting the specific term first, followed by the less specific. However there are exceptions mostly for abstract base classes. The term “Abstract” is usually used as a prefix, the term “Base” is usually used as a suffix.

See this SO question for another view on that topic. In the end it doesn’t really matter as it’s just a convention. The most important thing is to stay consistent within a codebase, no matter what kind of convention you use.

Your first example is the way to go.

If you need to group related variables, consider using a struct instead of devising an unorthodox naming convention. It will be easier to read, and I think you’ll find much nicer for yourself and any developers you may work with down the road.

Sample Code:

public struct UnitsRegen
{
    public float baseValue;
    public float deltaValue;
    public float timeDelay;

    public UnitsRegen(float _baseValue, float _deltaValue, float _timeDelay)
    {
        baseValue = _baseValue;
        deltaValue = _deltaValue;
        timeDelay = _timeDelay;
    }
}

// Instantiating the struct.
UnitsRegen unitsRegen = new UnitsRegen(3f, 0.2f, 0.5f);

// Access your instance.
float currentBaseRegen = unitsRegen.baseValue;