Hi Panu. I don't know if immutability is available in Pharo, but if it is it may work for you. You basically mark an object as immutable and register an exception handler. When an immutable object's i.v. is assigned a new value, an exception is raised and the assignment is left pending. There you can log the change and effectively apply the assignment to the object. HTH, Andrés Panu Suominen escribió:
Hi,
we have a problem where we must create audit trail of changes made to business objects. Also things should run inside transaction. Our first approach was to create so called command objects from every change but these would be hard to maintain by hand. For example there would be ChangePersonName, ChangeXXXName classes and these would have to be hand created in name: -mehtods. More "clever" approach we come up with is to copy original object and use proxy that records messages send to it and sends them to the copy. Also this proxy creates new proxy when copy returns values. These proxies record message sends to transaction and when transaction is ready these recorded message from all of the proxies are done to the actual objects instead of copies.
To create usable copies I found method that (shallow) copies the actual object and its instance variables (Object>>copyTwoLevel). The method is marked to be deprecated soon. Why is that and is there some alternative way of doing this kind of copy? Also if you know some way to trivially handle the audit trail problem I would like to hear... :)