Names and functions Recommended
Use names you can search for and say aloud
Use whole words that people can pronounce and search for. Replace magic numbers and strings with named constants.
How to do it
Write customerAddress, not cstmrAdr. Use single letters only for tiny loops or math. Give every repeated number or string a named constant, such as MAX_LOGIN_ATTEMPTS = 5.
Example
// Bad
if (tries > 5) lock(u);
// Good
const MAX_LOGIN_ATTEMPTS = 5;
if (failedLogins > MAX_LOGIN_ATTEMPTS) lockAccount(user);
# Bad
if tries > 5:
lock(u)
# Good
MAX_LOGIN_ATTEMPTS = 5
if failed_logins > MAX_LOGIN_ATTEMPTS:
lock_account(user)
How to check
A linter rejects short names and bare numbers, for example ESLint id-length with a minimum of 2 and no-magic-numbers, Pylint invalid-name, or PHPMD ShortVariable. Searching for a constant's name finds every place it is used.
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/searchable-names.