[Seaside] defining relationships...

Peter Osburg peter.osburg at gmail.com
Fri Feb 26 06:34:07 UTC 2010

Hi sergio,

I hope I got your question right because it seems to be an OOP question
instead of a Seaside specific one. But let me try :)

While thinking about your questions. I figured that it would be more easy to
answer the questions when an UML diagram would be present. It seems to be
important to see the communication directions between each class.

The simplest way would be to hold every communication partner in instance
variables. Say you want to know which albums are published by an artists,
then you simply need another instanceVariable at artists called 'albums'.
And you might want to do something like the following in the initialization
method of artist:

Artist >> #initialize
  super initialize.
  self albums: OrderedCollection new.

Same would go for albums. If you want to be able to see the artist of an
album, you need another instanceVariable called 'artist'. It would then hold
an instance of Artist.

Say you now have all the albums in a global Collection, you could do the
following in order to get all albums belonging to fleetwood mac:

albumCollection collect: [:album | album artist name = 'Fleetwood Mac']

You probably could also work with the instance of the artists (which shall
be called fleetwoodMac

albumCollection collect: [:album | album artist = fleetwoodMac]

I hope this would be the right answers for you :)


2010/2/26 sergio_101 <sergiolist at village-buzz.com>

> okay, i am really almost there.. i just need to understand how to
> define relationships between models ..
> for example..
> if i have the following objects:
> Object subclass: #Artist
>        instanceVariableNames: 'name formationYear '
> Object subclass: #Album
>        instanceVariableNames: ' albumName releaseDate numberOfSongs
> duration'
> Object subclass: #Song
>        instanceVariableNames: ' title duration'
> in this case...
> an artists has many albums
> an album has many songs
> and a song has and belongs to many albums (it can be on the original
> release, or it can be on a best of album)..
> so, in this case, how would i define my instance variables to show
> these relationships...
> and how would i grab all songs that belong to a particular album?
> ie..
> how would i say:
> give me all fleetwood mac albums
> or
> give me all songs on the album 'tusk'
> or
> give me all albums that "don't stop" shows up on
> thanks so much!
> --
> ----
> peace,
> sergio
> photographer, journalist, visionary
> http://www.coffee-black.com
> http://www.painlessfrugality.com
> http://www.twitter.com/sergio_101
> http://www.facebook.com/sergio101
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20100226/e5aa9d3f/attachment-0001.htm

More information about the seaside mailing list