Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC or Moderate pattern for GUI?

 
Suresh Babu Seeram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which pattern is good for our assignment.
Let me know how you guys are implementing?
What are pros & cons of these two patterns in our application (GUI).

Please reply with details.
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Model - View - Controller is the way to go for GUI. Controller has the listeners for the user actions. Also the controller contains the data for the gui components including the TableModel.
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the value of having the listeners in the controller object?
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
View is supposed to be an instance responsible to display the components. It doesn't know anything about user pressing the Search button. Controller has lot of inner classes as listeners which are registered with the view. Basically controller knows what to do for a mouse or keyboard action.
Also when the architecture changes from RMI to EJB, you have change only the controller class.
[ June 16, 2002: Message edited by: Sai Prasad ]
 
Eduard Jodas
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put together gui components and listeners in View classes because they must work together and are highly tight.
I create an Action class (SWING Action) for the main functionalities, one Action per functionality: Search, Book, Exit, Connect, Disconnect. These actions ask the view classes for user data, ask the user for confirmation or any additional data (like number of seats to book), pass the information to the model and finally they pass the model answer to the view classes.
These Actions are my controllers.
Well, at least that's the way it will be when I do it.
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a controller and put the listeners in the controller class.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just wanted to post a link to a MVC site.
Page describing Model View Controller
Mark
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sai Prasad:

Also when the architecture changes from RMI to EJB, you have change only the controller class.

If I'm following this correctly, we are comparing these two controller ideas:
1) Registering the listeners in the GUI components themselves and having the ActionPerformed() call the appropriate method in a contoller.
2) Registering the listeners in the Controller and having the controller respond directly to actions.
Why does registering the event listeners in the Controller class have anything to do with changing how we access our data (RMI or EJB)? For example, suppose your sequence (very generally) is like this:
GUI --> Controller --> Facade --> DataAccess --> Database
If you switch from RMI to EJB you would need to plug in a new DataAccess layer. This is pretty far removed from the controller.
-BJ
[ June 17, 2002: Message edited by: BJ Grau ]
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your 2 ideas don't differ much. I was talking about view holding the listener inner classes.
[ June 17, 2002: Message edited by: Sai Prasad ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic