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