I think that in this situation you need to choose between DRY violation or failure to clutch. I do not think you can avoid both.
If NameView does not contain its own copy of the data, then it will need a pointer to the data. Now you have tightened the clutch because NameView cannot be used on its own.
On the other hand, if NameView stores a duplicate of model data, you violate DRY and you may run into synchronization problems. Many GUIs have a βbindingβ concept that stores values ββthat are synchronized between the model and the view.
Personally, I would choose a loose connection plus bindings. You should not have synchronization problems if the bindings you use are good. The widespread use of bindings in many different languages ββand frameworks suggests that this is a decent approach.
Regarding the use of self.person.name or self.nameView.name , it depends on whether you are trying to change the state of the model or the state of the view. If you are trying to change the model, just change self.person.name . The view must somehow observe the change in the model, and should be able to update it accordingly. If you want to update the GUI and you do not need a model, use self.nameView.name .
source share