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

      Turning User Research Into Real Organizational Change

      July 1, 2025

      June 2025: All AI updates from the past month

      June 30, 2025

      Building a culture that will drive platform engineering success

      June 30, 2025

      Gartner: More than 40% of agentic AI projects will be canceled in the next few years

      June 30, 2025

      I FINALLY got my hands on my most anticipated gaming laptop of 2025 — and it’s a 14-inch monster

      July 1, 2025

      This gimbal-tracking webcam has TWO cameras and a great price — but it may not be “private” enough

      July 1, 2025

      I spent two months using the massive Area-51 gaming rig — both a powerful beast PC and an RGB beauty queen

      July 1, 2025

      “Using AI is no longer optional” — Did Microsoft just make Copilot mandatory for its staff as a critical performance metric?

      July 1, 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

      June report 2025

      July 1, 2025
      Recent

      June report 2025

      July 1, 2025

      Make your JS functions smarter and cleaner with default parameters

      July 1, 2025

      Best Home Interiors in Hyderabad – Top Designers & Affordable Packages

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

      I FINALLY got my hands on my most anticipated gaming laptop of 2025 — and it’s a 14-inch monster

      July 1, 2025
      Recent

      I FINALLY got my hands on my most anticipated gaming laptop of 2025 — and it’s a 14-inch monster

      July 1, 2025

      This gimbal-tracking webcam has TWO cameras and a great price — but it may not be “private” enough

      July 1, 2025

      I spent two months using the massive Area-51 gaming rig — both a powerful beast PC and an RGB beauty queen

      July 1, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: It’s Not Wrong to Say We’re Equal

    CodeSOD: It’s Not Wrong to Say We’re Equal

    July 1, 2025

    Aaron was debugging some C# code, and while this wasn’t the source of the bug, it annoyed him enough to send it to us.

    protected override int DoCompare(Item item1, Item item2)
    {
    	try
    	{
    		DateTime thisDate = ((DateField)item1.Fields["Create Date"]).DateTime;
    		DateTime thatDate = ((DateField)item2.Fields["Create Date"]).DateTime;
    
    		return thatDate.CompareTo(thisDate);
    	}
    	catch (Exception)
    	{
    		return 0; // Sorry, ran out of budget!
    	}
    }
    

    Not to be the pedantic code reviewer, but the name of this function is terrible. Also, DoCompare clearly should be static, but this is just pedantry.

    Now, there’s a lot of implied WTFs hidden in the Item class. They’re tracking fields in a dictionary, or maybe a ResultSet, but I don’t think it’s a ResultSet because they’re converting it to a DateField object, which I believe to be a custom type. I don’t know what all is in that class, but the whole thing looks like a mess and I suspect that there are huge WTFs under that.

    But we’re not here to look at implied WTFs. We’re here to talk about that exception handler.

    It’s one of those “swallow every error” exception handlers, which is always a “good” start, and it’s the extra helpful kind, which returns a value that is likely incorrect and provides no indication that anything failed.

    Now, I suspect it’s impossible for anything to have failed- as stated, this seems to be some custom objects and I don’t think anything is actively talking to a database in this function (but I don’t know that!) so the exception handler likely never triggers.

    But hoo boy, does the comment tell us a lot about the codebase. “Sorry, ran out of budget!”. Bugs are inevitable, but this is arguably the worst way to end up with a bug in your code: because you simply ran out of money and decided to leave it broken. And ironically, I suspect the code would be less broken if you just let the exception propagate up- if nothing else, you’d know that something failed, instead of incorrectly thinking two dates were the same.

    [Advertisement]
    BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticlePulp – skim excessive feeds
    Next Article CVE-2025-6934 – Opal Estate Pro – WordPress Property Management Plugin Privilege Escalation Vulnerability

    Related Posts

    News & Updates

    I FINALLY got my hands on my most anticipated gaming laptop of 2025 — and it’s a 14-inch monster

    July 1, 2025
    News & Updates

    This gimbal-tracking webcam has TWO cameras and a great price — but it may not be “private” enough

    July 1, 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

    Software Supply Chain Attacks Have Surged in Recent Months

    Development

    From Scroll to Sale: Designing a Creator-Led Shopping Journey

    Web Development

    CVE-2025-2762 – CarlinKit CPC200-CCPA Root of Trust Failure Privilege Escalation Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    TeamViewer for Windows Vulnerability Let Attackers Delete Files Using SYSTEM Privileges

    Security

    Highlights

    Facebook privacy – why statements about copyright don’t do anything

    April 9, 2025

    Facebook users around the world have reported the return of the network’s longer-lasting hoaxes -…

    ByteDance Introduces VAPO: A Novel Reinforcement Learning Framework for Advanced Reasoning Tasks

    ByteDance Introduces VAPO: A Novel Reinforcement Learning Framework for Advanced Reasoning Tasks

    April 10, 2025

    AI will change the trades too – and field service technicians can’t wait

    April 9, 2025

    Critical Vulnerabilities in Quick Agent Software Expose Ricoh MFPs to Remote Attacks

    April 29, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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