2

Getter method name for

private boolean mIsLast;

is

public boolean isIsLast() {
return mIsLast;

}

or

public boolean isLast() {
return mIsLast;

}

?

Should use isIsLast() or isLast()?

BomberBus
  • 1,195
  • 3
  • 15
  • 29
  • The best practice is not naming boolean variable like `isSomething`. Just `something`. If you will follow this practice then eclise will generate correct names for getters and setters. – Ruslan Stelmachenko Oct 26 '14 at 11:55

2 Answers2

2

For future readers, a better answer to this would be to not use the "is" prefix in the variable name itself. Boolean variables should be named in such a way that prepending "is" would create a natural sounding question. So in OP's example, the field would be called mLast and the getter isLast().

Almost any other answer will say the same thing:

Community
  • 1
  • 1
mpellegr
  • 3,072
  • 3
  • 22
  • 36
1

isLast would be a preferable than isIsLast if you are dealing with boolean values. It is not a good naming convention to repeat the first syllables of the method.

Rod_Algonquin
  • 26,074
  • 6
  • 52
  • 63
  • Thank you. I also think isLast is more preferably. But, Android Eclipse IDE auto generate functions generated isIsLast. Can edit the IDE settings to generate isLast. – BomberBus Jun 20 '14 at 04:10
  • @BusCar Nope, you cant edit it from your IDE the only way is to change it when it is already auto generated your method, +1 and upvote this post if it helps thank you. – Rod_Algonquin Jun 20 '14 at 22:59
  • Sorry, @Rod_Algonquin. I would like to upvote. But, Vote Up requires 15 reputation. My reputation is only 11. I cann't vote up. – BomberBus Jun 21 '14 at 05:43
  • @BusCar you can still upvote just click the check mark – Rod_Algonquin Jun 21 '14 at 05:45