I saw lot of code (for example some Android source code) where fields name start with a m while static fields start with s

Example (taken from Android View class source):

private SparseArray<Object> mKeyedTags;
private static int sNextAccessibilityViewId;

I was wondering what m and s stand for... maybe is m mutable and s static?

  • Prefixes are outdated, current Editors/IDEs has awesome options for Colorizing. You dont need to use them(prefixes) Commented Mar 15, 2016 at 23:56

2 Answers 2


m is typically for a public member (see this answer for common C code conventions Why use prefixes on member variables in C++ classes).

I've never seen s before, but based on that answer:

  • m for members
  • c for constants/readonlys
  • p for pointer (and pp for pointer to pointer)
  • v for volatile
  • s for static
  • i for indexes and iterators
  • e for events

Have you read any published standards for the project you've seen that code in?

One of the most famous prefix notation systems is Hungarian Notation.

There is a excellent blog post by Joel Spolsky on prefixes: Making Wrong Code Look Wrong

  • 2
    s prefix for static is really common (I use it!). First hit on web search took me to developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style
    – ckhan
    Commented Nov 26, 2012 at 10:29
  • 10
    You are mixing two kinds of things in that list. The scopes – m, c and s – and the Hungarian-style kind prefixes p, v, i and e. They are different things and if both are used, each identifier may have both.
    – Jan Hudec
    Commented Nov 26, 2012 at 10:32
  • 3
    Prefixing identifiers dilutes the value of diffs when something changes. For example, if something in a class starts life a constant and you've decided to make it a configurable-from-the-outside member, you have to change every reference to it to a new name. Someone reviewing the change will not only see the change in declaration and any new accessors, but also a substance-free change in every line that uses it. Adding a prefix is like declaring the variable repeatedly. Keep it to a single place and use your development tools to find out what it is.
    – Blrfl
    Commented Nov 26, 2012 at 12:18
  • 4
    @Blrfl, constants are normally ALL_CAPS anyway, so you'd get the many line changes. That's no too much of a hardship to review. Also, if something changes from a private const to a member, there's enough of a change to how that's used to warrant a rename anyway.
    – StuperUser
    Commented Nov 26, 2012 at 13:25
  • 4
    nounI verbDisagree punctuationPeriod
    – Blrfl
    Commented Nov 26, 2012 at 15:27

It's called hungarian notation, and it sucks. Do some research on it, it's actually a misunderstood concept.

It originated with a good intent, indicate variables that may cause harm, such as input directly from the user in a HTML form (be sure to strip out HTML before storing to DB for instance).

var unsafeComment = $('.input').val();
save(unsafeComment);//looks wrong
//strip out html then save 

The m is for member and s for static.

  • 7
    No, this isn't Hungarian notation. Or rather it's one kind of it and not the one usually meant by that term.
    – Jan Hudec
    Commented Nov 26, 2012 at 10:33
  • 6
    Have a read of joelonsoftware.com/articles/Wrong.html, Hungarian notation is easily open to abuse, but used judiciously it can be very useful.
    – StuperUser
    Commented Nov 26, 2012 at 10:33
  • 6
    @StuperUser: Indeed; there are good uses of Hungarian notation and evil uses of it. The one pushed by Microsoft rates as very evil, because it "effectively prevents abstraction from creeping into the code", but this one rates as somewhat useful and in dynamic languages it's often the sanest way to avoid getting lost in what is what.
    – Jan Hudec
    Commented Nov 26, 2012 at 10:41
  • 1
    @JanHudec - this is (sort of) the original use of Hungarian. It was for pixel coordinates relative to the window vs relative to the screen - so you can spot which way round an offset should be applied. Commented Nov 26, 2012 at 16:35
  • 2
    @MartinBeckett: These m and s prefixes indicate (lexical) scope, which is vastly different from indicating semantics as in the original paper (in C++ type is much better for that; see e.g. Boost.Units)
    – Jan Hudec
    Commented Nov 27, 2012 at 6:49

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