On Sun, 05 Oct 2008 18:34:45 -0700, puzzlecracker <ir*********@gmail.com>
wrote:
public delegate MessageHandler(Request request)
public sealed class Connection{
public event MessageHandler handler;
private void ExecuteMassageHandler(Request request)
{
if(handler!=null)
handler(request);
}
}
What's a good name, perhaps conventional, used in the place of
ExecuteMassageHandler?
Well, given the rest of the code, I might prefer "ExecuteMessageHandler"
instead. :)
More generally, if you're looking for a convention, the .NET event model
is the only wide-spread convention I'm aware of. In that, you start with
the event name, such as "Message". The delegate type would be
"MessageEventHandler", and the signature would be "void
MessageEventHandler(object sender, MessageEventArgs e)" where
MessageEventArgs inherits EventArgs or, if no special arguments need to be
passed, "void MessageEventHandler(object sender, EventArgs e)".
The event handler could be named anything you want, of course. The .NET
convention for Forms would be to name the handler
"controlFieldName_EventName" where "controlFieldName" is the name of the
field that references the control and "EventName" is the name of the
event. For example, "button1_Click".
For situations where a given handler is used with a specific object
referenced by a specific member field, that seems like a fine convention
to me. Otherwise, I think as long as you have the event name somewhere in
the method name and it's clear how that method relates to the object(s)
for which it handles their events, that's sufficient. But if you want to
include the word "Handler" in the method name, that seems fine to me too.
Pete