Pergunta

What is the difference between the Commands and the Events in CAB? There seem to do the same thing, when is the command intent to be used and the events?

Foi útil?

Solução

From a CAB point of view commands were meant to be used specifically for UI components, while events could in theory be used by any component. So commands are a more specific implementation of the event mechanism for UI menus, actions, etc...

Below are links to an excellent article series by Rich Newman on CAB. Chapter 10 and 11 are on commmands and events in CAB.

http://richnewman.wordpress.com/intro-to-cab-toc/

http://richnewman.wordpress.com/2007/09/22/introduction-to-events-in-the-cab-introduction-to-cabscsf-part-11/

http://richnewman.wordpress.com/2007/09/16/commands-in-the-cab-introduction-to-cabscsf-part-10/

Outras dicas

Leaving CAB aside, by theory;

  • Command: represents an action, that can be reused or not through different parts of the application. means "Do this".
  • Event: represents that something happened, so every instance attached to that event might decide to do different things when the event is published. means "this happened"

So I guess that, if for a given action you want to do always the same thing, then use a command. If not use an event.

I'm currently using Prism (adapted to work with Windows forms) and so far I've not used events for communication.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top