XAML-based applications - Event Naming Conventions for C# -


For event handling, I'm starting to see several coders:

  Click on XButton + = OnXButtonClicked () ... Zero OnXButtonClicked () {...}  

Where did this On_ conference come from? It does not seem right in terms of methods.

I am starting to see this too and I wonder what other people thought:

  XButton.Click + = HandleXButtonClick () ... void HandleXButtonClick ( ) {...}  

While using Intellisense, Visual Studio handles them in this way:

  XButton.Click + = XButton_Click; ... Zero XButton_Click (Object Sender, RoutedEventArgs E) {...}  

I am seeking some advice on these naming conventions and I would appreciate some advice.

Because this is usually always a personal way, this name actually depends on you and your team is. Event handlers are used only within your private API, and there is an implementation description, which is not partially in the context of naming, there is no official guidance.

It's being said, I can choose something just that you and your team understand, and stick to it for stability.

Personally, I do not like the name "xxxxx", because it's something misleading. For the implementation of the event, the suggestion is to use OnXXX as a safe method which increases the event XXX . Using this name as an event handler seems unfair.

A handlaxax name is understandable, this is an event subscription, and this way the event is "handling". It is being used in the Object_XXX syntax that the designer uses the visual studio by default, so this is also a good choice. As it is said, it will often make tools like private variables and conflict with law naming plans (because they are usually less cases) and styleCop complaints complaint.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -