Function names are verbs
A function does something. Its name must say what it does. Start every function name with a verb.
validate_payment— notpayment_validation.buildInvoice— notinvoiceBuilder.fetchUser— notuserData.retryUpload— notuploadRetry.
A noun names a thing. Classes, variables, types, modules and files are things. Functions are not.
Not optional
This rule is required. It is not a style preference.
No hook enforces it, so nothing will stop you from skipping it. That makes it easier to drop under time pressure, not less binding.
The test
Read the name aloud with a subject in front of it: "it ____". If the sentence works, the name is a verb.
- "it validates payment" — good.
- "it payment validation" — not a function name.
Booleans are still verbs
is, has, can, should and needs are verbs. Use them.
isEligibleForRefund,hasActiveSubscription,canDeleteOrder.- Not
eligibility, notactiveSubscription, notdeletable.
Pick the verb that is true
The verb carries the contract. A wrong verb is worse than a noun.
getreturns something cheap and already present.fetchorloadcrosses a network or a disk.build,create,makereturn a new value.update,set,applychange state.ensuremakes a condition true and is safe to call twice.
handle, process and manage are weak. They fit anything, so they stay true
however much the function grows. Prefer the specific verb when one exists:
chargeOrder over processOrder. When you keep the weak verb, check the length
— see the oversized-function skill.
The exceptions
- Components. A React, Vue or Svelte component is a function, but it names a
thing on screen.
UserCard,CheckoutForm. Keep the noun. - Python
@property. A property is read like an attribute.total_price, notget_total_price. - Constructors and factories that carry a type name.
Money.of,User.from_row.
Nothing else. A callback is a function: onSubmit is a field, but the function
behind it is submitOrder, never submitHandler.
Applying this
- The verb comes first. Then the object it acts on.
- One verb per name. Two verbs means two functions.
- Keep the name inside ten words — see the
self-documenting-namesskill.