On Feb 8, 2009, at 7:39 PM, Krzysztof Kosiński wrote:
- What are the differences between SPAction and Gtk::Action? I
read the code and the only difference seems to be that SPActions derive from NRActiveObject, but this doesn't seem to matter much.
Also SPAction predates Gtk::Action by some time, and were legacy C classes.
So the main thing to keep in mind is that they were in our codebase before something similar was released with GTK+ 2.4.
- Why do we need verbs at all? Why SPActions are bound to a
document when we can just perform them on SP_ACTIVE_DESKTOP when they are activated? Those are GUI actions, so I think it's impossible to perform an action on an inactive document.
There are some instances where a generic verb is more appropriate.
Additionally, SP_ACTIVE_DESKTOP is an older C-style approach that we really need to try to purge. Even with C, it's design breaks encapsulation and modularity. We should try to get rid of its use as much as possible.
Also, not all actions are GUI actions. Instead take the view that they are document actions, and some will manifest in the GUI. It's possible to get some that mainly get activated from a script or from the command-line.
- Why do we have one class per several verbs and a switch in
perform() instead of one class per verb?
There are often many reasons to not have a separate class per verb. The switch is just one particular way of implementing internals. Instead of the numeric enumeration we have been looking into switching to string names (and implementing certain things with atoms), but again that is internal.
For the big-picture, the design patterns the Verb class could be viewed as operating with include Facade, Factory, and perhaps Mediator.