28 lines
511 B
Plaintext
28 lines
511 B
Plaintext
== Why is this an issue?
|
|
|
|
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
|
|
|
|
[source,text]
|
|
----
|
|
public class Foo {
|
|
public int sum; // Noncompliant, matching sum() method name
|
|
public int sum() {...}
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,text]
|
|
----
|
|
public class Foo {
|
|
public int sumTotal; // Compliant
|
|
public int sum() {...}
|
|
}
|
|
|
|
----
|
|
|