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

      Coded Smorgasbord: High Strung

      September 26, 2025

      Chainguard launches trusted collection of verified JavaScript libraries

      September 26, 2025

      CData launches Connect AI to provide agents access to enterprise data sources

      September 26, 2025

      PostgreSQL 18 adds asynchronous I/O to improve performance

      September 26, 2025

      Distribution Release: Neptune 9.0

      September 25, 2025

      Distribution Release: Kali Linux 2025.3

      September 23, 2025

      Distribution Release: SysLinuxOS 13

      September 23, 2025

      Development Release: MX Linux 25 Beta 1

      September 22, 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

      PHP 8.5.0 RC 1 available for testing

      September 26, 2025
      Recent

      PHP 8.5.0 RC 1 available for testing

      September 26, 2025

      Terraform Code Generator Using Ollama and CodeGemma

      September 26, 2025

      Beyond Denial: How AI Concierge Services Can Transform Healthcare from Reactive to Proactive

      September 25, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Distribution Release: Neptune 9.0

      September 25, 2025
      Recent

      Distribution Release: Neptune 9.0

      September 25, 2025

      FOSS Weekly #25.39: Kill Switch Phones, LMDE 7, Zorin OS 18 Beta, Polybar, Apt History and More Linux Stuff

      September 25, 2025

      Distribution Release: Kali Linux 2025.3

      September 23, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Would a Function by Any Other Name Still be WTF?

    CodeSOD: Would a Function by Any Other Name Still be WTF?

    May 12, 2025

    “Don’t use exception handling for normal flow control,” is generally good advice. But Andy‘s lead had a PhD in computer science, and with that kind of education, wasn’t about to let good advice or best practices tell them what to do. That’s why, when they needed to validate inputs, they wrote code C# like this:

    
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-built_in">bool</span> <span class="hljs-title">IsDecimal</span>(<span class="hljs-params"><span class="hljs-built_in">string</span> theValue</span>)</span>
        {
            <span class="hljs-keyword">try</span>
            {
                Convert.ToDouble(theValue);
                <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
            }
            <span class="hljs-keyword">catch</span>
            {
                <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
            }
        } 
    

    They attempt to convert, and if they succeed, great, return true. If they fail, an exception gets caught, and they return false. What could be simpler?

    Well, using the built in TryParse function would be simpler. Despite its name, actually avoids throwing an exception, even internally, because exceptions are expensive in .NET. And it is already implemented, so you don’t have to do this.

    Also, Decimal is a type in C#- a 16-byte floating point value. Now, I know they didn’t actually mean Decimal, just “a value with 0 or more digits behind the decimal point”, but pedantry is the root of clarity, and the naming convention makes this bad code unclear about its intent and purpose. Per the docs there are Single and Double values which can’t be represented as Decimal and trigger an OverflowException. And conversely, Decimal loses precision if converted to Double. This means a value that would be represented as Decimal might not pass this function, and a value that can’t be represented as Decimal might, and none of this actually matters but the name of the function is bad.

    [Advertisement]
    ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleCVE-2025-4553 – PHPGurukul Apartment Visitors Management System SQL Injection
    Next Article Vine Linux is a Linux distribution with an integrated Japanese environment

    Related Posts

    News & Updates

    Distribution Release: Neptune 9.0

    September 25, 2025
    News & Updates

    Distribution Release: Kali Linux 2025.3

    September 23, 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

    LockBit Attempts Comeback with LockBit 5.0 Ransomware Release

    Development

    Superhuman’s Secret Onboarding UX

    Web Development

    CVE-2025-50164 – Microsoft Windows RRAS Heap-based Buffer Overflow Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    OpenAI Introduces o3 and o4-mini: Progressing Towards Agentic AI with Enhanced Multimodal Reasoning

    Machine Learning

    Highlights

    CVE-2025-38160 – Raspberry Pi Linux Kernel NULL Pointer Dereference Vulnerability

    July 3, 2025

    CVE ID : CVE-2025-38160

    Published : July 3, 2025, 9:15 a.m. | 2 hours, 14 minutes ago

    Description : In the Linux kernel, the following vulnerability has been resolved:

    clk: bcm: rpi: Add NULL check in raspberrypi_clk_register()

    devm_kasprintf() returns NULL when memory allocation fails. Currently,
    raspberrypi_clk_register() does not check for this case, which results
    in a NULL pointer dereference.

    Add NULL check after devm_kasprintf() to prevent this issue.

    Severity: 0.0 | NA

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

    Radware Cloud Web App Firewall Vulnerability Let Attackers Bypass Filters

    May 8, 2025

    6 Steps to 24/7 In-House SOC Success

    June 20, 2025

    Perfection is a Myth. Leverage Isn’t: How Small Teams Can Secure Their Google Workspace

    May 5, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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