Exactly :).

In Fame, there is a FMMultivalueLink hierarchy that implement many to one and many to many relations. This implementation exists since before slots and now we should reimplement them with slots. It will make the code so much nicer :).

Anyone interested in picking this up?

Cheers,
Doru


On Mon, Feb 23, 2015 at 10:34 PM, Ben Coman <btc@openinworld.com> wrote:
I haven't played with the relation example yet, but will real soon.  Just some initial thoughts...

I like RelationSlot.  To me association seems one-way while a relation is two-way.

btw, Is there some reason to not match the syntax of the often cited paper "Flexible Object Layout" ?  
I see one advantage is that its easier to read all the slot names vertically aligned.

Object subclass: #SlotExampleMovie
slots: { 
#name. 
#year. 
#director => ToOneRelationSlot opposite: #directedMovies class: #SlotExamplePerson.
#actors => ToManyRelationSlot opposite: #actedInMovies  class: #SlotExamplePerson. }
classVariables: {  }
category: 'SlotAssociations-Tests-Example'


Also maybe an alternative slot class name so that it reads more like a sentence... "#director related to one #directedMovies in class #SlotExamplePerson"

Object subclass: #SlotExampleMovie
slots: { 
#name. 
#year. 
#director => RelatedToOne inverse: #directedMovies inClass: #SlotExamplePerson.
#actors => RelatedToMany inverse: #actedInMovies  inClass: #SlotExamplePerson. }
classVariables: {  }
category: 'SlotAssociations-Tests-Example'

Or even...

Object subclass: #SlotExampleMovie
slots: { 
#name. 
#year. 
#director => OneRelatedTo many: #directedMovies inClass: #SlotExamplePerson.
#actors => ManyRelatedTo many: #actedInMovies  inClass: #SlotExamplePerson. }
classVariables: {  }
category: 'SlotAssociations-Tests-Example'

cheers -ben


On Tue, Feb 24, 2015 at 2:33 AM, Jan van de Sandt <jvdsandt@gmail.com> wrote:

On Mon, Feb 23, 2015 at 9:59 AM, Marcus Denker <marcus.denker@inria.fr> wrote:

> On 21 Feb 2015, at 21:11, Jan van de Sandt <jvdsandt@gmail.com> wrote:
>
> Today I experimented a little with the new Slots feature of Pharo 4.0. As an example I implemented support for associations/relationships.
>

Very nice! Can I add this to Pharo4 as an example?

Sure, cool!
 
My idea is that at first we add these things as examples, and then later take the examples and distill a library of
generally useful slots.

 
That sounds like a good approach to get familiar with these kind of new features.

Some things I can do to improve the Example
-  Add an option to make one side of the association readonly. In most situations I think it's a good idea to update an association only from one side to keep things simple.
- Whats a better name AssociationSlot or RelationSlot? I'm not sure
- As Stéphane said, isn't there a nicer way to declare the associations?
- Better error handling

Jan.









 





--
www.tudorgirba.com

"Every thing has its own flow"