24 lines
455 B
Plaintext
24 lines
455 B
Plaintext
![]() |
Having a duplication between a field name and a method name is confusing, misleading, and probably an indication that the field name should be updated to be more meaningful.
|
||
|
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
public class Foo {
|
||
|
public int sum; // Noncompliant, matching sum() method name
|
||
|
public int sum() {...}
|
||
|
}
|
||
|
----
|
||
|
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
public class Foo {
|
||
|
public int sumTotal; // Compliant
|
||
|
public int sum() {...}
|
||
|
}
|
||
|
|
||
|
----
|
||
|
|