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

      Error’d: Pickup Sticklers

      September 27, 2025

      From Prompt To Partner: Designing Your Custom AI Assistant

      September 27, 2025

      Microsoft unveils reimagined Marketplace for cloud solutions, AI apps, and more

      September 27, 2025

      Design Dialects: Breaking the Rules, Not the System

      September 27, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Cailabs secures €57M to accelerate growth and industrial scale-up

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

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025
      Recent

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025

      Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

      September 28, 2025

      The first browser with JavaScript landed 30 years ago

      September 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured
      Recent
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»Representative Line: Springs are Optional

    Representative Line: Springs are Optional

    August 28, 2025

    Optional types are an attempt to patch the “billion dollar mistake“. When you don’t know if you have a value or not, you wrap it in an Optional, which ensures that there is a value (the Optional itself), thus avoiding null reference exceptions. Then you can query the Optional to see if there is a real value or not.

    This is all fine and good, and can cut down on some bugs. Good implementations are loaded with convenience methods which make it easy to work on the optionals.

    But then, you get code like Burgers found. Which just leaves us scratching our heads:

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> Optional<Boolean> TRUE = Optional.of(Boolean.TRUE);
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> Optional<Boolean> FALSE = Optional.of(Boolean.FALSE);
    

    Look, any time you’re making constants for TRUE or FALSE, something has gone wrong, and yes, I’m including pre-1999 versions of C in this. It’s especially telling when you do it in a language that already has such constants, though- at its core- these lines are saying TRUE = TRUE. Yes, we’re wrapping the whole thing in an Optional here, which potentially is useful, but if it is useful, something else has gone wrong.

    Burgers works for a large insurance company, and writes this about the code:

    I was trying to track down a certain piece of code in a Spring web API application when I noticed something curious. It looked like there was a chunk of code implementing an application-specific request filter in business logic, totally ignoring the filter functions offered by the framework itself and while it was not related to the task I was working on, I followed the filter apply call to its declaration.
    While I cannot supply the entire custom request filter implementation, take these two static declarations as a demonstration of how awful the rest of the class is.

    Ah, of course- deep down, someone saw a perfectly functional wheel and said, “I could make one of those myself!” and these lines are representative of the result.

    [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 ArticleHeartbeat Collection Method in Laravel 12.26; Wayfinder Now in React and Vue Starter Kits
    Next Article Interactive Video Projection Mapping with Three.js

    Related Posts

    News & Updates

    Building personal apps with open source and AI

    September 12, 2025
    News & Updates

    What Can We Actually Do With corner-shape?

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

    Instruction-Following Pruning for Large Language Models

    Machine Learning

    JavaScript Weekly Insights #20: Latest Frameworks, Tools & Trends

    Development

    Don’t Choose the Wrong Web Team — Here’s Why It Matters

    Development

    Introduction to the View Transitions API: A New Era of Seamless Page Navigation

    Web Development

    Highlights

    Development

    Meeting European Accessibility Act (EAA) Standards: A Developer’s Checklist

    July 16, 2025

    Ensure your digital products meet the EAA standards before the June 2025 deadline. This guide…

    Dutch Espionage Law Update 2025: Cyber Offenses Now Punishable by Up to 12 Years

    May 21, 2025

    How PayU built a secure enterprise AI assistant using Amazon Bedrock

    July 15, 2025

    May report 2025

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

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