DEV Community

Discussion on: Boolean - The Good, The Bad and there is no place for the Ugly

Collapse
 
mrlarson2007 profile image
Michael Larson

Just one thing would like to mention, this is a great example where boolean flag would not be a good idea, but what if we where guaranteed that there only be admins and non admins and nothing else? We have to make trade offs all the time and there may be cases where a boolean flag is just fine.

Collapse
 
macsikora profile image
Pragmatic Maciej

Yes true, we make trade off all the time. I think in this particular example even for two options, type like: Admin | User would be just more readable. But even though you would choose Bool for that, then most important is to know when to turn back. The moment here would be any first situation when you need to create a second Bool, this should be a red light, it indicates that our data is wrongly modeled.