Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Optimizing PWAs For Different Display Modes

      August 26, 2025

      Node.js Web App Development Costs: A 2025 Executive Pricing Guide

      August 26, 2025

      Google locking down Android security with upcoming developer verification requirements for sideloaded apps

      August 26, 2025

      Microsoft donates DocumentDB to the Linux Foundation

      August 25, 2025

      Google can translate your voice in real time now – try it free

      August 27, 2025

      The one-click Linux app I use for instant online anonymity

      August 27, 2025

      You can try Android 16’s new lock screen widgets – if you have one of these phones

      August 27, 2025

      Apple’s iPhone 17 event launch date is official – here’s everything we expect

      August 27, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Password Strength Estimator Validation in Laravel

      August 27, 2025
      Recent

      Password Strength Estimator Validation in Laravel

      August 27, 2025

      Laravel’s Enhanced String Validation with Inverse Methods

      August 27, 2025

      Using SQLite in production with Laravel

      August 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft Excel just got a Copilot function — but the new AI has some surprising limitations

      August 27, 2025
      Recent

      Microsoft Excel just got a Copilot function — but the new AI has some surprising limitations

      August 27, 2025

      Why Final Fantasy XIV fans are review‑bombing the game on Steam

      August 27, 2025

      Google Chrome VPN under fire for secretly screenshotting users’ browsing habits

      August 27, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»Representative Line: Not What They Meant By Watching “AndOr”

    Representative Line: Not What They Meant By Watching “AndOr”

    August 26, 2025

    Today’s awfulness comes from Tim H, and while it’s technically more than one line, it’s so representative of the code, and so short that I’m going to call this a representative line. Before we get to the code, we need to talk a little history.

    Tim’s project is roughly three decades old. It’s a C++ tool used for a variety of research projects, and this means that 90% of the people who have worked on it are PhD candidates in computer science programs. We all know the rule of CompSci PhDs and programming: they’re terrible at it. It’s like the old joke about the farmer who, when unable to find an engineer to build him a cow conveyer, asked a physicist. After months of work, the physicist introduced the result: “First, we assume a perfectly spherical cow in a vacuum…”

    Now, this particularly function has been anonymized, but it’s easy to understand what the intent was:

    bool isFooOrBar() {
      return isFoo() && isBar();
    }
    

    The obvious problem here is the mismatch between the function name and the actual function behavior- it promises an or operation, but does an and, which the astute reader may note are different things.

    I think this offers another problem, though. Even if the function name were correct, given the brevity of the body, I’d argue that it actually makes the code less clear. Maybe it’s just me, but isFoo() && isBar() is more clear in its intent than isFooAndBar(). There’s a cognitive overhead to adding more symbols that would make me reluctant to add such a function.

    There may be an argument about code-reuse, but it’s worth noting- this function is only ever called in one place.

    This particular function is not itself, all that new. Tim writes:

    This was committed as new code in 2010 (i.e., not a refactor). I’m not sure if the author changed their mind in the middle of writing the function or just forgot which buttons on the keyboard to press.

    More likely, Tim, is that they initially wrote it as an “or” operation and then discovered that they were wrong and it needed to be an “and”. Despite the fact that the function was only called in one place, they opted to change the body without changing the name, because they didn’t want to “track down all the places it’s used”. Besides, isn’t the point of a function to encapsulate the behavior?

    [Advertisement]
    Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleLog Outgoing HTTP Requests with the Laravel Spy Package
    Next Article Staticcheck – advanced Go linter

    Related Posts

    News & Updates

    Google can translate your voice in real time now – try it free

    August 27, 2025
    News & Updates

    The one-click Linux app I use for instant online anonymity

    August 27, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Firefly AIBOX 3588S – Set up Flatpak to use external disk

    Linux

    Cybersecurity in the AI Era: Evolve Faster Than the Threats or Get Left Behind

    Development

    CVE-2025-40666 – TCMAN GIM Blind SQL Injection Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Cisco scores a perfect 10 – sadly for a critical flaw in its comms platform

    Security

    Highlights

    CVE-2024-12223 – Palo Alto Networks Prism Central Stored Cross-Site Scripting Vulnerability

    August 19, 2025

    CVE ID : CVE-2024-12223

    Published : Aug. 20, 2025, 1:15 a.m. | 28 minutes ago

    Description : Prism Central versions prior to 2024.3.1 are vulnerable to a stored cross-site scripting attack via the Events component, allowing an attacker to hijack a victim user’s session and perform actions in their security context.

    Severity: 9.3 | CRITICAL

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    AI search is gutting publisher revenue — This startup’s $5 plan aims to fix that

    August 27, 2025

    South Korea Accuses DeepSeek of Unlawful Data Transfers Amid AI Expansion

    April 24, 2025

    6 Best Free and Open Source Graphical Data Hashing Tools

    June 22, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.