Languages/All/IdentifierNames
From UIT
(Difference between revisions)
(→Identifiers) |
|||
Line 2: | Line 2: | ||
{{TOC right}} | {{TOC right}} | ||
== Identifiers == | == Identifiers == | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
Here are some tips for choosing good identifiers. | Here are some tips for choosing good identifiers. | ||
− | + | {{WarningBox|content='''... the length of a variable's name SHOULD be proportional to the size of its scope, and the complexity of its use.''' | |
− | + | * [https://goo.gl/cI631a Andrew Hilton, Anne Bracy; 2015; ''All of Programming - Edition 0''; §13.2.2 Naming]}} | |
− | + | ||
− | + | ||
− | Example | + | === Example === |
<source lang="java"> | <source lang="java"> | ||
// Bad idea : | // Bad idea : |
Latest revision as of 13:01, 2 December 2015
|
Identifiers
Here are some tips for choosing good identifiers.
... the length of a variable's name SHOULD be proportional to the size of its scope, and the complexity of its use.
Example
// Bad idea : for (int RidiculouslyLongIdentifierName = 0 ; RidiculouslyLongIdentifierName < 0 ; RidiculouslyLongIdentifierName++) { System.out.println(RidiculouslyLongIdentifierName); } // Better : for (int i = 0 ; i < 0 ; i++) { System.out.println(i); }