Closed AshleyScirra closed 1 year ago
Optional booleans that default to true are generally strongly discouraged since they lead to the unfortunate situation where undefined
APIs that have boolean arguments defaulting to true (see "APIs that have boolean arguments defaulting to true" link in https://w3ctag.github.io/design-principles/#prefer-dictionaries). Although I agree that the double negatives aren't great either.
I agreed that the naming is unfortunate, but as @mkruisselbrink described above I'm not sure if there's a better option :/
"exclude" induces cognitive dissonance.
Use "hide" : "hideAcceptAllOption".
"hide" is a straightforward action verb a three year old groks. So the default value of false happily makes sense to humans; and, happily also avoids the undefined implementation pitfall.
The
excludeAcceptAllOption
uses negative naming, which results in double negatives, which are a bit of a headache in API design.For example: want to show the 'accept all' option? You need
excludeAcceptAllOption: false
, which is a double negative. This might not seem like much of an issue as that's the default and so will typically be used asexcludeAcceptAllOption: true
. However sometimes it's controlled dynamically e.g.excludeAcceptAllOption: !showAcceptAll
in which case you have to think about the inverted logic.In general I think it's always better to use positive naming only, i.e.
showAcceptAllOption
that defaults totrue
. If you don't want to show it then you specifyshowAcceptAllOption: false
.