Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes OO, Patterns, UML and Refactoring and the fly likes MVC questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "MVC questions" Watch "MVC questions" New topic

MVC questions

Alexander Curvers
Ranch Hand

Joined: Apr 03, 2009
Posts: 33
In MVC you have
the view sending events to the controller. and the controller sending messages to the model.. thus often the model gets updated.
then the view uses the model to update 'itself'

i have a few questions about the exact implementation
1 how does a view get references to the model objects it needs to update itself.. does the controller return the references to these objects ?

if anyone has links to mvc examples/tutorials where the info is detailed about the implementation.. it would be appreciated
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

I had the honor of meeting and talking to Trygve Reenskaug, the originator of the MVC pattern, at the SPLASH 2012 conference in Tucson, AZ this past week. Trygve is an amazing person, in his 80s but still very sharp. It might help if you read some background material about MVC, written by Trygve:

In particular, your understanding that the view sends events to the controller is incorrect. In his paper on MVC dated 10 December 1979:
Trygve Reenskaug wrote:..a view should never know about user input, such as mouse operations and keystrokes.

Regarding your question of how the view gets references to the models, what have you tried that made you ask this question and what problems are you encountering?

Junilu - [How to Ask Questions] [How to Answer Questions]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

One of the most important things to know about MVC is that it's designed so that you can have more than one View of a Model (for example, a chart and a table) and you can have views that reference more than one model object. In other words, Models and Views have a Many-to-Many relationship.

The Controllers bind Models and Views together. A controller handles UI events from the View, posting updates to the Model. Likewise, updates to the Model are reflected into the View by the Controller.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: MVC questions
It's not a secret anymore!