Thursday, July 7, 2011

Enums: The Dark Side

In a previous post I advocated using enums as much as possible.  There are however times when this is not a good idea.

If a lookup table requires the ability to easily add new lookup values without redeploying the code base, you should avoid using enums in data accessors, view models, etc. 

The situation we had involved document types. After adding a new document type, the code had to be updated.  This shouldn't be necessary in this case and should have just worked.

So as with most things, use common sense.  I suggest keeping a list of lookups that should not be dealt with using enums for your project.

No comments:

Post a Comment