aspose file tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes MVC and dialogs Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Reply Bookmark "MVC and dialogs" Watch "MVC and dialogs" New topic
Author

MVC and dialogs

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 3901
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]

I never took notes in college. That's how I got a 4.0 the first 2 years, and a 3.5 the second two years.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2159
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: 3901
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: 2159
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.

 
 
subject: MVC and dialogs
 
Threads others viewed
calling batch files
run-time error HELP!
refactoring to fit MVC
HELP!!!! how does Character.isLetter work? (need experts)
switch statement
developer file tools