Notifying structures of editions

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

Notifying structures of editions

Damien Pollet
Hi,

When editing a structure, accessors are called via Magritte but there
is no way for the structure to reinitialize itself before any accessor
is called, or to re-establish its invariant after all accessors have
been called.

I thought I'd wrap PRCommand>>doExecute with something like self
structure willEdit and self structure didEdit, would that make sense?

I also saw PRStructure>>validateCommand which shouldn't modify the
structure, but in my case (Citezen) validating means parsing that
takes time and I'd prefer not to repeat that work when committing the
edition to the structure.

I think writing this helped me see a solution:
- validation does the heavy parsing and stores result in (an adhoc
subclass of) the edit command
- executing the command stores parsed data in the structure and resets
the final data
- a lazy accessor for the final data builds it and ditches the parsed data

hopefully that was clear… if you have suggestions…

--
Damien Pollet
type less, do more [ | ] http://typo.cdlm.fasmz.org


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Notifying structures of editions

Lukas Renggli-2
> When editing a structure, accessors are called via Magritte but there
> is no way for the structure to reinitialize itself before any accessor
> is called, or to re-establish its invariant after all accessors have
> been called.

It is possible to create a subclass of PREditCommand and override  
#doExecute to trigger some postprocessing.

> I thought I'd wrap PRCommand>>doExecute with something like self
> structure willEdit and self structure didEdit, would that make sense?

Exactly.

> I think writing this helped me see a solution:
> - validation does the heavy parsing and stores result in (an adhoc
> subclass of) the edit command
> - executing the command stores parsed data in the structure and resets
> the final data
> - a lazy accessor for the final data builds it and ditches the  
> parsed data
>
> hopefully that was clear… if you have suggestions…

Generally getting notified about events is a bit of a problem in Pier.  
Several things (such as creating new structures, persistency, etc) are  
quite, because this triggers events in rather clumsy ways. I once  
rewrote part of this mess using announcements, which provides a  
significant improvement over the current status but also breaks/
changes certain things. Unfortunately I lost the image, but if I have  
time I probably redo it.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch



_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki