Event Names

Topics: General
Apr 15, 2011 at 11:52 AM

Microsoft used to name events like actions, and corresponding virtual helper functions prefixed with 'On'

by ex:

public event MouseEventHandler MouseClick;

protected virtual void OnMouseClick(MouseEventArgs e)
{
    if (this.MouseClick != null)
    {
        this.MouseClick(this, e);
    }
}

as we can see, there is no OnSomethingHappened events...

The overriding of OnSomethingHappened functions is used to manage the SomethingHappened event in the inherited classes...

This "norm" is not always respected in the current code, creating some confusions...