

Tbh, creating new code just to shorten variable names is pretty bad practice. Don’t do that.
Each line of code needs to be maintained, each line of code can contain bugs and reusing such a class in locations it wasn’t actually made for can cause more harm than good.
And if you are adding external information (e.g. via a class) why not just add that information as inline documentation (aka comments) instead? Most IDEs can handle that so that if you hover over the variable/function name it will display the documentation. And pretty much all IDEs allow you to navigate to declaration with just one click, and there you find the necessary information.
You example only gets worse if you keep nesting these things, so for example if I have:
int sleepIntervalSeconds = 0;
Then I immediately know:
- It’s an int (not a double)
- It’s an interval used for sleeping
- It’s in seconds
(Putting all that in a comment instead of the variable name is almost equally as visible via IDE)
Instead consider your proposal, which would read like this:
Intervals var.sleep = 0;
I used var as the variable name since you abstracted the informations “sleep”, “interval” and “seconds” into other definitions.
So now I still know it’s an interval used for sleeping, but both the real variable type and the information that it’s in seconds is gone. I have to navigate to the Intervals class/type to figure that out.
IRL this often gets even worse, because Intervals probably doesn’t even contain the fields directly, but instead inherits from a Time class, which then inherits from some other class, and then you might get to the actual definition of the field.
This is only amplified by using Mixins and other obfuscation goodness.
If you have two options, and one option creates extra code, extra classes and extra code paths without reducing the complexity of the code significantly, than that’s the worse option.
When do you need documentation? When you are down in the code or when you are sitting on the toilet browsing Confluence? If your goal is to make people read the documentation, then the documentation needs to be immediately there where you need it, not in some external thing like Confluence.
Same goes with if your goal is to make people update the documentation. That’s much more likely to happen if the documentation is in a comment in the code than when you first have to go hunting to find the correct page in that steaming pile of mess that is confluence.
You still only got so much screen real estate, and having huge names means that your lines get very long at times, which makes everything really hard to read.