[Q] DependentsArray has weakreferences

Andreas Raab Andreas.Raab at gmx.de
Sat Mar 9 18:59:38 UTC 2002


Diego,

> I think that you assume that view means gui-view....

Even more specifically, MVC views. After all, that's the semantics Model
implements.

> >Views need models. Models do _not_ need views (at least that's the
> >theory).
> 
> I'm not sure that model do not need views...

As I said "that's the theory" (of MVC). An interesting (though
completely besides the point) note here is that the supposed
independence of models from views (which is broken in various places)
was one of the reasons for developing other UI frameworks (like MVP).

> if an object is not observed 
> by anyone the object will die...

But this applies only if the observer requires the object to be around.
In various places this is not the case and the observer can use weak
references itself - so even if the object is observed it might die. This
happens for example in all the registries which in fact observe the life
time of an object by viewing it weakly.

> >Thus if the last reference to a view goes away that view should
> >go away without bothering the programmer to manually deregister.
> 
> Here the definition of "last reference" is not clear to me.... I can 
> consider that the last reference comes from the model....

Yes, you can. But that's not the semantics that Model implements.

> My problem appears because the dependents mechanism assume 
> that you must have other strong-reference to a view to work....
> in most of the cases this extra strong reference is the World...
> in my case this extra strong-reference is in other image.

So the "view here" is really a remote representation of the "view there"
right? So how do you represent a message that is sent to the "view
there" in the "view here" without having a strong link to the "view
here" somewhere?

> From my point of view, one object can observe other object 
> without the needing of a third one.

Absolutely. However, (besides just not being the semantics of Model) you
need to ask yourself what that means. If an object views another one
passively (e.g., the viewee does not know about its view) and the view
is not referenced anywhere then the only services it can provide are
side effects. This is because no object can ask anything from the view
(since there is no reference to it) and the only thing that object can
affect is the environment. Which ultimately leads to the question: Does
a tree falling in a forest make a sound if nobody is there to hear it? I
say: No ;-) (and the garbage collector agrees...)

Cheers,
  - Andreas





More information about the Squeak-dev mailing list