The importance of queuing commands

May 5th, 2007 by Jaap Kooiker

As I mentioned earlier I use a MVC framework which we created at my work. Now for AS3 we wanted to revise this MVC framework and review the whole, although it is already pretty good. The discussion about queuing commands raised. Here are some reasons why I think queuing commands is a good practice. Now there are some things you have to consider when using queued commands, like for instance build a (failure-) timeout when executing a command. Otherwise your next command may never be executed.

  • You always know which result belongs to which command dispatched, because you can only execute one command at the time;
  • Browsers have connection limits which opposes a problem when you dispatch multiple commands at the same time;
  • You can use singletons instead of instances as commands, which makes is easier to create and manage EventListeners. It’s more likely you don’t build up countless EventListeners for each command (because it’s a singleton);
  • Starting up an application can be better directed. If you know you have to execute, for example, 20 commands you only have to know if the last command’s result (or fault) event is dispatched. Now you can continue your startup of the application

So these are some main reasons why I think you should use this construction.

Jaap Kooiker

Posted in Actionscript 2.0, Actionscript 3.0, Did you know?, Experiments, Flash 8, Flash CS3 |

6 Responses

  1. Dru Nelson Says:

    Hi, can you elaborate on the queuing pattern and your MVC framework.
    I find this interesting.

  2. Jaap Kooiker Says:

    Hello Dru,

    I can’t release our framework but if you want to learn about MVC you can look into the Cairngorm framework. I think the newest version of Cairngorm is already using queud commands.

  3. Dru Nelson Says:

    Hi,

    I don’t want your code, just a description of queued commands in regards to MVC frameworks.

  4. Dru Nelson Says:

    oh yeah, why? when I googled for MVC and queued commands I didn’t
    see anything.

    thanks!

  5. Jaap Kooiker Says:

    How the queue technically works is up the the MVC framework you use.
    Mainly the idea is when a command is executed the “manager or controller” (or whatever) is handling the flow of commands. It will see to it that when no command is currently executing the next command gets executed right away, otherwise it waits until the currently executing command has an result / fault or timeout. Then automatically executes the next command in line…

    Greetz…

  6. Arthur Clemens Says:

    We use queued commands in our ActionQueue in ASAP Framework (http://asapframework.org), that we are currently porting to as3 as ASAP Library (http://asaplibrary.org).

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.