How come, I got two instances of my model

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How come, I got two instances of my model

Herbert König
Hi,

trying to get to grips with sessions, I found that I got two instances
of my model. Funny thing, if I change one of them (which one?) through
the web browser, both instances get updated.

Can't remember to ever have created a second instance of the model
(addressBook).

What's happening here?
 
Thanks,

Herbert                          mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: How come, I got two instances of my model

Janko Mivšek
Herbert, I hope you solve that problem yet, but let me try to explain,
what could be the reason:

Herbert König pravi:

> trying to get to grips with sessions, I found that I got two instances
> of my model. Funny thing, if I change one of them (which one?) through
> the web browser, both instances get updated.
>
> Can't remember to ever have created a second instance of the model
> (addressBook).

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

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

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

Best regards
Janko


--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: How come, I got two instances of my model

Herbert König
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:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida