4 ms·
Great list to start with, but IMHO you need to embed as much information into a variable name as reasonably possible. If that doesn't seem possible, then maybe
by gitgud 7y ago
Great list to start with, but IMHO you need to embed as much information into a variable name as reasonably possible. If that doesn't seem possible, then maybe split the variable into a composite object with clearer properties.
Additionally, another good way to name variables is to compose them from understandable sub-name parts. For instance, I personally prefer boolean variables to have "is" or "has" prefixed.
isAdmin = true;
hasDiscount = false;
To me it's easier to understand, than the simplified:
admin = true;
discount = false;
Code is interpreted by computers, but understood by humans...