Hacker News new | ask | show | jobs
by arthurjj 3127 days ago
tl;dr If you have an Enum don't have the 0 value be semantically meaningful.

2nd tl;dr If sex/gender is an Enum you should have at least 4 values unspecified, female, male, other.

A few years ago I was working on a front end that talked to different scheduling software systems. Our front end had a much more nuanced way of representing sex/gender while the system that talked to scheduling systems had an older enum

Bad_Gender { female = 0, male = 1, }

A bug was introduced such that no gender was set. However the field not being set meant that it's value was 0. This led to all appointments being booked as women. Even a prostate exam. Needless to say we fixed the bug quickly.