Buffered models collections

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Buffered models collections

Esteban A. Maringolo-3
Hi,

        After many time using buffered models (AspectBuffer instances) for
many of my presenters, I find it's usage not very straighforward,
because even implementing a correct #copy of the buffer subject,
many of its objects get not automatically "back" to the subject,
adding work when appling changes.

Is AspectBuffer used to buffer only values of its subject?
Looking at the implementation it looks so, because it uses
ValueAspectAdaptor, and the apply sends #value to each. So it's not
possible to use it to buffer collections or other not value models.

I want to know what solutions or strategies do you use to solve this
¿feature?

Regards,

--
Esteban.


Reply | Threaded
Open this post in threaded view
|

Re: Buffered models collections

Christopher J. Demers
"Esteban A. Maringolo" <[hidden email]> wrote in
message news:[hidden email]...

> After many time using buffered models (AspectBuffer instances) for many of
> my presenters, I find it's usage not very straighforward, because even
> implementing a correct #copy of the buffer subject, many of its objects
> get not automatically "back" to the subject, adding work when appling
> changes.
>
> Is AspectBuffer used to buffer only values of its subject?
> Looking at the implementation it looks so, because it uses
> ValueAspectAdaptor, and the apply sends #value to each. So it's not
> possible to use it to buffer collections or other not value models.
>
> I want to know what solutions or strategies do you use to solve this
> ¿feature?

I have created my own custom AspectBuffer subclasses to add special handling
of contained collections in some cases.  However this may be overkill in
many situations.  You can probably just use something like this:

 model aspectValue: #mySubCollection.

Where mySubCollection is an accessor for the contained collection to create
a ValueAspectAdaptor that will buffer the entire collection. If the user
cancels the dialog the original collection is retained, if the user accepts
it the new collection is used.  If your copy is deep enough this should be
fine.  Just sending aspectValue: is enough, you do not need to use the
returned ValueAspectAdaptor.

I use the above technique when I don't need to persist the objects to a
database.  When I do, I use a relational db/object mapper tool called
ReStore http://www.solutionsoft.co.uk/restore/ that provides its own
transaction support.

Chris