On 27 nov. 2009, at 17:06, Tudor Girba wrote:
Hi Alex,
Why do you say that they do not have the same behavior? They both
return a collection with all the instances of the given Class from
the group.
Alex forgot to explain the use case.
Take some elements of ClassA, some elements of ClassB, and both ClassA
and ClassB are subclasses of ClassC.
Now ask aMooseModel allWithType: ClassC
It works with a SetupStorage which performs a #isKindOf: test
but does not work with a RuntimeStorage for which there is no byGroup
at: ClassC
Instead, you have one group ClassA -> {a1, a2} and one group ClassB ->
{b1, b2}, which are initialized when filling up the model.
Now I havent really thought through this, but I guess it will be ok to
do some lazy computation for such a case.
Is just that the SetupStorage stores elements in an ArrayList, which
makes it faster to add elements, while the RuntimeStorage has a more
elaborate caching mechanism (for example byGroup) for retrieving
elements faster.
Cheers,
Doru
On 27 Nov 2009, at 18:39, Alexandre Bergel wrote:
Dear List,
While programming with Simon, we bumped into a sensible issue.
Consider the two following methods:
SetupStorage>>selectAllWithType: aSmalltalkClass
^ self select:
[ :each |
"-- select returns an ArrayList"
each isKindOf: aSmalltalkClass ]
RuntimeStorage>>selectAllWithType: aSmalltalkClass
^ byGroup
at: aSmalltalkClass
ifAbsent: [ OrderedCollection new ]
These two methods do not have the same behavior.
We could have something starting with "(byGroup keys select: [:cls
| cls isKindOf: aSmalltalkClass]) ..."
But that would defeat the whole idea of having different storages...
Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel
http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
--
www.tudorgirba.com
"Be rather willing to give than demanding to get."
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
--
Simon