Phill said:
I agree classes instances don't need hungarian notation and its not
practical to keep comming up with them for each class.
But for primitives I think it makes sense.
I think between:
Savings = (OrigPrice * Discount);
And
fSavings = (fOrigPrice * fDiscount);
The 2nd is better because I know fDiscount is a float and its not like
the integer value 25 for 25%.
I disagree:
1) Just as someone gave an example where the type of a variable which
was a Hashtable could change to SortedList, so the discount might need
to be changed to a double, or a decimal. Are you definitely, definitely
going to change all your code? If you don't, it's worse than not having
the type there at all.
2) It makes it harder to read, IMO. You either have to teach your brain
to skip over the letters, or you have to mentally read them every time,
which breaks up the flow (for me, anyway).
Maybe that's not the greatest example
but I think things are ambiguous otherwise. If you have a decent sized
method that you haven't seen in a while, are you saying you'd rather
determine the variable's type using the debugger than by just looking
at it?
Yes, if that means greater readability when I'm looking at the code
when I *am* familiar with what things are. You don't really need to use
the debugger - just hover over a variable to see its type.
And what about telling the difference between constants classes and
methods. The .Net Naming schema treats them all the same. Each
Beginning word is capitalized. Why not CAPS ALL CONSTANTS, or just
capitalize the 1st word in classes.
Readability. ALL_CAPS is harder to read than CapitalizingWords (it
feels like it's shouting) and ReadingCapitalizedWords is easier than
reading Lotsofwordswithnothingtosaywheretheystart.
It's very easy to tell the difference by context though - unless you're
using a delegate, a method name will always have brackets at the end of
it anyway. When you're using a delegate, it should be obvious that
you're doing so.
Note I'm not really arguing with you guys, I'm kinda hoping someone
can show me this newer scheme is better, because I can't seem to see
it as an improvement myself.
Maybe you will when you've used it for a while and then look back at
some old code. Anything new takes a little while to get used to.