473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

good name to dispatch events (naming convention)


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?

Thanks
Oct 6 '08 #1
5 1472
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
Oct 6 '08 #2
PuzzleCracker... Consider the convention:

public delegate void MessageEventHandler(object sender, MessageEventArgs
e);
public event MessageEventHandler Message;

protected virtual void OnMessage(MessageEventArgs e)
{
if (Message != null)
{
Message(this, e);
}
}
}

Regards,
Jeff
>>What's a good name, perhaps conventional, used in the place of
ExecuteMassageHandler?<<
*** Sent via Developersdex http://www.developersdex.com ***
Oct 6 '08 #3
"puzzlecracker" <ir*********@gmail.comwrote in message
news:ce**********************************@k30g2000 hse.googlegroups.com...
>
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?
OnMessage()?

--
Dag.

Oct 6 '08 #4
On 06/10/2008 in message
<ce**********************************@k30g2000hse. googlegroups.com>
puzzlecracker wrote:
>What's a good name, perhaps conventional, used in the place of
ExecuteMassageHandler?
I used to use FireMessageHandler, but have recently changed to
RaiseMessageHandler as it seems to be more widespread.

--
Jeff Gaines Damerham Hampshire UK
There is absolutely no substitute for a genuine lack of preparation
Oct 6 '08 #5
On Oct 6, 5:34*am, puzzlecracker <ironsel2...@gmail.comwrote:
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?
If you were using the standard signature - "(object
sender, ...EventArgs e)" - for your event (and you really should!),
then you could use the rest of the pattern, in which case the method
is the same name as event with the prefix "On".
Oct 6 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David Thompson | last post by:
Looking for a book to help me develop a philosophy for building databases (particularly on MySQL). And then taking them from concept to construction. Something like.... Start by asking which...
9
by: Sandeep Sharma | last post by:
For many years I have been following the convention of naming all class attributes with a leading underscore. This enables me to quickly identify the class attributes when I encounter them in the...
27
by: Derek | last post by:
The company where I work uses a naming convention that I have never used before. They use mixed-case letters for public member functions, but lower-case with underscores for the rest, like this:...
6
by: yyy | last post by:
my question is rather theoretical than practical in the pure programming aspect... is "name mangling" the same as "name decorating" ? browsing the web, you might find multiple people saying...
10
by: jjkboswell | last post by:
I'm trying to pin down a good naming convention for the 3 things required to implement an event. You need: 1) a delegate 2) an event 3) an event handler Below is my understanding of a...
114
by: Jonathan Wood | last post by:
I was just wondering what naming convention most of you use for class variables. Underscore, "m_" prefix, camel case, capitalized, etc? Has one style emerged as the most popular? Thanks for...
3
by: Ronald S. Cook | last post by:
For all those anti-Hungarian notation people out there, how would you name an employee first name label and textbox on an create/modify employee form, respectively (please)? Thanks, Ron
14
by: Astley Le Jasper | last post by:
I'm still learning python and would like to know what's a good way of organizing code. I am writing some scripts to scrape a number of different website that hold similar information and then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.