Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Name Your Booleans Like Questions

Here's a tiny habit that quietly makes code easier to read: name every boolean so it reads like a yes/no question. Compare these: if ( user . active && ! loading && permission ) { ... } if ( user . isActive && ! isLoading && hasPermission ) { ... } Same logic. The second one reads almost like a sentence: "if the user is active, and we're not loading, and they have permission." The first makes you…

Naming boolean variables in a way that reads like a yes/no question can greatly enhance code readability. For example, if (user.active && !loading && permission) {...} can be rewritten as if (user.isActive && !isLoading && hasPermission) {...}.

The second version reads almost like a sentence: "if the user is active, and we're not loading, and they have permission." This makes it clear what the condition is checking, while the first version leaves ambiguity about what "permission" refers to - a flag, a string, or an object.

To maintain consistency, a few naming prefixes can be used for most cases:

- "is" for state: isOpen, isValid, isEmpty

- "has" for possession: hasChildren, hasError

- "can" for ability: canEdit, canRetry

- "should" for decisions: shouldRefetch, shouldShowBanner

Avoid negative names such as isNotDisabled, as they force the reader to perform double-negation math and make the code harder to understand. Similarly, avoid names that misleadingly suggest a specific type, such as user.admin, which could refer to a boolean, a role object, or an ID. Instead, use a more specific name like user.isAdmin to ensure clarity.

This simple naming convention benefits not only the original author but also anyone reading the code in the future. It eliminates confusion and simplifies the process of understanding the code, making it easier to maintain and collaborate on. By making code read like questions, developers can minimize moments of uncertainty and streamline the reading experience, ultimately saving time and effort for everyone involved.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

The Small-File Lakehouse Explosion: Why Streaming Destroys Iceberg

Originally published by the **Logic42 Sovereign Engineering Practice * at https://logic42.ai/articles/small-file-lakehouse-explosion-iceberg-compaction .* The Small-File Lakehouse Explosion: Why…

  • High-frequency streaming pipelines create thousands of tiny Parquet files.
  • Table metadata trees grow to gigabytes in 30-second commit cycles.
  • Query engines like Trino and DuckDB overwhelmed by metadata growth.

Two new x402 APIs: DNS AXFR vulnerability probe + Set-Cookie cache-disclosure (c148)

Two new x402 APIs for AI agents (cycle 148) Shipped today to https://mins-alternatively-meanwhile-lauderdale.trycloudflare.com — now serving 211 paid x402 routes ($0.0005 each on Base mainnet USDC).

  • /api/dns-zone-transfer-probe API checks for DNS AXFR vulnerability
  • /api/cookie-cache-disclosure API scans for Set-Cookie cache-disclosure
  • Both APIs are paid services requiring USDC deposit

Stitch Desk is a local-first order assistant for boutiques and tailors.

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle What I Built Stitch Desk is a local-first order assistant for boutiques and tailors.

  • Stitch Desk is an order assistant for small boutiques and tailors
  • Turns paper notes and WhatsApp chats into editable order cards
  • Integrates customer details, measurements, and outfit design images

More from Wednesday, 14 October 2026 →