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

    Orca Security announces new solution for scanning Bitbucket repositories for security issues

    Tech & Work

    Hindsight Bias in UX Research

    Web Development

    Creative Cloud Pro brings new tools and creative controls

    Web Development

    The Service Library Service

    News & Updates

    Highlights

    Development

    CISO’s Guide To Web Privacy Validation And Why It’s Important

    May 26, 2025

    Are your web privacy controls protecting your users, or just a box-ticking exercise? This CISO’s…

    New Rust Botnet Hijacking Routers to Inject Commands Remotely

    April 22, 2025

    Pantaloni Pelle Moto

    July 27, 2025

    Master Database Management Systems

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

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