 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Casper Guest
|
Posted: Mon Sep 05, 2005 2:15 pm Post subject: Swing AbstractAction/Action relation to the MVC? |
|
|
It's great to be able to isolate UI events into Swing actions so the
same action is called from a menu, toolbar and/or shortcut. But what is
its relevance to the MVC-pattern. I have isolated all UI actions of my
app in a single ActionFactory class, but I am simple unsure about how
this plugs in with a model. Are the actions part of the view or the
controller?
Any pointers or references greatly appreciated,
Casper
|
|
| Back to top |
|
 |
Giovanni Azua Guest
|
Posted: Mon Sep 05, 2005 3:36 pm Post subject: Re: Swing AbstractAction/Action relation to the MVC? |
|
|
Hi Casper,
IMHO What you mean as actions is the Controller itself.
The Controller (even though can be implemented generic enough)
would know about/coupled with the interfaces of the View (visualization)
and Model (underlying structures that could be e.g. persistent).
I think one has reached the optimal MVC implementation whenever
you can redefine/switch any of the three components without breaking the
other two e.g.
Swing application optimally implemented as MVC is converted into
Web Application by switching to a different View component, ideally
the Controller would be easily wrapped or extended to support the
J2EE-specifics e.g. servlets
HTH,
Best Regards,
Giovanni
"Casper" <casper (AT) jbr (DOT) dk> wrote
| Quote: | It's great to be able to isolate UI events into Swing actions so the same
action is called from a menu, toolbar and/or shortcut. But what is its
relevance to the MVC-pattern. I have isolated all UI actions of my app in
a single ActionFactory class, but I am simple unsure about how this plugs
in with a model. Are the actions part of the view or the controller?
Any pointers or references greatly appreciated,
Casper
|
|
|
| Back to top |
|
 |
Karsten Lentzsch Guest
|
Posted: Tue Sep 06, 2005 12:55 pm Post subject: Re: Swing AbstractAction/Action relation to the MVC? |
|
|
Casper wrote:
| Quote: | It's great to be able to isolate UI events into Swing actions so the
same action is called from a menu, toolbar and/or shortcut. But what is
its relevance to the MVC-pattern. I have isolated all UI actions of my
app in a single ActionFactory class, but I am simple unsure about how
this plugs in with a model. Are the actions part of the view or the
controller?
|
Actions fit better into the "Presentation Model" (PM)
pattern. And let me add that MVC is for components,
PM and MVP are for applications.
You can find descriptions of both MVP and PM at
http://www.martinfowler.com/eaaDev/OrganizingPresentations.html
I provide a "Desktop Patterns & Data Binding"
presention where I show how Actions can be used
in Swing in combination with the PM pattern.
See http://www.jgoodies.com/articles/
Hope this helps. Kind regards,
Karsten Lentzsch
|
|
| Back to top |
|
 |
Giovanni Azua Guest
|
Posted: Tue Sep 06, 2005 3:54 pm Post subject: Re: Swing AbstractAction/Action relation to the MVC? |
|
|
Hi Karsten,
"Karsten Lentzsch" <karsten (AT) jgoodies (DOT) com> wrote
| Quote: | Actions fit better into the "Presentation Model" (PM)
pattern. And let me add that MVC is for components,
PM and MVP are for applications.
You can find descriptions of both MVP and PM at
http://www.martinfowler.com/eaaDev/OrganizingPresentations.html
I provide a "Desktop Patterns & Data Binding"
presention where I show how Actions can be used
in Swing in combination with the PM pattern.
See http://www.jgoodies.com/articles/
According to you what is fundamentally the difference between |
Presenter and Controller? and another comment, using the Observer
Pattern is perfectly viable having a Controller that is totally
decoupled from the other two (MV) e.g. Eiffel Event Library
using agents.
Why do you assert that MVC is only for components? e.g.
Visual C++ applications use MVC Pattern, Java Web and
Swing applications as well employ MVC.
Kind Regards,
Giovanni
|
|
| Back to top |
|
 |
Karsten Lentzsch Guest
|
Posted: Wed Sep 07, 2005 9:38 am Post subject: Re: Swing AbstractAction/Action relation to the MVC? |
|
|
Giovanni Azua wrote:
I think Martin Fowler describes this well in this writing:
http://www.martinfowler.com/eaaDev/OrganizingPresentations.html
| Quote: | Why do you assert that MVC is only for components? e.g.
Visual C++ applications use MVC Pattern, Java Web and
Swing applications as well employ MVC.
|
More precisely: MVC is better for components,
MVP and PM are better for applications. In Smalltalk
where MVC was invented, whole apps were built with MVC.
Since modern toolkits already handle fine grained events,
the application's presentation logic can focus on
coarse grained events that lead to operations on
the domain or presentation state.
And yes, you can build a Swing application that uses
MVC. But no, Swing itself doesn't use MVC; instead
it uses a variant of MVC. For example in Swing the
painting code and the event handling is not separated,
it is typically done in a single class, the UI delegate.
You can find some diagrams about the difference between
MVC and the variant used in Swing in my presentations
"Desktop Patterns & Data Binding" as well as in
"Data Binding for Swing" at http://www.jgoodies.com/articles/
- Karsten
|
|
| Back to top |
|
 |
Casper Guest
|
Posted: Wed Sep 07, 2005 3:33 pm Post subject: Re: Swing AbstractAction/Action relation to the MVC? |
|
|
Thanks to all for the answers. :)
Regards,
Casper
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|