Are there design guidelines on how to name methods that trigger an event in .NET? In different examples I've seen all of:
OnPropertyChanged()
FirePropertyChanged()
TriggerPropertyChanged()
RaisePropertyChanged()
Of course this is not hugely important, but I'd like to do it the "right" way and not confuse others with unusual naming conventions. =)
You should use OnPropertyChanged
according to MSDN, CodeProject and the book Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (2nd Edition).
EDIT:
The quote from CodeProject only refers to the naming of the event, e.g. if your event signalizes that a alarm has happened it should be named AlarmRaised
.
Please note that in this article, events are described as "raised" (not "fired" or "triggered"). This convention comes from the team of developers who authored much of the .NET Framework (Cwalina and Abrams, 2006). They prefer the term, "raise," because it doesn't have the negative connotations of the expressions, "fire" or "trigger."
OnPropertyChanged()
sounds like the associated event handler.
I'd go with RaisePropertyChanged()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With