Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does "m" stand for in relation to singleton pattern?

(I have tried searching for "singleton pattern what does m stand for" with no result, but there is a lot of code online with variable names called mInstance.)
Code looks something like this:

internal sealed class ClassName
{
    private static ClassName mInstance;
    public static ClassName Instance
    {
        get
        {
            if (mInstance == null)
            {
                mInstance = new ClassName();
            }
            return mInstance;
        }
    }
}

This is clearly a singleton class, but I have no idea why "mInstance" is called "mInstance".
Do you know what "m" stands for?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The m is not related to the singleton pattern, but most likely denotes an internal member field (private, protected) of the class. Other conventions are to start such members with m_ or just an underscore _.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading