• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using composition instead of inheritance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using composition instead of inheritance


  • Subject: Using composition instead of inheritance
  • From: Paul Hoadley <email@hidden>
  • Date: Tue, 29 May 2012 15:46:17 +0930

Hello,

I'm after some general modelling advice.  I've been using inheritance for years to model app-specific versions of a framework-level Person (user) entity.  This works well enough, though it presents the same small headaches time after time for each new application.

I also have a framework-level Organisation entity to model a user's organisation.  I need to customise this for a new application, and I thought this time I would use composition instead of inheritance—I'll create a new FooOrganisation entity which has a to-one relationship to Organisation (without the inverse relationship), and then the additional attributes and/or relationships which are app-specific.

The application is still in development, but there's a demo deployment, and while I _can_ wipe the database, there are existing Organisation EOs in it, and it would be nice if I didn't have to.  I'm using migrations, so I can perform any one-off fix-ups in a post-migration step.

So, do people model like this?  Are there any pitfalls?  What's the best way to ensure referential integrity, such that Organisation and FooOrganisation remain 1-1—'owns destination' and 'propagates primary key'?  (Selecting those will require I scrap the DB and create the FooOrganisations first, won't it?)  Would dynamically adding some properties to the model at runtime be a better option here if I just want to store, say, a few limited extra attributes on an entity?


-- 
Paul Hoadley
http://logicsquad.net/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Using composition instead of inheritance
      • From: Ken Anderson <email@hidden>
  • Prev by Date: Re: mdimensions down?
  • Next by Date: ERJaveMail
  • Previous by thread: Re: mdimensions down?
  • Next by thread: Re: Using composition instead of inheritance
  • Index(es):
    • Date
    • Thread