Hi Max,

Thanks for your explanation.

Max Berger wrote:
> Hi *,
> 
> this rule is usefull in the case where you use common names for
> attributes (such as x, or y), and accidentially "overwrite" them as
> parameters. This again comes back to the point of readability.
> 
> The same variable name should ALWAYS refer to the same variable / value.
> 
> For setters and constructors this makes sense -> after all, in each of
> these you have a simple assignment, and both variables will carry the
> same value.
> 
> But in most other methods, the parameter you pass is NOT assigned to the
> internal variable, so they actually refer to a different thing, and
> thats where the confusion starts.

You definitely have a point here. But I’ve found that in a majority of
cases, warnings raised by this Checkstyle rule are “false positive”
i.e., correspond to setters that don’t match the simple setField pattern
(Alexander’s examples are good ones). Insofar as this rule creates more
noise than useful warnings, I’d remove it.


> I know modern IDEs can show you which variable you actually refer to,
> but this usually requires selecting the variable or hovering over it,
> which you will not do if you are just reading the code trying to
> understand it.
> 
> However, since we cannot agree to keep the rule, I'll have to be content
> with removing it (which is already done).

Yeah, at least waiting for Max’ explanation before applying the majority
rule would have been good.

<snip/>

Vincent

Reply via email to