Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Event naming convention confusion
Message
 
À
20/06/2007 13:16:42
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Divers
Thread ID:
01234534
Message ID:
01235046
Vues:
9
Tim,

>I find it important to stick to a reasonable naming convention and try to do this with my code. I am using a what I thought was consistent with Microsoft regarding events such as
>
>// the event
>public event CustomerChangedDelegate CustomerChanged
>
>// Event args
>public class CustomerChangedEventArgs : EventArgs
>
>// the method that raises the event (In the publisher)
>public void OnCustomerChanged()
>
>// The method for the handler (at the subscriber)
>public void CustomerChangedHandler()
>
>Why then with every book I look at are these same names being used but differently such as
>public void OnCustomerChanged() used as the handler method at the subscriber. or
>public event CustomerChanged OnCustomerChanged when creating the event

I've seen some code samples like this and you're right...it's simply bad naming conventions. The conventions you are using are similar to what Microsoft is using, except for the naming of the delegate. Sadly, Microsoft often names the delegate with a "Handler" suffix, obfuscating the fact that it is a handler (just double click on any Windows Forms user interface control and examine the registration code behind the scenes and you'll see what I mean). I personally advocate the naming convention you are using because it's clear that a delegate is a delegate.

Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform