Two variants of class hierachy
Peter Otten
__peter__ at web.de
Sat Nov 19 12:25:57 EST 2016
Victor Porton wrote:
> I am developing software which shows hierarchical information (tree),
> including issues and comments from BitBucket (comments are sub-nodes of
> issues, thus it forms a tree).
>
> There are two kinds of objects in the hierarchy: a. with a (possibly long)
> paginated list of childs; b. with a short list of strings, each string
> being associated with a child object.
>
> I have two variants of class inheritance in mind. Please help to decide
> which is better.
>
> The first one declares only one base class, but some its method remain
> unimplemented (raise NotImplementedError) even in derived classes.
Two observations:
In Python you can also use "duck-typing" -- if you don't want to share code
between the classes there is no need for an inhertitance tree at all.
Pagination is a matter of display and will be handled differently in a PDF
document or web page, say. I would not make it part of the data structure.
More information about the Python-list
mailing list