Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Android source code and many Android open-source apps and libs use m prefix for member fields and s prefix for static member fields:

private static boolean sStarted;
private long mTimestamp;

I personally dislike this, because it looks ugly and it's redundant – my IDE already uses different color and formatting for local, member and static member variables.

What's closest to truth?

  1. It's a good practice.
  2. It's a bad practice but you should use it anyway in order to be consistent with the majority of Android code out there.
  3. It's a bad practice and you shouldn't use it.
share|improve this question
Good question. I had to do a fair bit of Android development lately and I too wondered why Java development was going quasi-Hungarian. –  JohnMark13 Sep 6 '13 at 20:41

1 Answer 1

up vote 4 down vote accepted

The naming convention you described is very much like (if not the same as) system hungarian notation. There has been a lot of discussion about it here (Struggling not to use Hungarian notation), and obviously it is redundant.

Thus the answer to your first question, No, it isn't a good practice.

The second question is a little harder. In case you work on an existing code-base with that convention, its better to keep using it.

I personally wouldn't use this convention when creating something from scratch, even if I use libraries with that very convention. That practice is really redundant and you gain nothing from it taking into account the capabilites of IDE-s. I would instead keep consistent and accurate names in my own application, which would make it clear enough.

share|improve this answer
But, any idea why they did it? I went to the Android developers site, opened the first article and bam, it uses it. Like you say I just don't do it, but I find it odd. android-developers.blogspot.co.uk/2012/05/… . I see you opted for the Reverse Hungarian! –  JohnMark13 Sep 6 '13 at 21:36
Note this is not full blown Hungarian Notation, it only distinguishes fields by its kind. I imagine it may be useful in constructors and setters (mFoo = foo; rather than this.foo = foo;). It also makes you less reliant on semantic coloring which not every color theme/IDE offers. –  Xion Sep 7 '13 at 8:13
The font changes provided by IDE's are more subtle than this convention and so easier to miss. Additionally not all programming is done in IDE's. Therefore I think it's an overstatement to say that the convention is redundant flat-out. I suspect these are the reasons that the Android team has used this naming convention. –  MikeFHay Sep 7 '13 at 14:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.