OOP design question

Michal Wallace sabren at manifestation.com
Wed Jun 20 00:26:29 EDT 2001


On 19 Jun 2001, Anthony Veale' wrote:

> Let me be concrete here.  I'm writing a program to edit the Opera 5
> for Linux bookmarks file.  I designed some classes for Urls and
> Folders and one for the bookmark file as a whole.  The BookmarkFile
> class contains instances of Folders and Urls.
> 
> Then when I started to design the editing program, I found that
> there are some features that I wanted to add to Folders, that are
> really only applicable to Folders when editing the bookmark file.


I'm not sure I really understand the problem you're having..  It kind
of depends on the specific features you're trying to add.

Not knowing any more than that, though, my gut feeling is to suggest
making a new object (Editor, for example) that acts on a
Folder. Folder itself should provide an interface for changing its
data, but Editor would coordinate between the Folder instance and the
UI.. 

I could be wrong, but I think the your situation is better solved
using composition (one object using/owning another) rather than
inheritance.

Cheers,

- Michal
------------------------------------------------------------------------
www.manifestation.com  www.sabren.net  www.linkwatcher.com  www.zike.net
------------------------------------------------------------------------





More information about the Python-list mailing list