views:

58

answers:

1

Straight to the point!

  1. How do signals/slots and event/event-listeners compare?
  2. Are there any pros and cons?
  3. Which one should I consider and why?

Thanks in advance!

+2  A: 

My general approach is to use Events/Listeners inside a single app, they are really efficient and fast, and IDEs have lots of tooling that makes them relatively easy to implement. My rule of thumb would be to use this pattern if you really need to be sure the listener gets notified of the event every time.

I use a signals/slots pattern in SOA applications or systems integration, since it is a more lag-friendly and stateless approach.

Guy Starbuck
Then are you implying that event/listeners perform better than signals/slots, and also could you tell me what IDEs have this support for events/listeners? Thanks for the fast response.
meteorfox
I guess it depends on the implementation, but the eventing models in .NET or Java are geared for in-process operation, which would make them about as fast as possible (depending on the library). Even COM events are fast, if not as reliable. Signals/slots as a pattern doesn't presume when/if any listeners will get the signal, so performance is not as big a concern. Obviously everything depends on the implementation, I am sure you could create a signals/slots implementation that is faster than .NET eventing.
Guy Starbuck
With respect to IDEs that have support, I'm referring to Visual Studio, which auto-wires up events from the UI designer, as well as auto-generating handlers and delegates in the code view. I believe Eclipse has similar helpers.
Guy Starbuck