[aida] How come, I got two instances of my model

Herbert König herbertkoenig at gmx.net
Sat Feb 7 17:28:57 CET 2009


Hello Janko,


JM> Herbert, I hope you solve that problem yet, but let me try to explain,
JM> what could be the reason:

no I haven't solved but it isn't a problem. On one side I develop my
model on the other side I try everything I feel I might need with the
Adressbook app of the tutorial to keep communication simple.


JM> I'm sure you didn't create another instance, you just stored a reference
JM> to the same object in two different variables.

JM> Remember, you don't store an object to variable but just a reference (a
JM> pointer) to it. This is sometimes easy to forget and then you have such
JM> surprises.

JM> In this case both variables point to the same object, which you can
JM> check with identity operator ==. Also, you can check with MyClass
JM> allInstances to see how many of them you actually have.

I rechecked ADemoAddrssBook allInstances inspect and in the inspector
with the two instances self first == self last returns false.
BTW self first = self last also returns false. So I guess I managed to
create two addressbooks which point to the same OrderedCollection with
their addresses instance variable.

self first addresses == self last addresses returns true.

Wonder how I managed to do this. Hopefully my subconscious isn't able
to do such sophisticated smalltalk hacking without me noticing :-))

Playing with the redirector of the other thread (thanks for those
hints) gives me more instances which are clearly distinct in having
different ADemoAdress 'es in them and are not cross updated.

I just saved a copy of that image and changes to keep it for further
investigation in the changes file.

BTW I noticed you are announced for the Squeak eV meeting in Potsdam.
A big incentive to make time to be there.

Cheers,

Herbert                            mailto:herbertkoenig at gmx.net



More information about the Aida mailing list