Hello.
This rule says: Methods and field names should not be the same or differ only by capitalization
However, this rule ignores the particular case of Builder pattern.
In a Builder class, is very common to have methods with same field name, to provide a Fluent API, such as:
public static class MyClassBuilder {
private String name;
public MyClassBuilder name(String value) {
this.name = value;
return this;
}
public MyClass build() {
return new MyClass(name);
}
}
Of course, we could argue that we could use a different name for the method, such as withName() but I don't think we should need to change the code in those cases where the field in only used for the build procedure, should not cause any confusion at all.
What do you think? Could it exclude Builder classes? Maybe using the class name suffix "Builder" would be sufficient.