Should I use concrete Inheritance or not?

Posted by Mez on Stack Overflow See other posts from Stack Overflow or by Mez
Published on 2010-05-29T18:17:23Z Indexed on 2010/05/29 18:22 UTC
Read the original article Hit count: 319

I have a project using Propel where I have three objects (potentially more in the future)

  1. Occasion
  2. Event extends Occasion
  3. Gig extends Occasion

Occasion is an item that has the shared things, that will always be needed (Venue, start, end etc)

With this - I want to be able to add in extra functionality, say for example, adding "Band" objects to the Gig object, or "Flyers" to an "Event" object.

For this, I plan to create objects for these. However, without concrete inheritance, I have to have the foreign key point to the Occasion object - giving the (propel generated) functions for all of these extra bits to anything inherited from Occasion.

I could, in theory do this without a foreign constraint, and add in functions to use the Peer or Query classes to get things related to the "Gig" or similar. Whereas with concrete inheritance, I would only have these functions in the things where they are.

I think the decision here is whether I should Duck Type the objects (after all they are occasions) or whether I should just use the "Occasion" object as a "template" (only being used to search for things, like, all occasions at a venue)

Thoughts? Comments?

© Stack Overflow or respective owner

Related posts about inheritance

Related posts about propel