One of the patterns I follow a lot is creating enumerations in my code for certain reference data. I usually have tables in my SQL database to back up this data, essentially just to give myself the benefit of referential integrity. But it’s a pain to refer to data based on an arbitrary ID in the database, so enumerations are a way to ensure my code isn’t littered with “magic numbers.”
Enumerations by themselves are powerful, but pretty plain. Since 95% of my development work is in ASP.NET MVC these days, I wanted an easy way to render the options an enumeration provides as a drop-down or radio button list. I could do this manually, and it’s not a lot of code, but I felt like there needed to be an easier, more generic way to handle things.