Jon said:
So people say, but that's what I use, and I've never had a problem with
it.
In a case sensitive language varying symbol names only be case, foo and Foo
is a really bad idea. It is programming 101. (Does MS really recommend
this?) The human eye sees what it wants when reading text, not what is
there. How often have you written "the the" when you mean "the", and proof
read your document 10 times and not seen it? The same goes for letter case
in code.
Perhaps you are very careful all the time, and always use the variable when
you mean the variable, and the property when you mean the property. And
perhaps every author of every library you depend on is equally careful. Of
course no body can be that careful all the time. 99.9% of the time your
code will work the same way if you do mix it up, so there really is no way
to know if you do mix it up now. Little time bombs are being set in C# code
being written all over the world right now.
For example, you write this class:
class Foo {
private Data myData;
public Data MyData {
get { return myData; }
set { myData = value; }
}
public Bar() {
// oops. Should be using the property
// here. But every thing works right
// now, so no tests catch it....
doSomething(myData);
}
}
A year later you modify the MyData property:
public Data MyData {
get {
// This line was added as something important
// needs to be done.
doSomethingImportantBeforeReturning()
return myData;
}
set { myData = value; }
}
public Bar() {
// Uh-oh. I never noticed this was a direct
// access, and not a property call, and now
// my code fails every 13.5 hours only when
// I'm on vacation!
doSomething(myData);
}
Oh for properties being able to declare member variables which only
they could access though... that would improve things a lot, IMO.
This sounds like a real solution. I predict, once enough of these little
time bombs go off, MS will do something like this. Or not. It is Microsoft
after all...