question about globals vars...

Will Stuyvesant hwlgw at hotmail.com
Sat Aug 3 04:15:49 EDT 2002


"Sean 'Shaleh' Perry"
> sounds like broken inheritance and broken design to me.
> 
> Sn should contain an instance of S and calls its methods while maintaining its
> own numberOfItems attribute.  You can't fix a broken design with inheritance.
>

Agreed!  I always try to use instances instead of inheritance as a
general rule.
 
> This is not an OO problem.  Any time you implement data encapsulation this type
> of issue comes up.  Deciding how much of an interface to provide is always
> tricky.

If you implement a data structure in a C library you do not have to
deal with inherited usage.
I think the encapsulation problem in the example is caused by the
inheritance.  It makes you wonder about OO inheritance.  When is it
useful?  If it is dangerous even in a simple case like the example
then what are the rules to find out if inheritance is usable in a
specific case?  Or is there something fundmentally wrong with OO, do
we need another paradigm?  I know from experience that some of the
problems can be avoided by development teams using extra rules.  Like
'no usage of inherited methods over 1 generation away' etc.
I admire the effort turning Python all OO, unifying classes and
built-in types.  But maybe after a while we find out OO is not that
great and then what <:-)

'''
Reality is an obstacle to hallucination.
'''



More information about the Python-list mailing list