[Seaside] Smalltalk design advice - how to implement genericbi-directional pointers?

Sebastian Sastre ssastre at seaswork.com
Fri Dec 21 13:30:45 UTC 2007


Hi Sophie,

	this can sound basic but smalltalk has the virtue to allow you to
easily get the conceptual domain in a computer domain. Usually you take
concepts of real world, make a model in your mind of things you are
observing from it and then program them in "a computer". Maybe I didn't
observe the world enough but I don't know of real rooms in wich you can add
real houses in them, so it sounds to me that the conceptual model should be
reviewed even before to try to make a machine that can make that at
industrial scale.

	I use to take my time to mature the conceptual models before making
them in smalltalk, sometimes you have to make a little and see what happens
to get some feedback from the proposed design and define next steps. As
allways there are exceptions but the default for bidirectional knowledge is
not to do it and review design. Probably there is a more proper (so
extensible) way to achieve similar objetives.

	cheers,

Sebastian 

 

> -----Mensaje original-----
> De: seaside-bounces at lists.squeakfoundation.org 
> [mailto:seaside-bounces at lists.squeakfoundation.org] En nombre 
> de itsme213
> Enviado el: Viernes, 21 de Diciembre de 2007 04:33
> Para: seaside at lists.squeakfoundation.org
> Asunto: [Seaside] Smalltalk design advice - how to implement 
> genericbi-directional pointers?
> 
> I don't think I have grasped the "Smalltalk Way" to deal with 
> this and am looking for some design advice ...
> 
> I often repeat this kind of code to maintain relations that I 
> have implemented as bi-directional pointers (illustrative 
> example only):
> 
> Object subclass: #House
>    instanceVariableNames: 'rooms'
> 
> House>>addRoom: aRoom
>     self basicAddRoom: aRoom
>     aRoom basicAddHouse: self
> 
> House>>basicAddRoom: aRoom
>     rooms add: aRoom
> 
> House>>removeRoom: aRoom
>     self basicRemoveRoom: aRoom
>     aRoom basicRemoveHouse: self
> 
> House>>basicRemoveRoom: aRoom
>     rooms remove: aRoom
> 
> Object subclass: #Room
>     instanceVariableNames: 'house'
> 
> Room>>addHouse: aHouse
>     self basicAddHouse: aHouse
> 
> Room>>basicAddHouse: aHouse
>     house notNil ifTrue: [house basicRemoveRoom: self]
>     house := aHouse
> 
> etc.
> 
> How can I make this relation-management code generic, so I 
> can easily add it to any class with any named accessors, any 
> number of times? I prefer to avoid DNU approaches if possible 
> as this code will be called in several inner loops that need 
> to run fairly tight. I thought traits might help but now 
> don't think so.
> 
> Thanks - Sophie 
> 
> 
> 
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list