MagmaCollection API
Chris Muller
chris at funkyobjects.org
Thu Sep 14 02:27:53 UTC 2006
Before, #read:at: that was on MagmaCollection and returned a reader;
| reader |
reader _ cases read: #id at: id.
reader size > 1 ifTrue: [self error: 'Multiple objects with the same
UUID!'].
^reader size = 1 ifTrue: [reader at: 1] ifFalse: [nil]
so you still had to do the size checking, nothing has changed w.r.t.
that. The only difference is now we have just one #where: method for
all querying rather than multiple methods. Everyone is concerned with
code bloat, so I think #where: handling all cases was addition by
subtraction.
The other thing to watch out for with the above code is, because the
reader is based on a collection that is always changing, its really
best to use #at:ifOutOfBounds: since, theoretically, another user could
remove objects causing the size to change.
> PS. I am now experimenting with a shared magma session in combination
> with one per user - I drowned in too much materialization otherwise.
By "otherwise", do you mean the strict 1:1? And even after employing
correct read-strategys?
thanks..
--- goran at krampe.se wrote:
> Howdy all, and Chris of course!
>
> Ok, let me show you a method in Gjallar:
>
> findObjectById: id
> "Find any object by id. Return nil if not found."
>
> | reader |
> reader _ cases where: [:each | each read: #id at: id ].
> reader size > 1 ifTrue: [self error: 'Multiple objects with the same
> UUID!'].
> ^reader size = 1 ifTrue: [reader at: 1] ifFalse: [nil]
>
> So "cases" is a MagmaCollection with an index #id. Now... what is the
> preferred simplest way of doing the #read:at: ? Nowadays this method
> is
> not on MagmaCollection but on the reader. So.... the above looks
> needlessly complex IMHO - or is there a point I am missing?
>
> regards, Göran
>
> PS. I am now experimenting with a shared magma session in combination
> with one per user - I drowned in too much materialization otherwise.
> _______________________________________________
> Magma mailing list
> Magma at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/magma
>
>
More information about the Magma
mailing list