my dog learned polymorphism*
The moose likes OO, Patterns, UML and Refactoring and the fly likes MVC and dialogs 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 and dialogs" Watch "MVC and dialogs" New topic
Author

MVC and dialogs

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

i am refactoring an old project to fit a MVC framework. in the original i just displayed the dialogs from action Performed. the framework i am forcing it into uses showXXXdialog() methods in View, and calls them from actionPerformed(). ok this seems alright, but!!! the program i am refactoring gets input from some dialogs.the code will show what i am talking about.

actionPerformed() from the original program:


what i have now:

from TopController:


from Model:


first of all it seems kind of silly to call a View method from Controller just to display a dialog.
what is worse is now i have to display a dialog from Model. importing View into Model just to display a dialog seems ridiculous to me.

i don't know why the code posted so poorly, hope you can still read it.

[Edit - fixed code tags - MB]

SCJP
Visit my download page
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Why did you decide to change the code to implement a Model-View-Controller design pattern? For your application will there be any benefits?
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

no, it is just to help me re-learn the pattern/framework. actually i see little benefit gained since it is a pretty small project.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Sounds good. Keep in mind that there are Model-View-Controller-based "frameworks" which are implementing a portion of the Model-View-Controller "object-oriented design pattern." Apache Struts is a good example of a MVC-based framework which is based on the MVC design pattern. Struts enables developers to easily build application Controllers and provides a robust Java Server Page Tag library for creating a HTML-based View. Sometimes individuals miss the fact that a MVC framework is simply a partial implementation of the corresponding OO design pattern. When the framework creators use the "MVC" acronym to describe their work, things get more confusing than they have to be. At its core, MVC is a design concept only.

That said. The other relevant point that you may be close to understanding it that object-oriented design patterns are most beneficial for "big" things, not "small" things. For large applications with teams of developers, not a single programmer. Design patterns are communication tools which enable individuals to discuss complex topics in a simplified and abstract way.

 
GeeCON Prague 2014
 
subject: MVC and dialogs