2011/5/5 Stéphane Ducasse <[email protected]>:
> why not putting the method in your domain object root?
When doing things like this domain object could return objects out
side of the domain object hierarchy and they should be copied. Most
notably collections. Also I think that if copyTwoLevel it is too
spesific for object it is too spesific for domain objects. That does
not matter now because the approach was flawed...
Original idea was to copy only two levels to avoid too much work and
only do more copying when necessary. Two levels where copied because
this would handle situations where objects internal state is changed.
More levels would get copied when the proxied object would return new
values. Thus the proxy had following code.
doesNotUnderstand: aMessage
| result |
accumulator add: aMessage -> originalObject.
result := aMessage sendTo: copyObject.
^ (result isLiteral)
ifTrue: [ result ]
ifFalse: [ transaction proxyFor: result ]
And copyObject is initialized using originalObject copyTwoLevel.
However this just is not a proper solution because there might be
calls that dive deeply in the structure and alter objects that have
not been copied yet (they are lower than second level from object the
message is send). But deep copy alone won't handle this either. After
deep copying it is hard to say which objects where changed and which
were not.
--
Panu