From time to time, you may need to name something that performs on operation conditionally. The Windows Runtime has adopted the following naming conventions:
If you are requesting that action X occur whenever transition Y occurs, then use the term “On”. For example, if you have a property that specifies whether the Widget should auto-disable itself whenever it is hidden, you could name the property Widget.
. Even if this property is set to True
, that does not preclude the possibility of enable the Widget while it is hidden. All it’s saying is that when the Widget transitions from Shown to Hidden, it will be flipped to disabled. The property doesn’t say anything about what happens after the transition occurs. In this usage, the term Y describes an action or transition.
If you are requesting that a condition X be in effect as long as condition Y is in effect, then use the term “When”. For example, if the property is named Widget.
, then setting it to True
means that the Widget is disabled whenever it is hidden. This is a continuous effect, not just a one-time effect when it transitions from Shown to Hidden. In this usage, the term Y describes a condition or state.
If you are requesting that an operation X occur right now, but only if condition Y is true, then use the term “If”. For example, a method called Widget.
checks whether the Widget is hidden, and if so, it disables the Widget. If the Widget is not hidden, then it does nothing. This check is done once, at the point of the method call. If the Widget becomes hidden later, this method call has no effect. It had one chance. An example usage as a parameter might be Widget.
. In this usage, the term Y describes a condition or state.
Here are the results in table form.
Magic word | Trigger | Example | Notes |
---|---|---|---|
On | Edge triggered | DisableOnHide | Y is an action or transition |
When | Level triggered | DisableWhenHidden | Y is a state or condition |
If | One-shot | DisableIfHidden | Y is a state or condition |
0 comments
Be the first to start the discussion.