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

      Top 10 Use Cases of Vibe Coding in Large-Scale Node.js Applications

      September 3, 2025

      Cloudsmith launches ML Model Registry to provide a single source of truth for AI models and datasets

      September 3, 2025

      Kong Acquires OpenMeter to Unlock AI and API Monetization for the Agentic Era

      September 3, 2025

      Microsoft Graph CLI to be retired

      September 2, 2025

      ‘Cronos: The New Dawn’ was by far my favorite experience at Gamescom 2025 — Bloober might have cooked an Xbox / PC horror masterpiece

      September 4, 2025

      ASUS built a desktop gaming PC around a mobile CPU — it’s an interesting, if flawed, idea

      September 4, 2025

      Hollow Knight: Silksong arrives on Xbox Game Pass this week — and Xbox’s September 1–7 lineup also packs in the horror. Here’s every new game.

      September 4, 2025

      The Xbox remaster that brought Gears to PlayStation just passed a huge milestone — “ending the console war” and proving the series still has serious pulling power

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

      Magento (Adobe Commerce) or Optimizely Configured Commerce: Which One to Choose

      September 4, 2025
      Recent

      Magento (Adobe Commerce) or Optimizely Configured Commerce: Which One to Choose

      September 4, 2025

      Updates from N|Solid Runtime: The Best Open-Source Node.js RT Just Got Better

      September 3, 2025

      Scale Your Business with AI-Powered Solutions Built for Singapore’s Digital Economy

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

      ‘Cronos: The New Dawn’ was by far my favorite experience at Gamescom 2025 — Bloober might have cooked an Xbox / PC horror masterpiece

      September 4, 2025
      Recent

      ‘Cronos: The New Dawn’ was by far my favorite experience at Gamescom 2025 — Bloober might have cooked an Xbox / PC horror masterpiece

      September 4, 2025

      ASUS built a desktop gaming PC around a mobile CPU — it’s an interesting, if flawed, idea

      September 4, 2025

      Hollow Knight: Silksong arrives on Xbox Game Pass this week — and Xbox’s September 1–7 lineup also packs in the horror. Here’s every new game.

      September 4, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Adding to the Argument

    CodeSOD: Adding to the Argument

    September 3, 2025

    David G saw a pull request with a surprisingly long thread of comments on it. What was weirder was that the associated ticket was all about adding a single parameter to an existing method. What could be generating that much discussion?

    How could adding an argument add to an argument?

    <span class="hljs-attr">registerFooWrapper</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params">arg1, arg2, arg3, arg4, arg5, arg6, arg7</span>) {
        bar.<span class="hljs-title function_">when</span>(<span class="hljs-string">'bar-event'</span>, <span class="hljs-keyword">function</span>(<span class="hljs-params">context</span>) {
            context.<span class="hljs-title function_">foo</span>({
                <span class="hljs-attr">arg1</span>: arg1,
                <span class="hljs-attr">arg2</span>: arg2,
                <span class="hljs-attr">arg3</span>: arg3,
                <span class="hljs-attr">arg4</span>: arg4,
                <span class="hljs-attr">arg5</span>: arg5,
                <span class="hljs-attr">arg6</span>: arg6,
                <span class="hljs-attr">arg7</span>: arg7,
            });
        });
    }
    

    This is the original version of the JavaScript function. The parameter names have been anonymized. That aside, this still isn’t very good. Seven parameters is likely too many, and based on what I see in setting the context, there is an object type that holds them all, so maybe we should be passing the object around in the first place? Still, this isn’t a WTF by any stretch, and since it’s already deployed code, changing the interface significantly is a bad idea- maybe just adding a parameter is the right choice here. So what generated so much discussion?

    This revision:

    <span class="hljs-attr">registerFooWrapper</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params">arg1, arg2, arg3, arg4, arg5, arg6, arg7, notArg8</span>) {
        <span class="hljs-keyword">if</span> (notArg8 === <span class="hljs-literal">true</span>) {
            bar.<span class="hljs-title function_">when</span>(<span class="hljs-string">'bar-event'</span>, <span class="hljs-keyword">function</span>(<span class="hljs-params">context</span>) {
                context.<span class="hljs-title function_">foo</span>({
                    <span class="hljs-attr">arg1</span>: arg1,
                    <span class="hljs-attr">arg2</span>: arg2,
                    <span class="hljs-attr">arg3</span>: arg3,
                    <span class="hljs-attr">arg4</span>: arg4,
                    <span class="hljs-attr">arg5</span>: arg5,
                    <span class="hljs-attr">arg6</span>: arg6,
                    <span class="hljs-attr">arg7</span>: arg7,
                    <span class="hljs-attr">arg8</span>: !notArg8,
                });
            });
        }
        <span class="hljs-keyword">else</span> {
            bar.<span class="hljs-title function_">when</span>(<span class="hljs-string">'bar-event'</span>, <span class="hljs-keyword">function</span>(<span class="hljs-params">context</span>) {
                context.<span class="hljs-title function_">foo</span>({
                    <span class="hljs-attr">arg1</span>: arg1,
                    <span class="hljs-attr">arg2</span>: arg2,
                    <span class="hljs-attr">arg3</span>: arg3,
                    <span class="hljs-attr">arg4</span>: arg4,
                    <span class="hljs-attr">arg5</span>: arg5,
                    <span class="hljs-attr">arg6</span>: arg6,
                    <span class="hljs-attr">arg7</span>: arg7
                });
            });
        }
    }
    

    Okay, so if notArg8 is true, we pass false to the context. If it’s any other value, we don’t past arg8 at all. I do not understand what I’m looking at here. If the goal is to ensure that arg8 is either true or not set, there are clearer ways to express that idea. But also, the goal of the ticket was not to do that- it was simply to add another parameter, which means you could drop the condition entirely and just add the parameter. context was already receiving arg8 as undefined, so it could clearly handle an undefined value.

    David made some comments on the pull request, but the original developer just ended up going radio silent on it. One of the juniors on David’s team approved it, for some reason, but nobody ever actually hit merge. Instead, a different developer simply made a version that took arg8 as a parameter, passed it down to context, and called it a day. It worked, the tests passed, and everyone was happy.

    Well, except the original developer, but again, who knows what they were trying to do?

    [Advertisement]
    ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleLaracon AU 2025 Talk Titles Revealed
    Next Article 7 Must-Know GSAP Animation Tips for Creative Developers

    Related Posts

    News & Updates

    ‘Cronos: The New Dawn’ was by far my favorite experience at Gamescom 2025 — Bloober might have cooked an Xbox / PC horror masterpiece

    September 4, 2025
    News & Updates

    ASUS built a desktop gaming PC around a mobile CPU — it’s an interesting, if flawed, idea

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

    We’ll Just Do a Quick Design Audit” (Famous Last Words)

    Web Development

    Microsoft Urges TPM 2.0 for Windows 11 Upgrade as Win 10 Support Nears End

    Security

    CVE-2025-5858 – PHPGurukul Nipah Virus Testing Management System SQL Injection

    Common Vulnerabilities and Exposures (CVEs)

    AI Agent Examples: Transforming Technology

    Development

    Highlights

    Machine Learning

    Build a conversational data assistant, Part 1: Text-to-SQL with Amazon Bedrock Agents

    July 11, 2025

    What if you could replace hours of data analysis with a minute-long conversation? Large language…

    Battlefield 6 won’t bother with ray tracing — here’s why that matters

    September 4, 2025

    CVE-2025-8879 – Google Chrome Heap Buffer Overflow Vulnerability

    August 13, 2025

    CVE-2025-46014 – Honor PC Manager Named Pipe Privilege Escalation Vulnerability

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

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