24 lines
468 B
Plaintext
24 lines
468 B
Plaintext
Having a class and some of its methods sharing the same name is misleading, and leaves others to wonder whether it was done that way on purpose, or was the methods supposed to be a constructor.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
public class Foo {
|
|
public Foo() {...}
|
|
public void Foo(String label) {...} // Noncompliant
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
public class Foo {
|
|
public Foo() {...}
|
|
public void foo(String label) {...} // Compliant
|
|
}
|
|
----
|
|
|
|
|