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

      10 Top Node.js Development Companies for Enterprise-Scale Projects (2025-2026 Ranked & Reviewed)

      July 4, 2025

      12 Must-Know Cost Factors When Hiring Node.js Developers for Your Enterprise

      July 4, 2025

      Mirantis reveals Lens Prism, an AI copilot for operating Kubernetes clusters

      July 3, 2025

      Avoid these common platform engineering mistakes

      July 3, 2025

      Just days after joining Game Pass, the Xbox PC edition of Call of Duty: WW2 is taken offline for “an issue”

      July 5, 2025

      Xbox layoffs and game cuts wreak havoc on talented developers and the company’s future portfolio β€” Weekend discussion πŸ’¬

      July 5, 2025

      Microsoft plans to revamp Recall in Windows 11 with these new features

      July 5, 2025

      This 4K OLED monitor has stereo speakers that follow you β€” but it’s missing something “imPORTant”

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

      Flaget – new small 5kB CLI argument parser

      July 5, 2025
      Recent

      Flaget – new small 5kB CLI argument parser

      July 5, 2025

      The dog days of JavaScript summer

      July 4, 2025

      Databricks Lakebase – Database Branching in Action

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

      Just days after joining Game Pass, the Xbox PC edition of Call of Duty: WW2 is taken offline for “an issue”

      July 5, 2025
      Recent

      Just days after joining Game Pass, the Xbox PC edition of Call of Duty: WW2 is taken offline for “an issue”

      July 5, 2025

      Xbox layoffs and game cuts wreak havoc on talented developers and the company’s future portfolio β€” Weekend discussion πŸ’¬

      July 5, 2025

      Microsoft plans to revamp Recall in Windows 11 with these new features

      July 5, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: A Trying Block

    CodeSOD: A Trying Block

    May 22, 2025

    Mark sends us a very simple Java function which has the job of parsing an integer from a string. Now, you might say, “But Java has a built in for that, Integer.parseInt,” and have I got good news for you: they actually used it. It’s just everything else they did wrong.

    private int makeInteger(String s)
    {
      int i=0;
      try
      {
        Integer.parseInt(s);
      }
      catch (NumberFormatException e)
      {
        i=0;
        return i;
      }
      i=Integer.parseInt(s);
      return i;
    }
    

    This function is really the story of variable i, the most useless variable ever. It’s doing its best, but there’s just nothing for it to do here.

    We start by setting i to zero. Then we attempt to parse the integer, and do nothing with the result. If it fails, we set i to zero again, just for fun, and then return i. Why not just return 0? Because then what would poor i get to do?

    Assuming we didn’t throw an exception, we parse the input again, storing its result in i, and then return i. Again, we treat i like a child who wants to help paint the living room: we give it a dry brush and a section of wall we’re not planning to paint and let it go to town. Nothing it does matters, but it feels like a participant.

    Now, Mark went ahead and refactored this function basically right away, into a more terse and clear version:

    private int makeInteger(String s)
    {
      try
      {
        return Integer.parseInt(s);
      }
      catch (NumberFormatException e)
      {
        return 0;
      }
    }
    

    He went about his development work, and then a few days later came across makeInteger reverted back to its original version. For a moment, he wanted to be mad at someone for reverting his change, but no- this was in an entirely different class. With that information, Mark went and did a search for makeInteger in the code, only to find 39 copies of this function, with minor variations.

    There are an unknown number of copies of the function where the name is slightly different than makeInteger, but a search for Integer.parseInt implies that there may be many more.

    [Advertisement]
    Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upgrade when ready.Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHand TeX is a handwritten LaTeX symbol classifier
    Next Article Egghead is a simple trivia app

    Related Posts

    News & Updates

    Just days after joining Game Pass, the Xbox PC edition of Call of Duty: WW2 is taken offline for “an issue”

    July 5, 2025
    News & Updates

    Xbox layoffs and game cuts wreak havoc on talented developers and the company’s future portfolio β€” Weekend discussion πŸ’¬

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

    From Logic to Confusion: MIT Researchers Show How Simple Prompt Tweaks Derail LLM Reasoning

    Machine Learning

    CVE-2024-41195 – Ocuco Innovation INNOVASERVICEINTF.EXE Privilege Escalation Remote Authentication Bypass

    Common Vulnerabilities and Exposures (CVEs)

    DragonForce Exploits SimpleHelp Flaws to Deploy Ransomware Across Customer Endpoints

    Development

    8 Best Free and Open Source NVIDIA GPU Monitoring Tools

    Linux

    Highlights

    Microsoft Family Safety is blocking Chrome after recent update β€” here’s how to fix

    June 21, 2025

    If your child’s Chrome browser suddenly won’t open on a Windows PC, you’re not alone.…

    How IBM’s new AI solutions ease deployment and integration for your business

    May 6, 2025

    Blockchain Offers Security Benefits – But Don’t Neglect Your Passwords

    April 17, 2025

    Microsoft Store adds Copilot, smarter search, and a personalized homepage

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

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