

Decoupling: Events vs. Dependency Injection - spankalee
http://zef.me/5390/decoupling-events-vs-dependency-injection

======
powatom
Both have their merits, but personally I prefer the event based system.

There are solutions to the 'silent failure' problem:

1: You could have your event router 'do something' whenever an event is
triggered which has no registered subscribers. That way, you will get some
feedback at least. However, this feedback is still almost certainly outside of
the current scope - you could solve this by registering some global
'unsubscribed event' handler. This solution won't solve the silent-failure
problem fully, but it could reduce the number of places it's likely to occur,
and at least give some feedback (somehow) when this situation occurs.

2: You could just be more careful during development - ultimately the problem
of 'silent failure' only happens because the developer(s) have no idea what's
going on inside their system. There is absolutely no reason why the
'saveRequested' event should ever not have at least one handler - and if that
is the case, then it's still simply the developer's fault.

All that being said, I don't think DI is too terrible either. Swings and
roundabouts!

