On Mon, Dec 20, 2010 at 1:13 AM, Stéphane Ducasse
<[hidden email]> wrote:
On Dec 20, 2010, at 3:46 AM, Elliot Finley wrote:
> Hello,
>
> If I have an object with accessors #firstName, #lastName and #age, how would I short shirt circuit or replace these selectors? In other words, how would I modify an object after it's already been created?
Hello
there are plenty of ways to do that but I think that this is not what you want to do.
Tell us what you are trying to achieve?
Did you read smalltalk by example from my web page? There is a chapter on object creation and instantiation.
Stef
I haven't, I'll see if I can find it.
I'm trying to create a memento that will work for a facade. Currently I have:
IFBaseModel >> memento
| memento |
memento := self copy.
memento refModel: self.
^ memento.
Which works for a normal model object. But a facade wouldn't be storing it's values in instance variables. It would be proxying for one or more underlying model objects and so would a copy of that object. So rather than have the memento just be a simple copy of the object, I want it to be a copy of the object and intercept the relevant accessors (I have a list) and redirect them to a dictionary. Then after validation, etc. the updateRefModel selector on the memento would update the underlying model or facade. Thus it would work for both normal models and facades.
Elliot