Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Don't Use Booleans (luu.io)
5 points by fanf2 on Dec 18, 2019 | hide | past | favorite | 1 comment


That clearly depends on the expressivity of your programming language.

Python is an example where named arguments preserve context, readability and simplicity (especially for people not aware with language features, bitmasks, etc):

   fetch(
     accountId,
     includeDisabled=true,
     fetch_history=true,
     fetch_details=true
   );
Similar languages (Perl for instance) recommend passing dictionaries (hash maps), which roughly reads the same way. Typically, these ways are easily extendable without breaking the API.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: