strangeioc/strangeioc — pull request #102 by bejeweledpair (2014-05-05 16:46:59+00:00)
Title: Prevent AddListener from adding the same delegate

In a nutshell, we noticed that BaseSignal does something akin to what we're doing with this commit by preventing AddListener from adding the same delegate multiple times. Here we've added the corresponding tests and code that provide that.

On that note, we did have some suggestion for naming AddOnce. What if it were named to something like CallDelegateOnce, or something similar? AddOnce only reveals its intent after reading the source, and is easy to mistake for something that "Only adds a delegate listener once".

We also had a question about Signal inheriting from BaseSignal. Signal re-implements every aspect of BaseSignal, only in the Dispatch method is there any re-use of code. Related to this is that this inheritance violates the Liskov substitution principle. One cannot use a Signal and a BaseSignal interchangeably. Even if this is on purpose, maybe there's some way to reduce the quadruple duplication? If we come up with something, we'll be sure to let you know.