[Tutor] Deleting an instance of an object

paul.baines at ecb.int paul.baines at ecb.int
Fri Sep 24 09:46:37 CEST 2004


I think it's good to use the phrase "is a" when thinking about
subclassing. A mammal is an animal, so mammal is a subclass of animal,
but "article is an issue" doesn't really make sense, so it's probably
not a good candidate for a subclass.

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of Adam Cripps
Sent: Friday 24 September 2004 09:36
To: tutor at python.org
Subject: Re: [Tutor] Deleting an instance of an object


On Thu, 23 Sep 2004 10:56:50 -0700, Jeff Shannon <jeff at ccvcorp.com>
wrote:
> Adam Cripps wrote:
> 
> >(Article is a subclass of Issue, which is a subclass of Title, which
> >is a subclass of MagazineCollection). Each instance of Article has an
> >attribute name (article.name).
> >
> >
> 
> I haven't looked closely at your code, but this strikes me as not
being
> a very good design.
> 
<snip> 
> Hmmm... glancing at your code a bit more, it *does* look like you have
> internal collections of each subclass in the next-higher class, so it
> seems that you've got that idea down.  So why are you subclassing?
It
> looks like Article instances aren't using any of the
MagazineCollection
> code or the Issue code (and sharing code is the main benefit of
> subclassing), so it seems to me that this provides no benefit...   You
> can probably make each subclass a fully independent class, with no
> subclassing involved, without requiring any significant changes to
your
> code.
> 
> Jeff Shannon
> Technician/Programmer

Jeff, 

Thanks very much for the feedback - very useful and provides a lot of
food for thought. It's this kind of community feedback that makes
Python so enjoyable to use.

This is the first program where I've used OO strictly, and so I'm not
completely clear why I made them subclasses. I think you're right -
they don't need to be. I'll try and make the changes later this
evening (UTC), wife permitting ;-)

Thanks again
Adam
--
proj: http://jiletters.sf.net
site: http://www.monkeez.org
wiki: http://wiki.monkeez.org
_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor



Any e-mail message from the European Central Bank (ECB) is sent in good faith but shall neither be binding nor construed as constituting a commitment by the ECB except where provided for in a written agreement.
This e-mail is intended only for the use of the recipient(s) named above. Any unauthorised disclosure, use or dissemination, either in whole or in part, is prohibited.
If you have received this e-mail in error, please notify the sender immediately via e-mail and delete this e-mail from your system.




More information about the Tutor mailing list