Drawing a hierarchy w.r.t. class (instance) variables

M

Minkoo Seo

Hi group.

Recently, I've read

http://www.visibleworkings.com/little-ruby/Chapter3.pdf
http://www.ruby-doc.org/docs/Understanding Ruby's Object Model/ChrisPine_UROM.ppt
and PickAxe.

I'm trying to draw a picture of hierarchy for the following:

class Foo
@@k = 20
end

class Bar < Foo
@j = 10

def initialize
@i = 0
end
end

b = Bar.new


I understand how to draw hierarchy if it were not for class variables:

Class
^
|
+-------+
| |
(Foo) <-(Bar)
^ ^ - Bar's class methods
| |
Foo <- Bar
^ - j and Bar's instance methods
|
b
- i

In this picture parenthesis represents meta class. Upward arrows
represents 'class', while leftward arrows represents 'inherits'.

But, I have no idead where the class variable k should belong to. k is
shared by Foo and Bar which menas that if k is modified at Foo, then
the value of k at Bar will be modified also. That being the case, does
k must be drawn under (Foo)? or Class?

Thanks.

- Minkoo Seo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top