Urgent.News

What's breaking now, across thousands of outlets.

Tech

The Evil of Optional Parameters: When Having too Many Options is Self Destructing

You are the main developer of agents.com, an app that lets an organization manage an army of AI agents. You’re designing an admin page where an admin within an org can see each agent and the skills associated with them. You write this beautiful, simple function that takes an orgId and agentId and returns a list of skills: function getAgentSkills ( orgId : string , agentId : string ): AgentSkill…

The article discusses the negative impact of using optional parameters in a function, specifically in the context of an AI agent management system called agents.com. Initially, a simple function named getAgentSkills was created to return a list of skills associated with an agent. As the application evolved, more features were added, leading to an increasingly complex function signature with multiple optional parameters.

The article highlights several issues arising from the use of optional parameters. First, it allows for contradictory and impossible states to be returned, as seen when passing both includeAgent=true and deletedAt=Date(SOME_DATE). This ambiguity confuses developers and makes it difficult to predict the function's output.

Second, optional parameters lead to defensive code on the part of consumers, who must write additional logic to determine what response they are receiving. This not only increases code complexity but also makes the codebase harder to maintain.

Lastly, the article argues that optional parameters create a burden for developers, as they need to remember the correct combination of optional parameters to achieve the desired functionality. The example provided shows a lengthy function call with multiple boolean values and an undefined placeholder, which is considered an inefficient and unclean way to consume the API.

The author concludes that while there are rare cases where optional parameters might be justified, such as when working with a heavily cached system, the use of optional parameters in this particular function has led to a tangled and confusing API that negatively impacts the development experience for all involved.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

From 3 lines to 2 cold emails: a worked example

Most cold emails fail before the first word because the writer never pinned down who they're writing to. Here's the method I use: start from three lines, then build two emails from them.

  • Target niche: independent dental clinics with 2-5 chairs in the US
  • One-line offer: fill last-minute cancelled appointments through text within an hour
  • Three personas: practice owner-dentists, office managers, clinics with new hygienists

I Published 24 Articles in 5 Days. Here's What Actually Moved — and What Took 3 Days to Show Up.

"I Published 24 Articles in 5 Days. Here's What Actually Moved — and What Took 3 Days to Show Up." published: true tags: seo, contentstrategy, webdev, indiehackers description: "A solo dev's content…

  • Developer published 24 articles in 5 days, boosting ToolVault's search visibility
  • Post on post-quantum cryptography climbed to top-10 pages within a day, gaining 18 visits
  • Google Search Console shows impact after 3-day lag, emphasizing importance of 72-hour evaluation

"Your file never leaves your device": how to test that claim (and the Chromium catch)

Lots of web tools now say "runs in your browser, nothing is uploaded". I make one of them ( Drible , 53 file tools, 48 of which run client-side), and at some point I realised the claim was just a…

  • Many web tools claim client-side operation, but claim can be tested.
  • Test involves capturing network requests for file signatures and non-GET requests.
  • Chromium fails test due to not exposing file upload bodies to Playwright.

A 10-Point Scorecard for Vetting Telegram Channels Before Adding Them to Your Collection Set

Every Telegram OSINT collection set starts as a pile of channels someone pasted from a Twitter thread. Most of that pile is junk, and the junk is expensive: every junk channel in your collection set…

  • Scorecard assesses Telegram channels across origin, language, cadence, audience, and link hygiene
  • Channels must score at least 7 overall to be included in collection set
  • Origin evaluation checks for original reporting and watermark consistency

More from Saturday 10 October →