Tag Info

Hot answers tagged

6

Not sure what you mean with reference driven programming. From what I gather, you're wondering what the advantages of event-driven programming are as opposed to writing code, and then using a bunch of branches to determine when to call a given method. Before I set off, allow me to be pedantic and point out that: a module can't listen for any event, nor can ...


3

Not 100% sure I know what you're asking. But, I get the sense you're at a point where event-driven programming doesn't feel "real" enough -- or like you're at the mercy of someone else's event system. Or like your application isn't really "doing" anything. Or like it's just a bunch of disparate methods that you're feeding another application. So. Suppose a ...


3

There's a third option: mock the object with the event and use behavior testing to verify the mock's subscriptions at given points. Several mocking frameworks allow for this. public interface INeedToBeMocked { public event EventHandler EventRaised; } NSubstitute var mockedItem = Substitute.For<INeedToBeMocked>(); ...


2

Is there a better way to solve this problem? Yes! C# allows you to override the += and -= syntax. I'm not sure how easy it is to supply in common mocking frameworks like Moq, but it should be trivial to build your own fake object that has hooks into the subscribe and unsubscribe methods of your interface: private Action foo = () => {}; ...


1

There is a subtle, but important difference between commands and events. A command has a presumption of a response whereas an event does not presume a response, it's merely a statement. To be less abstract: ShipOrder is a command and the sender of ShipOrder will likely expect a response of some sort. OrderShipped is a declaration and the sender is ...



Only top voted, non community-wiki answers of a minimum length are eligible