Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update names per naming guidelines. #1012

Merged
merged 7 commits into from Sep 8, 2016
Merged

update names per naming guidelines. #1012

merged 7 commits into from Sep 8, 2016

Conversation

BillWagner
Copy link
Member

Fixes #1011

The section on "events" incorrectly recommended naming events with the "On" prefix. Events should be the verb or verb phrase, and the handlers should have the "On" prefix.

@BillWagner
Copy link
Member Author

Hmmm. OPS build didn't happen. closing and reopening.

@qinezh
Copy link
Contributor

qinezh commented Sep 7, 2016

Open Publishing Build Service: The pull request content has been published and here are some sample preview links:

@qinezh
Copy link
Contributor

qinezh commented Sep 7, 2016

Open Publishing Build Service: The pull request content has been published and here are some sample preview links:

@@ -126,15 +126,15 @@ that the event objects can only be accessed in safe ways. The only
operations available on a field-like event are add handler:

```cs
EventHandler<FileFoundArgs> handler = (sender, eventArgs) =>
EventHandler<FileFoundArgs> OnFoundFile = (sender, eventArgs) =>
Copy link
Contributor

@svick svick Sep 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a local variable, so it should use camelCase, not PascalCase.

@svick provides the usual very thorough review.
@qinezh
Copy link
Contributor

qinezh commented Sep 7, 2016

Open Publishing Build Service: The pull request content has been published and here are some sample preview links:

@qinezh
Copy link
Contributor

qinezh commented Sep 7, 2016

Open Publishing Build Service: The pull request content has been published and here are some sample preview links:

```

The type of the event (`EventHandler<FileListArgs>` in this example) must be a
delegate type. There are a number of conventions that you should follow
when declaring an event. Typically, the event delegate type has a void return.
Prefix event declarations with 'On'.
The remainder of the name is a verb. Use past tense (as in this example) when
Event declarations should be a verb, or verb phrase.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: or a verb phrase

the event reports something that has happened. Use a present tense verb (for
example, `OnClosing`) to report something that is about to happen. Often, using
example, `Closing`) to report something that is about to happen. Often, using
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing would be present participle no? And we also have some that are simple present that don't have cancellation such as Authenticate. Any recommendation on when to use one vs. the other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the present participle: I'd prefer not going into that much grammatical detail for developers. Would you agree?
On the guidance: I'll do a bit of research and add a paragraph.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@qinezh
Copy link
Contributor

qinezh commented Sep 7, 2016

Open Publishing Build Service: The pull request content has been published and here are some sample preview links:

@BillWagner
Copy link
Member Author

There's one remaining open feedback item. I'll propose this:

Proposal:

Change event names that are verb phrases from VerbNoun (ChangedDirectory) to NounVerb (DirectoryChanged).

Remain silent on whether this is a standard or not.

Can I get upvotes @mairaw and @terrajobst ? Once that happens, I'll make that change and merge.

@terrajobst
Copy link
Member

Change event names that are verb phrases from VerbNoun (ChangedDirectory) to NounVerb (DirectoryChanged).

👍 That's what the framework does.

@mairaw
Copy link
Contributor

mairaw commented Sep 8, 2016

LGTM!

@qinezh
Copy link
Contributor

qinezh commented Sep 8, 2016

Open Publishing Build Service: The pull request content has been published and here are some sample preview links:

@BillWagner BillWagner merged commit 59cb2f6 into dotnet:master Sep 8, 2016
@BillWagner BillWagner deleted the update-events-article branch September 8, 2016 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update events article with correct naming conventions
6 participants