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

      tRPC vs GraphQL vs REST: Choosing the right API design for modern web applications

      June 26, 2025

      Jakarta EE 11 Platform launches with modernized Test Compatibility Kit framework

      June 26, 2025

      Can Good UX Protect Older Users From Digital Scams?

      June 25, 2025

      Warp 2.0 evolves terminal experience into an Agentic Development Environment

      June 25, 2025

      Microsoft Copilot secures a spot in classrooms as a “thought partner” — with Copilot Chat backed by OpenAI’s GPT-4o

      June 26, 2025

      OpenAI started as a “countervailing force” to Google — did Elon Musk and Sam Altman torpedo DeepMind’s plans to dictate AGI?

      June 26, 2025

      Gears of War: Reloaded preorders — where to buy and everything you need to know

      June 26, 2025

      OpenAI’s Sam Altman breaks silence on Microsoft feud with Satya Nadella — citing “points of tension” amid evolution plans

      June 26, 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

      Are Semantic Layers Sexy Again? or The Rise and Fall and Rise of Semantic Layers

      June 26, 2025
      Recent

      Are Semantic Layers Sexy Again? or The Rise and Fall and Rise of Semantic Layers

      June 26, 2025

      Salesforce Marketing Cloud Engagement vs. Oracle Eloqua

      June 26, 2025

      Exploring Lucidworks Fusion and Coveo Using Apache Solr

      June 26, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft Copilot secures a spot in classrooms as a “thought partner” — with Copilot Chat backed by OpenAI’s GPT-4o

      June 26, 2025
      Recent

      Microsoft Copilot secures a spot in classrooms as a “thought partner” — with Copilot Chat backed by OpenAI’s GPT-4o

      June 26, 2025

      OpenAI started as a “countervailing force” to Google — did Elon Musk and Sam Altman torpedo DeepMind’s plans to dictate AGI?

      June 26, 2025

      Gears of War: Reloaded preorders — where to buy and everything you need to know

      June 26, 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:

    
        public static bool IsDecimal(string theValue)
        {
            try
            {
                Convert.ToDouble(theValue);
                return true;
            }
            catch
            {
                return false;
            }
        } 
    

    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

    Microsoft Copilot secures a spot in classrooms as a “thought partner” — with Copilot Chat backed by OpenAI’s GPT-4o

    June 26, 2025
    News & Updates

    OpenAI started as a “countervailing force” to Google — did Elon Musk and Sam Altman torpedo DeepMind’s plans to dictate AGI?

    June 26, 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

    CVE-2025-3200: Wiesemann & Theis Com-Server Devices Exposed by Deprecated TLS Protocols

    Security

    How to Get YouTube Channel Views Using Custom GPTs? Leaked Guide (2025 Edition)

    Artificial Intelligence

    Camera’s PTZOptics en ValueHD via hardcoded wachtwoord over te nemen

    Security

    With KB5055627, Recall is finally one step closer to general availability in Windows 11

    Operating Systems

    Highlights

    Today’s LLMs craft exploits from patches at lightning speed

    April 21, 2025

    Today’s LLMs craft exploits from patches at lightning speed

    The time from vulnerability disclosure to proof-of-concept (PoC) exploit code can now be as short as a few hours, thanks to generative AI models.
    Matthew Keely, of Platform Security and penetration te …
    Read more

    Published Date:
    Apr 21, 2025 (1 hour, 24 minutes ago)

    Vulnerabilities has been mentioned in this article.

    CVE-2025-32433

    CVE-2025-1254 – RTI Connext Professional Core Libraries Out-of-bounds Read/Write Vulnerability

    May 8, 2025

    CVE-2025-47947 – ModSecurity Denial of Service Vulnerability

    May 21, 2025

    CVE-2025-6360 – Simple Pizza Ordering System SQL Injection

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

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