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

      Sentry launches MCP monitoring tool

      August 14, 2025

      10 Benefits of Hiring a React.js Development Company (2025–2026 Edition)

      August 13, 2025

      From Line To Layout: How Past Experiences Shape Your Design Career

      August 13, 2025

      Hire React.js Developers in the US: How to Choose the Right Team for Your Needs

      August 13, 2025

      I’ve tested every Samsung Galaxy phone in 2025 – here’s the model I’d recommend on sale

      August 14, 2025

      Google Photos just put all its best editing tools a tap away – here’s the shortcut

      August 14, 2025

      Claude can teach you how to code now, and more – how to try it

      August 14, 2025

      One of the best work laptops I’ve tested has MacBook written all over it (but it’s even better)

      August 14, 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

      Controlling Execution Flow with Laravel’s Sleep Helper

      August 14, 2025
      Recent

      Controlling Execution Flow with Laravel’s Sleep Helper

      August 14, 2025

      Generate Secure Temporary Share Links for Files in Laravel

      August 14, 2025

      This Week in Laravel: Filament 4, Laravel Boost, and Junie Review

      August 14, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      KDE Plasma 6 on Wayland: the Payoff for Years of Plumbing

      August 14, 2025
      Recent

      KDE Plasma 6 on Wayland: the Payoff for Years of Plumbing

      August 14, 2025

      FOSS Weekly #25.33: Debian 13 Released, Torvalds vs RISC-V, Arch’s New Tool, GNOME Perfection and More Linux Stuff

      August 14, 2025

      Ultimate ChatGPT-5 Prompt Guide: 52 Ideas for Any Task

      August 14, 2025
    • 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.

    private static void LogView(object o)
    {
        try
        {
            ArrayList al = (ArrayList)o;
            int pageId = (int)al[0];
            int userId = (int)al[1];
    
            // ... snipped: Executing a stored procedure that stores the values in the database
        }
        catch (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 ArticleEye Care: Best Free Linux Software to Look after your Eyes
    Next Article Rilasciata Kaisen Linux Rolling 3.0: Ma Annuncia che Sarà l’Ultima!

    Related Posts

    News & Updates

    I’ve tested every Samsung Galaxy phone in 2025 – here’s the model I’d recommend on sale

    August 14, 2025
    News & Updates

    Google Photos just put all its best editing tools a tap away – here’s the shortcut

    August 14, 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

    Rilasciato Mozilla Thunderbird 137: tutte le novità del client email open-source

    Linux

    How to Scale TestOps for Global Software Development Teams

    Development

    Patch Tuesday, June 2025 Edition

    Security

    Figma AI Tools

    Web Development

    Highlights

    Machine Learning

    Build and deploy AI inference workflows with new enhancements to the Amazon SageMaker Python SDK

    June 30, 2025

    Amazon SageMaker Inference has been a popular tool for deploying advanced machine learning (ML) and…

    ONLYOFFICE Docs 9.0 is here: discover the redesigned interface, diagram viewer, AI tools and more

    June 18, 2025

    CVE-2025-40656 – DM Corporative CMS SQL Injection Vulnerability

    June 10, 2025

    Grafana Patches CVE-2025-3260 and More in Critical Security Update

    April 23, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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