Class hierarchy problem

Terry Reedy tjreedy at udel.edu
Tue Aug 6 19:13:40 EDT 2013


On 8/6/2013 11:36 AM, BrJohan wrote:

> Consider a botanical classification system (somewhat analogous to my
> 'problem' as it effectively is related to classification of entities):
>
> A Domain should know about its Kingdoms,
> a Kingdom should know about its Phylums,
> ...
> a Genus should know about its Species.

As some already said, 'a domain' is an instance of Domain (or possibly 
generic Taxon). We have on Earth one instance of 'Life'.
>
> Of course it is possible to implement such a decision tree as a
> 'factory'. However, I would rather prefer to encapsulate those decisions
> at the class level where they 'belong'.

Each instance could have a .classify function that assigns instances to 
sub-instance. The master classifier function would only know how to use 
the .classify functions and have no specific content knowledge in itself.

-- 
Terry Jan Reedy




More information about the Python-list mailing list