Member Names and Case Sensitivity

Question
Is it okay to give type members names that differ only in their casing?

Answer
You never want to define public members using names that differ only in their casing. You should also avoid giving private members names that differ only in their casing.

Comments
Why? It’s harder to read code when names differ only in their case.

Examples

class User
{
    // Not good. Two properties that only differ in case.
    public string UserName { get; set; }
    public string userName { get; set; }
}

class Card
{
    // Also not good. Two methods that only differ in case.
    public int Count()
    {
        ...
    }

    public int count()
    {
        ...
    }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s