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»CodeSOD: An Array of Parameters

    CodeSOD: An Array of Parameters

    August 14, 2025

    Andreas found this in a rather large, rather ugly production code base.

    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">LogView</span>(<span class="hljs-params"><span class="hljs-built_in">object</span> o</span>)</span>
    {
        <span class="hljs-keyword">try</span>
        {
            ArrayList al = (ArrayList)o;
            <span class="hljs-built_in">int</span> pageId = (<span class="hljs-built_in">int</span>)al[<span class="hljs-number">0</span>];
            <span class="hljs-built_in">int</span> userId = (<span class="hljs-built_in">int</span>)al[<span class="hljs-number">1</span>];
    
            <span class="hljs-comment">// ... snipped: Executing a stored procedure that stores the values in the database</span>
        }
        <span class="hljs-keyword">catch</span> (Exception) { }
    }
    

    This function accepts an object of any type, except no, it doesn’t, it expect that object to be an ArrayList. It then assumes the array list will then store values in a specific order. Note that they’re not using a generic ArrayList here, nor could they- it (potentially) needs to hold a mix of types.

    What they’ve done here is replace a parameter list with an ArrayList, giving up compile time type checking for surprising runtime exceptions. And why?

    “Well,” the culprit explained when Andreas asked about this, “the underlying database may change. And then the function would need to take different parameters. But that could break existing code, so this allows us to add parameters without ever having to change existing code.”

    “Have you heard of optional arguments?” Andreas asked.

    “No, all of our arguments are required. We’ll just default the ones that the caller doesn’t supply.”

    And yes, this particular pattern shows up all through the code base. It’s “more flexible this way.”

    [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 ArticleLaravel Boost is released
    Next Article On Accessibility Conformance, Design Systems, and CSS “Base” Units

    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

    How to Automate Mobile Testing: Strategies for Reliable, Scalable Tests

    Development

    Closing Deals Faster: The Future of Sales with AI & Personalization

    Development

    Mistral-Small-3.2-24B-Instruct-2506 is now available on Amazon Bedrock Marketplace and Amazon SageMaker JumpStart

    Machine Learning

    Before AI: How Templates Put the First Dent in Web Design’s Coffin

    Web Development

    Highlights

    Google’s new Opal tool allows users to create mini AI apps with no coding required

    July 28, 2025

    Google has launched a new experimental AI tool designed for users who want to build…

    U.S. House Bans WhatsApp on Official Devices Over Security and Data Protection Issues

    June 24, 2025

    Experts Uncover New XorDDoS Controller, Infrastructure as Malware Expands to Docker, Linux, IoT

    April 18, 2025

    Paragon Commercial Spyware Infects Prominent Journalists

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

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