case sensitivity

  • Thread starter Thread starter Jeff S
  • Start date Start date
J

Jeff S

I'm getting started with C# and was just wondering if C# veterans LIKE the
fact that the language is case sensitive. If so, how is case sensitivity
helpful? Do you create multiple variables, functions, and objects with
identical names that differ only in case?

Really wondering....

Jeff
 
Jeff S said:
I'm getting started with C# and was just wondering if C# veterans LIKE the
fact that the language is case sensitive.

I do.
If so, how is case sensitivity
helpful? Do you create multiple variables, functions, and objects with
identical names that differ only in case?

I don't, I really don't!


You've to understand that the fact that the language is case sensitive help
to trap errors as they occur, and the ability to visually recognize a
variable just by its consistent casing (How do I seperate XmlDocument &
XmlNavigator, I read the upper case letters and in 99% it allows me to know
what class is being used.
Just think of the resulting code:

XmlWrTier xNoCAsEisFUN = nEw xMLWRitER("foo.xml");
XnOCAseISFuN.Write();

This is an exteme example, but anything that helps is good.
And no good-coding-style manual will help you if the compiler isn't
enforcing this.
 
Jeff S said:
I'm getting started with C# and was just wondering if C# veterans LIKE the
fact that the language is case sensitive.

I do.
If so, how is case sensitivity
helpful? Do you create multiple variables, functions, and objects with
identical names that differ only in case?

I often have a property and a variable which have the same name but
differ in case:

int count;
public int Count
{
get
{
return count;
}
}

etc.
 
In most cases, I find it useful to not have to qualify members, like
properties, when I have a parameter or local of the same name. It is also
just very inbred, case sensitivity should be there(as all C based langauges
are case senstive, including java), its just how it works.
I also tend to do things like
public string Name
{
get
{
return name;
}
}
string name;

for properties.
 
I don't particularily like that it is case-sensitive but I don't not like
it, either. The fact that it is case sensetive is simply just how it is
built. Sometimes it's daunting to remember to always type in the correct
case (when you type very fast by the time it registers in your brain that
there was a typo (I always know because it "felt" wrong when I typed it) I'm
already 15 characters ahead and have to backspace or arrow-key back to it
and it breaks the flow).

In VB I have mixed case but when I reference them I type in small case and
if it automatically corrects the case-sensitity I know I typed it in
correctly. I suppose C# will tell you also.

Where it is useful (albeit perhaps confusing) in C# is when I have a public
member mixed case and a local/private member small case. I never ever ever
use a small case type as a public referencable/usable
method/variable/object. But in some projects it can be confusing. In VB I
prepend an underscore if it is private or local. In C#, I don't have to, I
juse make 'em all small letters.

Yes... I do:

public class X {
private string name;

public string Name {
get() { return name; }
set() { name = value; }
}
}

I suppose that illustrates a simple example of the concept. At least, if
I'm consistant I'll never get lost in the code (even 13 months later -- I
know, I'm at that point). But we have other developers here and no standard
and it'll throw them off or you off but for the most part, everyone here is
adaptable and there have never been problems because of this, only because
of lack of code re-use but that's another thread topic.


Thanks,
Shawn
 
Shawn B. said:
I don't particularily like that it is case-sensitive but I don't not like
it, either. The fact that it is case sensetive is simply just how it is
built. Sometimes it's daunting to remember to always type in the correct
case (when you type very fast by the time it registers in your brain that
there was a typo (I always know because it "felt" wrong when I typed it) I'm
already 15 characters ahead and have to backspace or arrow-key back to it
and it breaks the flow).

Alt+Space is your friend, if you've 15 letter vars, then IntelliSense is
sure to get the right one.
 
Back
Top