[Tutor] Problems with references

Martin Hjort Eriksen martin at hardcoder.dk
Wed Jun 2 19:05:42 EDT 2004

Alan....either we both totally agree but we cannot understand each 
other, or we have been going to two very different schools of thought. :)

I think instead of commenting on your comments on my comments...etc. I 
will just come with a short summary of the basics, from what I have been 
tought in the ways of OOP. Hopefully it can help to clear any 
misunderstandings between us. ;)

As a starter, you have classes and objects. The class definitions are a 
blueprints on how the objects should be built, and these deifinitions 
are usualy not interesting when they are not instantiated. The basic 
purpose of class definitions is to provide blueprints for the objects. 
But of course all rules have an exception, meaning that sometimes it can 
be necessary to have a class definition that never will be instantiated, 
where the different part will be called staticly. But to work in the 
best OOP maner, this should be kept to a minimum. Well it even lies in 
the name...Object Oriented Programming.

To understand the difference between the class and object, we can use 
one of the classic examples...a sail boat, or to be more precise, the 
sail of a sail boat. Roughly the different states of a sail can be the 
size, whether or not it is op or down, what color it is and so forth. 
These different states of the sail will be described through the 
attributes of the object, and theses attributes are defined in the 
class. Multiple instances of the class, means different sails. This idea 
of modeling is the basic idea of OOP, and this modeling has as a basic 
idea, that the attributes should not be shared.

This leads back to what it was that i origanally objected in one of your 
e-mails, that the idea of attributes is that they should be shared.

"If the dictionary is defined as a class attribute it will be
shared across instances. That is what class attributes are for."

Hope my writing clears any misunderstandings in my position. :)


Martin Eriksen

More information about the Tutor mailing list