Delegates and Events or Command Patter

  • Thread starter Thread starter Reg
  • Start date Start date
R

Reg

Hello, I have a situation where a text based protocol comes to my component
to be handled.

Protocol has differnt commands and they have different arguments.

The question is that which is in C# world's way to handle different command
a J2EE style Cpmmand Pattern Design Pattern or C#'s Events and Delegates?

Any opinions of that? If Events and Delegates are proper how should I deal
with differents of commands into Delegates and Events? Also return values
may vary depending on command.

thanks.
 
I would consider delegates and events the DotNet "built in" implementation
of the Observer Pattern, not the Command Pattern.

check out dofactory.com and their "free design patterns" section as well,
for C# specific code.
 
I agree that using the delegates & events is the way forward - you want to
listen to the incoming feed, capture the required data and then fire an event
to who ever is observing (listening).

I would also say that by using delegates & events that you will be using the
command Pattern if you specify custom derived EventArgs classes as part of
the event signature, i.e you can have different event arguments for different
data read from the incoming feed.

HTH

Ollie Riches
 
Back
Top