3 ms·
> it makes every possible event explicit and stand-out I agree that's nice to have - essentially announcing events as special in the type system. > good for i
by MaxBarraclough 7y ago
> it makes every possible event explicit and stand-out
I agree that's nice to have - essentially announcing events as special in the type system.
> good for inline optimization
Any optimisation here should be possible with an ordinary implementation of the observer pattern, no?
> it also provides a standard, much more intuitive syntax using formal function delegate declaration
I'm not convinced that it does. Without events, we can still write:
var h = () => { doStuff(); doOtherStuff(); };
subject.registerObserver(h);
> Before having lambdas in Java, we need to add an EventListener as a variable and adding an extra interface
I suspect we're both right, then: events were introduced for a good reason, but now that C# has lambdas and such, they don't seem to add much.
- jayd16 7y agoI'd much rather use events than that snippet.