Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In an application framework when performance impact can be ignored (10-20 events per second at max),
what is more maintainable and flexible to use as a preferred medium for communication between modules - Events or Futures/Promises/Monads?

It's often being said, that Events (pub/sub, mediator) allow loose-coupling and thus - more maintainable app... My experience deny this: once you have more that 20+ events - debugging becomes hard, and so is refactoring - because it is very hard to see: who, when and why uses what.

Promises (I'm coding in Javascript) are much uglier and dumber, than Events. But: you can clearly see connections between function calls, so application logic becomes more straight-forward. What I'm afraid. though, is that Promises will bring more hard-coupling with them...

p.s: the answer does not have to be based on JS, experience from other functional languages is much welcome.

share|improve this question
It's often being said, that Events (pub/sub, mediator) allow loose-coupling who the hell says that? stop listening to them! You can't subscribe to an event without knowing the parent --> tight coupling. Look into weak events (=Mediator?). –  Baboon Sep 25 '12 at 8:58
@Baboon I generally agree that events do not automatically produce loose-coupling, but if you introduce an event bus you can subscribe to events without knowing the "parent". Who says it? Ray Ryan on Google IO 2009, see google.com/events/io/2009/sessions/… at 13:50. –  scarfridge Sep 25 '12 at 10:12
@scarfridge yes, if you implement some kind of eventaggregator, it's lose coupling, as I said in my comment. –  Baboon Sep 25 '12 at 11:07
.net rx Is an event aggregator, I'm on mobile , will post more details later –  AndreasScheinert Sep 25 '12 at 14:00
add comment

1 Answer

up vote 1 down vote accepted

Monads and events play quite nicely together, for example have a look at .NET Rx. I think there should be even an JavaScript implementation. http://msdn.microsoft.com/en-us/data/gg577609.aspx

share|improve this answer
sorry for delayed accept. "some dumb thing from microsoft" is indeed awesome. And now, after Reactive Extensions have been open-sourced, they are even more viable. Thanx for the answer (though you might want to expand it a little bit ;) ). –  c69 Nov 26 '12 at 21:12
It depends what you are looking for: some introduction or specific examples. In any case I can recommend you to explore channel9 videos and talks by Erik Meijer and Brian Beckmann on the topic. –  AndreasScheinert Nov 28 '12 at 10:33
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.