views:

66

answers:

3

Here's the situation. I'm reviewing some SDK code that I didn't write because I've been tasked with drafting the developer's documentation. In one class, in the constructor, event handling is set up like this:

_engine.ReceiverEvents_OnPosition += OnPosition;
_engine.ConnectionEvents_OnDeviceStatus += OnDeviceStatus;
_engine.ConnectionEvents_OnErrorStatus += OnErrorStatus;
_engine.ReceiverEvents_OnConstellation += OnConstellation;

The ordering is Event-Raised first; Method-To-Call second.

In another class, in a method (not the constructor), the event handling is set up like this:

_captureManager.PositionLogged += CaptureManager_PositionLogged;
_captureManager.GeometryCaptureStarted += CaptureManager_GeometryCaptureStarted;

The ordering is Method-To-Call first, Event-Raised second.

My question is this - Is the ordering of the Event-Raised and Method-To-Call when setting up event handling arbitrary (order doesn't matter) or is it significant (different ordering gives you different results)?

Thanks in advance.

+6  A: 

I don't think the ordering can change. I suspect your event names and method names are just confusing.

You have to specify like this I believe:

<object>.<event name> += <event handler>;
John Weldon
I didn't think the ordering could change but wasn't sure. Turns out different programmers had different naming schemes (so much for coding standards).Thanks for confirming this for me.
billmaya
+2  A: 

Those are exactly the same declaration. The naming is inconsistent, which is probably confusing you, but in every case the object to the left of the += is the event, and the object to the right is the handler.

JSBangs
A: 

In any standard implementation there should be no difference. But if you are paranoid, check the code. It could have custom add/remove implementations that do crazy stuff. But that would be... crazy.

Marc Gravell
I think the question was more about the naming conventions, though I'm somewhat confused as well.
zneak