by chrisoverzero · 11mo ago · 0 comments
I’ve used languages with an approach like this. The difference in what I’ve used is that you separate the conventional part from the rest of the name with a space (or maybe a colon), then only refer to the value by the non-conventional part for the rest of the scope. Then the language enforces this convention for all of my co-workers! It’s pretty neat.
var intValue = 3;
…I separate the conventional prefix with a space: int value = 3;
…so now my co-workers don’t need to remember the convention – it’s enforced by the language.(I hope this makes the joke more obvious.)
User activeUser
…you’ll always know that `activeUser` contains a User value – something that might have an `Id` property. And the convention is enforced by the language, so it’s easy to communicate. These semantic distinctions are very useful, I agree.