I remember a quote from either headfirst java or design patterns that
said something like:
"The key to inheritance is to abstract functionality."

I realize we're not talking about inheritance, but I think it still
applies.

It may make logical sense that a user object has a blog that has
entries, but unless a blog object adds functionality, you should just
say that a user has entries.

On Sep 21, 8:33 pm, ringemup <ringe...@gmail.com> wrote:
> There's a pattern I keep running into, and I've been wondering if
> anyone who's encountered it before has an opinion on how best to deal
> with it:
>
> Imagine you have an app that could theoretically stand on its own --
> for now let's say a schedule, but it could be anything (an image
> gallery, a blog, etc).  This app has multiple items per "app
> instance" (i.e. every schedule has multiple events; every blog has
> multiple entries, etc).
>
> For your main project, tou want every user to have one instance of
> what the app provides.
>
> It seems more pluggable to have an intermediary parent model (Schedule
> or Blog or Gallery) between the app items (events, entries, etc) and
> the user / user profile than to assign the items directly to the
> user.  I.e. each Event has a "schedule" FK and the user profile has a
> "schedule" one-to-one field, rather than giving each event a "user"
> FK.
>
> On the other hand, the intermediary model is rather pointless if it
> doesn't have any fields of its own.  It also results in more demanding
> queries and interferes with the use of select_related.
>
> How do you typically handle this case?
>
> Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to