[squeak-dev] versioning objects
Jimmie Houchin
j.squeak at cyberhaus.us
Wed Apr 16 17:06:26 UTC 2008
Colin Putney wrote:
>
> On 15-Apr-08, at 3:15 PM, Jimmie Houchin wrote:
>
>> Currently I am implementing accessors which simply create an
>> OrderedCollection for each attribute.
>>
>>
>> id: anObject
>> id ifNil: [
>> id := OrderedCollection new.
>> id add: anObject].
>> (id = anObject) ifFalse: [id add: anObject]
>>
>>
>> obj id
>> ^ id last
>>
>>
>> Is there a more standard or better way to offer such features?
>
> I think an important thing to consider is the unit of work that will be
> undoable. If it's "revert #id of <some object> to the previous value"
> then your ordered collection scheme is probably not bad. But if there
> are more complex actions that need to be undo, this kind of thing will
> be difficult.
>
> The usual way to do this is to have all your undoable units of work be
> implemented by "command" objects that know how to perform a specific
> action. Then when the user does something undoable, you create a
> command, execute it, then push it on the undo stack. To undo you can
> either have the command know how to undo its self, or have it create an
> "inverse" command. This kind of thing works pretty well, and it can be
> extended with other features like redo, logging, journal-and-snapshot
> persistence etc.
>
> Hope this helps,
Thanks Colin (and Tim).
I'll have to study that and learn how to do that. Right now I have a
vague understanding of what you are saying, But it will require some
thought before I can proceed implementing such.
Currently I went forward with accessors for all of my attributes like I
wrote above. That will give me a history of the attribute which I can
display to the user for them to be able to manipulate.
Again thanks for something to explore and learn about and possibly use
in a future iteration.
Jimmie
More information about the Squeak-dev
mailing list
|