• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Share a base class or to not share?

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I have entity type category and another entity type - logisitchierarchy.
From the business prespecive they have nothing in common.
From the structre prespective - they both have a tree (hierarchy structre - parent - childs) - so they share "structre functionality" like calculate path , get root and etc.


if for each i write the structre and they not share the same base, fix for the base structre - for example you discover that the best way to model tree is with addtional column for calculate-path..., will required to fix it in all "trees structre" in the application.

in addtional base class for all make it easier to share structre functionalty.

what is your opinion - does common structre (a one that required complex functuionality) are a good reason to inherit from the same class?
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

From the business prespecive they have nothing in common.
From the structre prespective - they both have a tree (hierarchy structre - parent - childs) - so they share "structre functionality" like calculate path , get root and etc.



Then derive both from a third class, e.g. CompositeObject. Simply deriving the second class from the first has the disadvantage of possibly inheriting more than the tree-related behavior...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic