Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Model and View relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Model and View relationship" Watch "Model and View relationship" New topic

Model and View relationship

Alex Sbityakov
Ranch Hand

Joined: Jul 23, 2001
Posts: 49
Fellow Ranchers,
I have a question about the relationship between the View and the Model. According to the MVC pattern the Model should notify the View of state changes. Some posters have proposed using the fireXXX... methods to take care of that, notifying JTables in the View from the TableModel in the Model. My concern is doesn't this create a strong coupling between the classes?
Is it better to use the plain old Observer pattern and just shuttle text-based data from the Model to the View.
Incidentally, some people (who have passed the assignment) did not have the Model notify the View, but used the Controller for that purpose. This sounds strange to me,

Cheers and TIA,
Robin Underwood
Ranch Hand

Joined: May 01, 2002
Posts: 117

I don't think it creates a strong coupling. The model and table model don't need to know anything about the table model listeners. The JTable is a listener just because it was constructed using the table model.
subject: Model and View relationship
It's not a secret anymore!