Neil Walker
Neil Walker

Reputation: 6848

Naming conventions for event handler methods

Following Microsoft naming standards classes, methods, enums use Pascal naming standard and variables use camel case.

How do gui events and such fit in with all this.

For example a menu item ends up with the name 'someMenuItem', same for buttons, etc. Then when you go to create the event handler you end up with a camelcase method name, e.g. someMenuItem_Click()

Upvotes: 1

Views: 1291

Answers (1)

user1228
user1228

Reputation:

In all things, you should consult the Framework Design Guidelines. You can find that online for free (on msdn) or buy a hard copy. I bought the hard copy so that I could hit people over the head with it when they name their sheet incorrectly. Less chance of breakage when you try to hit them with the electronic version.

Which is why the default name for event handlers in Visual Studio is so blasphemous. Anyone going with the default is of weak moral character and should be shunned.

The easiest thing to do is let the editor give your method the default name, then go immediately and change it to a proper name, using the refactoring tools to fix the original assignment.

Upvotes: 5

Related Questions