Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’ve worked on systems which where the set of enum values was fixed at any particular point in time, but could change over time as business requirements changed.

For instance, we had an enum that represented a sport that we supported. Initially we supported some sports (say FOOTBALL and ICE_HOCKEY), and over time we added support for other sports, so the enum had to be expanded.

Unfortunately this always required the entire estate to be redeployed. Thankfully this didn’t happen often.

At great expense, we eventually converted this and other enums to “open-ended” enums (essentially Strings with a bit more structure around them, so that you could operate on them as if they were “real” enums). This made upgrades significantly easier.

Now, whether those things should have been enums in the first place is open for debate. But that decision had been made long before I joined the team.

Another example is gender. Initially an enum might represent MALE, FEMALE, UNKNOWN. But over time you might decide you have need for other values: PREFER_NOT_TO_SAY, OTHER, etc.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: