Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.programming > #16780

Re: “Booleans Considered Harmful”

From Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups comp.programming
Subject Re: “Booleans Considered Harmful”
Date 2025-05-22 22:33 +0000
Organization A noiseless patient Spider
Message-ID <100o8od$3mk15$3@dont-email.me> (permalink)
References <100mhh5$3b9hp$3@dont-email.me> <100mpta$32gho$1@dont-email.me>

Show all headers | View raw


On Thu, 22 May 2025 11:14:17 +0200, Julio Di Egidio wrote:

> But we know better: the one best practice that would be relevant there
> is *do not use magic values*.

I think the writer was trying to make a point about cryptic actual-
argument values. But that is an issue that applies to other types besides 
booleans, and is easily solved by passing arguments by keyword. Compare 
his example

    saveUser(user, true, false);

with something more like

    saveUser
      (
        user,
        sendWelcomeEmail := true,
        verified := false
      );

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