Java Reference
In-Depth Information
class MyVector {
private void doLogic() {
for (int i = 0; i < 10; i++) {/* ... */}
for (int i = 0; i < 20; i++) {/* ... */}
}
}
Applicability
Name reuse makes code more difficult to read and maintain, which can result in security
weaknesses. An automated tool can easily detect the reuse of identifiers in containing
scopes.
Bibliography
[Bloch 2005]
Puzzle 67, “All Strung Out”
[Bloch 2008]
Item 16, “Prefer Interfaces to Abstract Classes”
[Conventions 2009]
§6.3, “Placement”
[FindBugs 2008]
DLS, “Dead store to local variable that shadows field”
[JLS 2013]
§6.4.1, “Shadowing”
§6.4.2, “Obscuring”
§7.5.2, “Type-Import-on-Demand Declarations”
38. Do not declare more than one variable per declaration
Declaring multiple variables in a single declaration could cause confusion about the types
of variables and their initial values. In particular, do not declare any of the following in a
single declaration:
Variables of different types
A mixture of initialized and uninitialized variables
Search WWH ::




Custom Search