Good guidelines for defining bool properties

Usually, if there is a property that gets / sets a value for the state, I use "Is", for example:

Visibility: .IsVisible 

But for properties that get / set actions, what is the best way to use it? How:

 Casting shadows: .CastShadows 

Should I use:

 .DoesCastShadows 

Is there a better alternative?

+6
properties naming-conventions
source share
3 answers

Most of the library uses something that would be similar to .IsShadowCastingEnabled .

For example, UIElement defines IsInputMethodEnabled and IsHitTestVisible .

The best part is that IsXXX makes it clear that this is a logical property.

+11
source share

I think CastsShadows will work. Pay attention to s after Cast . It is parallel to Is in that both beginnings with singular verbs (and Does sound pretty sticky). A.

+5
source share

Prefer using "Is" for read-only properties; I would probably use the "EnableShadows" property as a property. It may not be immediately obvious that this property is not a method, but when reading the code it should be obvious, and when writing code Intellisense should indicate that this property. Also, if you are trying to use EnableShadows as a method, the compiler must complain.

+1
source share

All Articles