Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Inheritance

  Asked By: Ayden    Date: Aug 03    Category: Java    Views: 1974
  

I have two types of vehicles, forklifts and straddle carriers,
there are also 2 choices of scheduling methods,

I want to be able to have
forklift_schedulemethod1
and forklift_schedulemethod2

and

straddle_Carrier_Schedulemethod1
and straddle_Carrier_schedulemethod2

The question is,
From a design point of view. Is it best to have

forklift_schedulemethod1->forklift->vehicle
and
forklift_schedulemethod2->forklift->vehicle

(where -> means inherits from...)

or should I have it

forklift->schedulemethod1->vehicle
forklift->schedulemethod2->vehicle

bearing in mind that I also have the
straddle carriers too???

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Mildred Bailey     Answered On: Aug 03

Neither. Since a scheduling  method is
not a type of forklift (or the other way
around) you don't have an inheritance
relationship between them. The
scheduling method should be associated
with the vehicle by aggregation or
containment, not inheritance.

 
Didn't find what you were looking for? Find more on Inheritance Or get search suggestion and latest updates.




Tagged: