Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #16778

Re: “Booleans Considered Harmful”

From Julio Di Egidio <julio@diegidio.name>
Newsgroups comp.programming
Subject Re: “Booleans Considered Harmful”
Date 2025-05-22 14:57 +0200
Organization A noiseless patient Spider
Message-ID <100n6vt$32ghp$3@dont-email.me> (permalink)
References <100mhh5$3b9hp$3@dont-email.me> <100n34e$3eqip$1@dont-email.me> <100n64t$32ghp$2@dont-email.me>

Show all headers | View raw


On 22/05/2025 14:43, Julio Di Egidio wrote:
> On 22/05/2025 13:51, David Brown wrote:
>> On 22/05/2025 08:51, Lawrence D'Oliveiro wrote:
>>> I think most of this article is a load of nonsense, myself.
>>>
>>> <https://www.infoworld.com/article/3990923/booleans-considered-harmful.html>
>>>
>>> Thoughts?
>>
>> He makes some relevant points about clarity of code,
> 
> He makes no relevant points: the whole thing is rather misguided.
> 
> <snip>
>> So in general, I'd prefer positive names to negative ones - 
>> "UserIsAuthorised" rather than "UserIsNotAuthorised".  And I would not 
>> "hide" a "not" in the middle of a variable name as his example does. 
>> But sometimes a negative name makes more sense - "UserBanned" might be 
>> perfectly reasonable.
>>
>> All things being equal, I'd usually choose "put positive first".  But 
>> again, that's more a bias than a rule.  In particular, it might often 
>> be best with an "early exit" coming first regardless of whether it is 
>> the positive condition or the negative condition.
> 
> I could give tons of *sensible* examples where you'd have to say
> "sure, maybe, in that case".  Rather, some properties and conditions
> are *most naturally* expressed negatively.  Keep also in mind that
> readability is way more about uniformity than the specifics, hence
> some of those are/were indeed common conventions then patterns. --
> More on that line in my initial post.
> 
> That said, "think positive", as the "think negative" of some of
> your counter-examples, is only *dumb and dumbing*: perfectly in
> line with the abolishment of negation and the dumbing down of
> humanity, as negation is the fundamental logical connective...
> 
> Not that I expect *you* and the resident gang to acknowledge
> any of that, of course: you cannot even engage properly.

Advanced exercise: do you think these are equivalent?

"I do not expect you to acknowledge any of that."
"I expect you to not acknowledge any of that."

> Anyway, HTH.

-Julio

Back to comp.programming | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

“Booleans Considered Harmful” Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-05-22 06:51 +0000
  Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-22 11:14 +0200
    Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-22 12:04 +0200
    Re: “Booleans Considered Harmful” Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-05-22 22:33 +0000
      Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-23 07:04 +0200
  Re: “Booleans Considered Harmful” David Brown <david.brown@hesbynett.no> - 2025-05-22 13:51 +0200
    Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-22 14:43 +0200
      Re: “Booleans Considered Harmful” Julio Di Egidio <julio@diegidio.name> - 2025-05-22 14:57 +0200
  Re: “Booleans Considered Harmful” Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-05-22 12:27 -0700
  Re: “Booleans Considered Harmful” JJ <jj4public@outlook.com> - 2025-05-23 16:56 +0700
    Re: “Booleans Considered Harmful” Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-05-23 22:58 +0000
  Re: “Booleans Considered Harmful” Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-05-23 22:48 +0000
  Re: “Booleans Considered Harmful” c186282 <c186282@nnada.net> - 2025-06-18 02:40 -0400

csiph-web