Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why Google calls variables with the prefix "m"?

Tags:

android

why Google calls variables with the prefix "m" for example:

    private int mSectionResourceId;
    private int mTextResourceId;

I see it in all examples. But i not understand why they do it?

And now i have some example where it practic very good. If a called variabels without prefix i need write

public SimpleSectionedRecyclerViewAdapter(Context context, int sectionResourceId, int textResourceId,
                                              RecyclerView.Adapter baseAdapter) {
        this.sectionResourceId = sectionResourceId;
        this.textResourceId = textResourceId;

but if i use prefix i can write

public SimpleSectionedRecyclerViewAdapter(Context context, int sectionResourceId, int textResourceId,
                                              RecyclerView.Adapter baseAdapter) {

        mSectionResourceId = sectionResourceId;
        mTextResourceId = textResourceId;

I think it more readable. Who can explain to me the pros and cons of a prefix?

like image 812
ip696 Avatar asked Feb 10 '23 15:02

ip696


1 Answers

The variables starting with m are telling you they are variables in the scope of your class. Member of the class.

Link to Android Code Style Guide

like image 113
Marko Avatar answered Feb 20 '23 10:02

Marko