Names and functions Required
Never let a name mislead
A name must never suggest a type or behaviour the code does not have. Calling a set a list, or a lookup a getter that writes, misleads every reader.
How to do it
Only use a type word, such as List, Map or Set, when the value is that type. Prefer a plain plural, such as customers. Keep names that differ only slightly, such as account and accounts, far apart or rename one. A function named get must not change anything.
Example
# Bad: a set called a list, and a getter that writes
customer_list = {"ada@example.com", "bo@example.com"}
def get_order(order_id): orders.mark_viewed(order_id); return orders.find(order_id)
# Good
customer_emails = {"ada@example.com", "bo@example.com"}
def find_order(order_id): return orders.find(order_id)
// Bad: a set called a list, and a getter that writes
const customerList = new Set(['ada@example.com', 'bo@example.com']);
function getOrder(id: string) { orders.markViewed(id); return orders.find(id); }
// Good
const customerEmails = new Set(['ada@example.com', 'bo@example.com']);
function findOrder(id: string) { return orders.find(id); }
How to check
Type checkers do not read names, so this is a review question. Does any name suggest a wrong type or hide a side effect? A custom lint rule can flag functions named get that write.
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/no-disinformation.