Scott M. said:
This will be my last post in this thread
Fair enough - but I'd be interested in continuing this by email if
you're willing. I'm passionate about trying to get people who teach
other people not to teach them falsehoods that other people then have
to correct later on. I'd like a bit more time to try to convince you
but as a professional
trainer, who has trained literally over 10,000 people. I can
certainly say without hesitation something that those who have not
taught to any great extent wouldn't know; you must teach concepts
before you can teach detail oriented application of that concept.
You might be interested to hear that various people have emailed me or
posted on the newsgroups stating that they've found my page has helped
them understand things which had previously confused them.
As for "those who have not taught to any great extent wouldn't know" -
I believe my pages *do* teach people, as do my newsgroup posts. I may
not be a professional trainer, but that doesn't mean I haven't taught
or don't know how to teach. (If you want to trade numbers, use
groups.google.com. My C# pages receive between four and five thousand
hits a week. They wouldn't do that if they didn't teach people stuff,
surely?)
Furthermore, I think that understanding the difference between a value
type and a reference type is hindered rather than helped by the kind of
statement you made. Instead, talk about the difference between a
reference and an object; that the value of any reference type
expression is a reference and not an object. Once you've got that, you
can easily move onto the fact that where a variable's value goes
depends only on its context (local variables always being on the stack,
etc) and that objects themselves go on the heap.
As for teaching the concept before the detail oriented application -
which would you count your statement as? My article is fairly brief
about the difference between value types and reference types, but it
does cover it. (I keep meaning to write a full article talking about
just that topic, and then referencing it from both the memory and
parameter passing articles, but I haven't got round to it yet.)
Clearly, you and I have been having a conversation about 2 different
things, but I think from reading your posts, that you still haven't
gotten that.
I've "got" that you seem to think that teaching people something which
isn't true is a good idea in this case, whereas I've shown clear
evidence that people *do* get confused by it. You still haven't
commented on that, as far as I've seen.
I've never disputed your point on if a value type can live on the heap, but
you fail to even come close to understanding what it is that I'm trying to
say.
You've claimed that what you said was correct, despite now
acknowledging that value types can live on the heap. Do you deny that
what your statement implies is *not* correct?
I still find it amazing that you said that the information on my page
was the "exception to the rule and not a rule in and of itself". What
proportion of types do you create which don't contain value type
variables? My page explains *the* rule, to which there are no
exceptions (unless you count the possibility of a future JIT moving
things around, putting objects on the stack if it knows they're not
used after the method finishes etc) as far as I'm concerned. If you
think there are exceptions, please state them - otherwise in what way
is it not a rule in and of itself?
In my 20 plus years of experience, there are certain approaches to mastering
a concept. If you'll remember the OP was a newbie. It is not always the
best idea to lay the most intricate details of something on someone who
needs to understand the concept first.
I agree, but only if you can give basics *without* actually saying or
implying things which aren't true, as you do here. Also I only agree if
explaining things properly is either difficult or makes other things
more complicated.
In this case it's not particuarly difficult to understand, and it helps
greatly in other areas. How can anyone understand parameter passing or
even basic variable assignment if they don't understand what a variable
actually holds?
If you go back and read this thread, you'll see that the OP even
acknowledged to another poster: "That was the clearest answer.
Thanks. I got a bit confused by reference types and value types
discussion later in the thread."
Indeed - it's not clear whether or not he'd have been confused if there
hadn't been two different messages presented, of course. You can't use
that quote to claim that your statement is less confusing than mine, as
it doesn't distinguish between the two.
Despite what you've said, I will continue to approach the concept of
value/reference types to newbie's in the exact same successful manner
that I have been doing for several years now as I've found that this
has been the best way to get someone thinking about it clearly.
Oh great. I wonder if I'll see some of those students ask questions in
the newsgroup based on the false implications of your statement, as
others who've been taught with statements such as yours have had to ask
in the past.
When those students are ready to move to a level of greater
understanding of memory management and OO concepts, they are ready
for what you have been addressing.
But it's really not that hard to start with! Teaching the truth about
variables and memory to start with isn't complicated, and makes so many
things easier. It always amazes me that some people try to write
Windows Forms applications, talk to databases, etc without really
understanding the difference between reference types and value types,
or what a variable really is.