February 21, 2018

One of the most annoying programming mistakes I face on a regular basis is when people use boolean, where they should use enum instead. The rule is simple: if two possible values is just coincidence, it must be enum.

Might be not the best example, but GET /thumbnail?size=large instead of GET /thumbnail?isLarge=true Or public gender: Gender instead of public isMale: boolean

2 comments:

Unknown said...

Author of PhantomJS is on the same page with you
https://ariya.io/2011/08/hall-of-api-shame-boolean-trap

Ufo 3D said...

https://ufo3d.com