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

Janko Mivšek janko.mivsek at eranova.si
Fri Feb 6 10:18:28 CET 2009


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


More information about the Aida mailing list