New ask Hacker News story: Ask HN: Do You Use Enum for Yes, No, Unset?
Ask HN: Do You Use Enum for Yes, No, Unset?
2 by whitakerch | 0 comments on Hacker News.
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
2 by whitakerch | 0 comments on Hacker News.
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
Comments
Post a Comment