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

      Last week in AI dev tools: Cloudflare blocking AI crawlers by default, Perplexity Max subscription, and more (July 7, 2025)

      July 7, 2025

      Infragistics Launches Ultimate 25.1 With Major Updates to App Builder, Ignite UI

      July 7, 2025

      Design Guidelines For Better Notifications UX

      July 7, 2025

      10 Top React.js Development Service Providers For Your Next Project In 2026

      July 7, 2025

      A million customer conversations with AI agents yielded this surprising lesson

      July 7, 2025

      Bookworms: Don’t skip this Kindle Paperwhite Essentials bundle that’s on sale

      July 7, 2025

      My favorite “non-gaming” gaming accessory is down to its lowest price for Prime Day | XREAL’s AR glasses give you a virtual cinema screen for Xbox Cloud Gaming, Netflix, PC gaming handhelds, and more

      July 7, 2025

      I’ve been using this Alienware 240Hz gaming monitor for 2 years — less than $1 a day if I’d bought it with this Prime Day discount

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

      Token Limit – Monitor token usage in AI context files

      July 7, 2025
      Recent

      Token Limit – Monitor token usage in AI context files

      July 7, 2025

      Perficient Named a 2025 Best Place to Work in Orange County!

      July 7, 2025

      Perficient Recognized by Leading Analyst Firm for Automotive and Mobility Expertise

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

      My favorite “non-gaming” gaming accessory is down to its lowest price for Prime Day | XREAL’s AR glasses give you a virtual cinema screen for Xbox Cloud Gaming, Netflix, PC gaming handhelds, and more

      July 7, 2025
      Recent

      My favorite “non-gaming” gaming accessory is down to its lowest price for Prime Day | XREAL’s AR glasses give you a virtual cinema screen for Xbox Cloud Gaming, Netflix, PC gaming handhelds, and more

      July 7, 2025

      I’ve been using this Alienware 240Hz gaming monitor for 2 years — less than $1 a day if I’d bought it with this Prime Day discount

      July 7, 2025

      Final Fantasy IX Remake possibly cancelled according to latest rumors — Which may be the saddest way to celebrate this legendary game’s 25th anniversary

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

    A million customer conversations with AI agents yielded this surprising lesson

    July 7, 2025
    News & Updates

    Bookworms: Don’t skip this Kindle Paperwhite Essentials bundle that’s on sale

    July 7, 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-5430 – AssamLook CMS SQL Injection Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Turn Data Chaos into AI Clarity with Data Quality Management

    Development

    React 19: Revolutionizing Web Development with New Features

    Web Development

    CVE-2025-43921 – cPanel WHM GNU Mailman Unauthenticated List Creation Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    Building Construction suppliers in India

    June 16, 2025

    Comments Source: Read More 

    CVE-2025-1529 – WordPress AM LottiePlayer Stored Cross-Site Scripting Vulnerability

    May 1, 2025

    CVE-2025-43025 – HP Universal Print Driver Buffer Overflow Denial of Service

    July 2, 2025

    CVE-2025-4148 – Netgear EX6200 Remote Buffer Overflow Vulnerability

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

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