From: stefoid on
The view in my aplication observes the model via propertyChangeSupport
(Java). This allows an observer to register as listener for a
PropertyChangeEvent by passing in an event name string such as
"something_happened".

I have a single model object which holds the PropertyChangeSupport
mechanism. This model object is just for encapsualtion - it is
composed of all the working model objects. When these objects have an
atribute change that they want to alert the view to, they call a
method on the encasulating model object, and it fires the
PropertyChangeEvent for them. The idea here is that the view objects
dont have to know about the internals of the encapsulating model
object - all they are interested in is one or more attributes which
they register as a listener for by its property change string - they
get the data they are interested from the PropertyChangeEvent when it
fires.

So the coupling between view and model internals is quite low. The
view has to know the type of the data passed in the
proeprtyChangeEvent, but this doesnt have to be the same type as the
model's internal data it is generated from. The PCE data type is
designed for GUI consumption so it shouldnt need to change even if the
underlying model type(s) that generates it, does change.

However this falls down at initialization. View objects need to be
fully initialized when they are created. I thought that maybe I
could fire a property change event to a specific listener for a
specific attribute when the view first registers as a listener for
that attribute, thus initializing it. But that doesnt work because the
knowledge of which event name corresponds to which actual attribute is
only known by the model object that holds the attribute. That only
time that connection is made is when the internal model object fires
an event like : fire event (name, PCE). So I am falling back to the
view objects having to know which the object and attribute diretly to
initialize themselves when they are created (using a getter).

long winded question but:

a) do you think the direct connection between view and model is a
problem?
b) is there any established way to get around that direct connect?

cheers