Re: Difference between nullable class and nullable<> structure
- From: "Scott M." <s-mar@xxxxxxxxxxxxx>
- Date: Wed, 14 Oct 2009 15:17:13 -0400
The following comes from "Pro VB 2005 and the .NET 2.0 Platform", APress, by
Andrew Troelsen
Page 313 (Understanding Value Types and Reference Types):
"Specifically speaking, a .NET data type may be value-based or
reference-based. Value-based types, which include all numerical data types
(Integer, Double, etc.), as well as enumerations and structures, are
allocated on the stack."
Point #1:
Realizing that this is a C# NG, but also realizing the Greg used the VB .NET
term "structure", let me quote from page 123 (Programming Constructs):
"...structures do not have an identically named class representation in the
..NET library (that is there is no System.Structure class), but are
implicitly derived from System.ValueType."
and from page 314:
"...understand that .NET structures and enumerations are also value types.
Structures, as you may recall from Chapter 4, provide a way to achieve
bare-bones benefits of object orientation (i.e. , encapsulation) while
having the efficiency of stack-allocated data."
Your statement to Greg that the term "structure" to refer to a value type
was incorrect, is itself incorrect.
Point #2:
You stated:
"Any discussion of reference types and value types that begins by mentioning
the heap and the stack is, at a minimum, bound to fall short of precision,
and at worst will be extremely misleading."
The author (who you may have heard of and is considered to be quite an
expert in .NET) explains value-types to the reader in just the same way I
did. In fact, this approach is also taken in "Professional Visual Basic
2008", WROX. And, in fact, it is taken in just about every text I can find
on the subject.
The bottom line for me Peter is that you may know quite a bit about
programming, but you know very little about teaching and despite your edicts
on what teaching technique is "at best" and "at worst" as have been "proven"
as unreliable, every single one of those assertions is absolutely wrong when
it comes to IT Education.
Those who can't teach cite Wikipedia, those who can, do.
My 20 years of experience in IT Education clearly contradicts your several
minutes of Wikipedia searching and conclusions based on no actual experience
in teaching.
Despite what you may personally belive, I (and just a few notable others)
feel that it is appropriate to discuss reference and value types in the
context of the stack and the heap and that it is not necessary to explore
all the gory details during the initial exposure to the concepts.
There's just no argument you can put up to defend youre point, other than
your opinion.
-Scott
"Peter Duniho" <no.peted.spam@xxxxxxxxxxxxxxxxxx> wrote in message
news:uDO7hG2SKHA.4980@xxxxxxxxxxxxxxxxxxxxxxx
Gregory A. Beamer wrote:
[...]
As for the stack and heap discussion, er fight, here: When we are first
taught the atomic structure, the solar system is often used as an
analogy, without disclaimers. It helps the young student understand
electrons and orbits.
In what way? If the student already understand planetary orbital
mechanics, what knowledge there helps them understand atomic structure?
Are electrons kept in their orbits by gravity? Do they follow regular
elliptical paths? Are some electrons larger or smaller than others? Do
some electronics take more or less time to complete an orbit than others?
Do the protons and neutrons in the nucleus of an atom orbit each other,
again kept in proximity by gravity, but from collision by velocity?
I won't dispute that some teachers introduce the solar system as an
analogy for atomic structure. However, I will certainly debate the claim
that doing so is actually helpful to the students. There's practically
nothing about the analogy that helps a student better-comprehend atomic
structure.
Technically, however, it is a flawed analogy,
which is learned later on. In the same boat, using stack and heap as a
general way of describing value and reference types, especially to
junior devs, does not bother me as much as it might some. It helps wrap
the mind around the concept, even if it is not true in all conditions,
It's not true in _any_ conditions. The things that make value types
different from reference types and interesting as a particular kind of
data structure don't have anything to do with the stack. It's simply a
convenience of purpose that value types _sometimes_ wind up on the stack.
Knowing that value types occasionally wind up actually stored on the stack
doesn't provide any insight whatsoever into the things that make value
types useful or unique.
just as undestanding you are working with the value (value type) versus
a reference to the "value" works on a basic level. I am sure someone
here might disagree, which is their prerogative. ;-)
It is a well-established educational principle that misdirecting the
student in this fashion is counter-productive. Using a false analogy
provides them no useful information in understanding the concept, as
compared to simply providing a simplified-but-correct explanation, and it
leads to the student failing to properly comprehend the more detailed
concepts.
See http://en.wikipedia.org/wiki/Principles_of_learning#Primacy for more
details.
It's well and good to, when introducing the idea of a "value type" to a
student, to limit the information about that idea to the things the
student is capable of comprehending at that moment. I'd argue that value
types aren't really all that complicated and that there's no real need to
limit that information, but every student is different and if there's a
need, fine. But to teach the student WRONG information as a substitute
for teaching them correct information is misguided at best, disrespectful
and irresponsibly deficient at worst.
Pete
.
- Follow-Ups:
- Re: Difference between nullable class and nullable<> structure
- From: gareth erskine-jones
- Re: Difference between nullable class and nullable<> structure
- From: Peter Duniho
- Re: Difference between nullable class and nullable<> structure
- References:
- Difference between nullable class and nullable<> structure
- From: Raj
- Re: Difference between nullable class and nullable<> structure
- From: Scott M.
- Re: Difference between nullable class and nullable<> structure
- From: Peter Duniho
- Re: Difference between nullable class and nullable<> structure
- From: Scott M.
- Re: Difference between nullable class and nullable<> structure
- From: Peter Duniho
- Re: Difference between nullable class and nullable<> structure
- From: Mark Rae [MVP]
- Re: Difference between nullable class and nullable<> structure
- From: Gregory A. Beamer
- Re: Difference between nullable class and nullable<> structure
- From: Peter Duniho
- Difference between nullable class and nullable<> structure
- Prev by Date: Office Locks Change Install New Locks Locksmith Los Angeles 1-323-678-2704
- Next by Date: Re: RegExp DoubleQuote
- Previous by thread: Re: Difference between nullable class and nullable<> structure
- Next by thread: Re: Difference between nullable class and nullable<> structure
- Index(es):
Relevant Pages
|