0

On applying check style i am getting " hides a field" if the name of formal and actual parameters are same.

private String limitedDimensionId;

 /**
 * Sets the limited dimension id.
 * 
 * @param limitedDimensionId
 *            the new limited dimension id
 */
public void setLimitedDimensionId(final String limitedDimensionId) {
    this.limitedDimensionId = limitedDimensionId;
}

However i am not getting the same issue in the following case:

private boolean fallBack;

 /**
 * @param isFallBack
 *            the isFallBack to set
 */
public void setFallBack(final boolean isFallBack) {
    this.fallBack = isFallBack;
}

Both the conditions appear same to me. Still the discrepancy. Usually i change the name of the parameter variable to resolve this check style issue. But looking at the other case i am getting a hint that a more elegant solution is available. Any insights?

Farrukh Chishti
  • 7,652
  • 10
  • 36
  • 60

2 Answers2

1

The variable names are different:

fallBack vs isFallBack

Usually i change the name of the parameter variable to resolve this check style issue

That's correct solution.

Azodious
  • 13,752
  • 1
  • 36
  • 71
  • u r so ryt....looks like i need and eye examination before actually programming or looking at anything for that sake....still ain't there any other way of doing so....for a large file (say with 40 variables)...do i have to change the name of each and every one of them individually .. ?? – Farrukh Chishti Mar 06 '13 at 07:09
  • Yes, i guess. Or may be you can write a plugin for same. :-) – Azodious Mar 06 '13 at 07:12
  • you can write a plugin to prefix the variables with certain word. and similar things ... – Azodious Mar 06 '13 at 07:14
0

I would agree that giving them different names is more appropriate, however the "this" keyword in the "this.limitedDimensionid" should avoid the "hides a field" error. That's what it's for...

James Hamilton
  • 457
  • 3
  • 16