Skip to main content
Participant
August 18, 2008
Question

Command factories in frontcontroller

  • August 18, 2008
  • 3 replies
  • 786 views
Hi all,

one of the things I would like to see improved is the way the frontcontroller handles the creation of commands. The FC is now actually a very basic command factory itself: it looks up the class of the command via the event name and dynamically instantiates a new command. I want to be able to create my own command factory that is able to post process a command once it is created and does some configuration (e.g. inject a business delegate into the command).

Any thoughts?
This topic has been closed for replies.

3 replies

Participating Frequently
August 27, 2008
Hi Christophe and Ali,

Here are a few possible use cases for discussion:

(1) Add the new command as it is created to an undo stack
(2) Injecting dependencies like business delegates for testing
(3) Supporting Mate-style mxml controller/command configuration as an alternative to addCommand (you could even use mx:Component to declare commands in-line, and maybe write stuff like {function(e:Event){...}} if you wanted to.
Participant
August 26, 2008
Hi Guys,

I think i mentioned this in another thread too. In a previous release of Cairngorm, i almost added an ICommandFactory interface and a basic implementation within the FrontController, and Cairngorm developers could thereafter plug in their own implementation, but decided not to in the end as we only like to add features that have been required across multiple projects.

Can we discuss some use-cases here, to see if we'd find something like this of value?
Participating Frequently
August 25, 2008
Now that executeCommand is protected, couldn't you just override the method and insert your post processing before calling the command's execute method?