Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC questions

 
Alexander Curvers
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 7482
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html

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?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18214
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic