Commands or messages


Just a quick question:

I can’t find any easy way of passing some parameters with my commands, for instance; open this url. The command sent from a button would be something like “openUrl” but now I have to do some ugly code to save the url in a static class known by both the sender and the receiver, and I don’t know if this is correct either? (is there any race conditions possible?)

There is a message framework, should I use that instead of commands in cases like this?


App commands aren’t really supposed to carry data, they’re just for button pushes, keypresses, etc, rather than passing data around your app. Maybe you could use an ActionListener or a Message object to send your info?


Thanks for answering.

OK, I will implement my own little command framework with support for data (and with history).

Maybe something like:

CommandFramework::execute(new OpenUrlCommand(url));

I will check out the message classes and see if I can use it as a base for the commands, at least for the async parts.


I have many classes where I broadcast messages, I have created a message structure which takes a void*, a string and integer value. The integer value is the message identifier.

And I use ChangeListener and ChangeBroadcaster to receive and deliver change messages.