Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was reading this article: Designing Flags Enumerations @ msdn and it says

Combining flags enumeration values is an intermediate skill that should not be required for developers implementing common scenarios.

I think flags enumeration are awesome - something I learned about during my experience with C.

Why does it seem like this article is cautioning developers away from what I consider to be a useful (and not complex) skill?

share|improve this question
up vote 17 down vote accepted

As with many computing concepts, those who understand them don't find them difficult. You're among those people; congratulations!

That doesn't change the fact that bitwise arithmetic seems strange and hard to understand to many people, because it uses a language element (numbers) that they are used to handle in one way (for absolute magnitude) in a very different way (with different meanings for each bit, regardless of their 'value' in the normal number system.)

Yes, there are people to whom this is difficult, and yes, there are a lot of positions that can be filled by people who can't be bothered to learn bit arithmetic. That's what "intermediate" means here.

share|improve this answer

The article says

Consider providing special enumeration values for commonly used combinations of flags.

Of course, it is not really hard to combine different flags using the "|" operator, but providing special enumeration values has the following advantage:

  • easier to read:

    MyEnumeration.MyFlag1 | MyEnumeration.MyFlag2 | MyEnumeration.MyFlag3

    tends to get much more lengthy than


  • it makes immediately clear that the specific combination of flags is a legal combination (which may or may not be the case for every other combination)

Nevertheless, I read this sentence from the article not like "don't do this, never ever", only like "make it easier for the common case". There's nothing to say against having no special enum value for a rarely used combination.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.