Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC and java

 
Rajesh Khan
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a bit of confusion regarding MVC some people say that view should never interact directly with the model and vice versa while others say it can ?? What is the correct way here ?? Furthermore in my applications actions are being performed by anonymous classes in swing. How can i apply mvc here when i my service layer already has services in it suplied by a factory. I mean to say what would the controller look like ??
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my use of MVC, the View class always gets handed a reference to the Model to draw data from along with other information required to create a complete display.

The Controller gets involved in the interpretation of the current state of the program and preparing data for output by the view + model.

Generally speaking I find it easy to decide what goes in View and Model classes and a lot harder to separate controller functions into a separate class so controller functions tend to end up scattered around wherever it seems logical.

Bill

 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a bit of confusion regarding MVC some people say that view should never interact directly with the model and vice versa while others say it can ? What is the correct way here ?


There is no single "correct" way to implement the Model-View-Controller design pattern. Design patterns do not dictate or specify implementation details. They provide examples of a possible implementation and serve as design guides. That is all. There can be many variations of a particular design pattern implementation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic