TreeView node and multiple inheritance challenge

  • Thread starter Thread starter Hazz
  • Start date Start date
H

Hazz

I am just beginning to design a Treeview display (winforms) for wine
regions. Problem. Some wine growing regions belong to two counties. Eg.
Carneros is in both Napa and Sonoma Counties. Although most nodes will have
only one parent, a few will have two parents. The Treeview which seems to me
to lend itself to the Windows Explorer type of app could not possibly show
one file as a leaf belonging to two different parent folders. You either
have a file in this folder or that one. Before I begin my exercise, I wanted
to think about how I could represent a node to have a visual indication that
a particular node has lines drawn to attach it back to two different parent
nodes? Really this is an example of multiple inheritance in a very practical
sense. Thank you for any ideas. -hazz
 
Hazz,

First, your case isn't a case of multiple inheritance. It isn't a case of
inheritance at all. Inheritance defines "IS A" relationship. IS wine growing
region A county? No.

As for TreeView, I would probably append "see also" to a node label, i.e.:

Napa
...
Carneros (See also Sonoma County)
...
Sonoma
....
Carneros (See also Napa County)

HTH,
Alexander
 
Alexander,
Thank you for your very practical suggestion to simply qualify the dual
parent nodes by a node label clarification.
Thank you also for the "IS A" point you mentioned. I am thinking through
this. Could a wine growing region be a location as a county is?
Is a wine growing a geographical location, as a county is, which itself has
an "IS A" relationship with a state or province which are themselves
geographical locations? Like an employee has an "IS A" relationship with a
person (class?)
Thank you for helping me clarify this. I see your point absolutely and I am
not certain I am looking at these relationships correctly yet.
I should have stated that one node has two parents and not taken that leap
so quickly to the OO analogy. thx -hazz
 
Hazz,

Certainly, a county and a wine growing region have similarities. They both
have name and topological borders:

class Region {
string Name;
Point[] Borders;
}

class County : Region {...}

class WineGrowingRegion: Region {...}

But here the multiple inheritance strikes: IS a county also A political
system entity?

class PoliticalSystemEntity {
string Name;
Point[] Borders;
void ElectGovernor();
decimal CollectTaxes();
}

You can't do that:

class County : Region, PoliticalSystemEntity {
< confusion!!! >
}

I would say that the hardest problem of OO Design is to determine which
branch of inheritance is more important semantically, and your example
demonstates it very clearly.

How would I do it in your case? It's hard to say... I think I would let Wine
Growing Regions be a separate entity... Political systems come and go, wine
culture stays.


Alexander
 
Back
Top