someone wants me to make other people’s code compliant to some FxCop ruleset which includes rule CA1726:Use preferred terms. Most of the terms/replacements are all right and I can understand that one has to decide on one single way to name things.
However, what’s the deal with the term ‘flags’? Can anyone explain to me why I shall not use this name? (before I go and complain about it at my boss 😉 )
Say, I have a data object which has a member of class ‘flags’ which bundles a large number of properties that define how to handle the data object. How else would you call this?
In the book Framework Design Guidelines, which is what FxCop is based on, the authors say that using
FlagorFlagsis a bad idea. Their alternative suggestion is that when naming enumerations that you use a singular name for standard enums and a plural name for bit field (flags) enums.For example if you wanted to create an enum listing different visibilities then you would name it
Visibilitiesinstead ofVisibilityFlagsorVisibility:The only items considered flags in .NET by the authors are these bitfield enumerations due to the keyword
Flagsattribute.