B
Bob Grommes
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.
If you have a system, and are committed to it, yes. Generally you are not
talking about a lot of instances of the variable to deal with, and this kind
of refactoring is easily automatable if you are a slow typist or whatever.
That said, I made the original point about Hashtable ==> SortedList and that
in my mind is a somewhat different beast. Both of those classes implement
the same interfaces and are descendants of the same ancestor; making a
distinction between the two is probably less useful than the distinction
between an int and a string or even an int and a float. I mainly advocate
using prefixes on value types.
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).
One gets used to it -- but you're right, we're all wired differently and
this may be a perpetual distraction for some.
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.
Ah, but to me, this is where the evaluation of the usefulness of prefixing
variable names usually runs afoul. It is much less useful when you are
writing the code, or have familiarity with it. But where it really shines
is months or years later when you're no longer familiar with it, or tomorrow
when you hire someone new to work on it. That is where the value is -- in
making code you're either unfamiliar or rusty with, more self-evident and
therefore, easier to read accurately in the long run.
--Bob