On 1/26/06, Alex Combas <alex.combas / gmail.com> wrote:
> I know I'm wrong, I probably should have wrote that at the top in
> big green letters. I just want to throw this out and see just how many
> ways I can be proven wrong so that I can learn and maybe
> one of the ways will stick like a wet noodle on the wall of my brain
> for long enough that I dont have to ask this question again next week.
>
> What I would really like is a better metaphore for class!

A better metaphor for a class is - a class!

More seriously, I believe  it's a good idea  to start thinking about
classes as just classes as soon as possible.  Or to  go even further 
and think of classes as "Ruby classes", "Perl classes", etc. 
Metaphors are good for the initial communication, to create the new
structures in your mind by copying aspects of old ones.  As you've
discovered, they're treacherous when it comes to thinking about those
things, though.  They limit your thinking to just one dimension of the
subject.

Apart from that, the object factory pattern (as described in the
thread and in the Gang of Four book) is one way to think of classes in
Ruby.  Another way to think of classes is to remember ways to
implement them, underneath.  A constructor just allocate some memory
for an object, add in a pointer to the set of methods in the class and
the class name, and  call the initialize method on the "empty" object.
 Every time a method call is done on that object, the Ruby interpreter
search through the list of classes that that object is involved with,
in a prioritized order, and find the implementation to call.  That
implementation will be method_missing if nothing else is found.

None of these are "complete" per se.  It's still best to just remember
that Ruby classes *are* Ruby classes, and should be thought of as Ruby
classes.  That way, you'll never go wrong - you just may learn more
abour Ruby classes...

Eivind.