Discussion

Ask HN: Do You Use Enum for Yes, No, Unset?

I've seen different arguments on this topic and thought I'd ask HN if you all have a standard for this.

Say you have a form that's filled out and saved to a DB. One required field is a dropdown with Yes and No. But the field begins as blank to show that a value hasn't been selected yet, ensuring that the User pays attention to the field.

Do you use a Nullable Bit (DB) and Nullable Bool (Code)? OR an Enum: Yes, No, Unset?

You wouldn't use a boolean to represent states like say New, Processing, Done. But do you consider NULL a separate "state"?

Thanks

21 points whitakerch 4 years ago 41 comments

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton