Agent Wranglers

Names and functions Required

Pass few arguments

Give a function at most three arguments. When it needs more, pass one named object that groups them.

How to do it

Group arguments that travel together into a parameter object or DTO, such as ShippingAddress. Replace boolean flags with two functions, because a flag means the function does two things.

Example

// Bad
createOrder(customerId, street, city, postcode, country, true);
// Good
createOrder({ customerId, shippingAddress, giftWrap: true });

How to check

ESLint max-params set to 3, PHPMD ExcessiveParameterList with a minimum of 4, or Pylint too-many-arguments with max-args=3.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/names-and-functions/few-arguments.