Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC and dialogs

 
Randall Twede
Ranch Hand
Posts: 4481
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4481
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic