I once spent twenty minutes staring at a function called processData. It fetched a user from an API, checked a flag, wrote a row to the database, and sent an email. Four jobs under one name. Everyone who opened that file had to read the whole thing to work out what it did. That is what a bad name costs you. Not a crash, just twenty minutes here, ten minutes there, every time someone new touches the code.
Names are the first thing another person reads. Before the logic, before the comments, the name tells them what to expect. Get it wrong and they have to unlearn it before they can do anything else.
Fetch, load, and get do different jobs
In everyday speech, fetch, load, and get are near enough the same. In code they promise different things. If your codebase swaps them around, every reader has to guess what really happens.
getUser sounds like the data is already close by, a quick lookup. fetchUser sounds like a trip out to a network or an API. loadUser sounds like reading from disk, or doing some setup first. Three words, three promises about where the data comes from and how long it takes.
Saving is the same story. save is plain. store sounds like putting something away for later. persist sounds like it will survive a restart. Call a function persist when it only writes to memory, and one day someone will trust that word and lose data. The name lied. The code did not.
So before you name a function, ask what the name promises. Then check the code keeps the promise. If it doesn't, fix the name.
A name carries a feeling
delete sounds final. remove sounds like taking something off a list. discard sounds like binning a draft. All three take something away, but a reader feels a different level of danger from each. A button that says "Delete account" should make you pause. A button that says "Remove from list" should not. The words do the warning for you.
Booleans are where this hurts most. isEnabled and isActive look interchangeable until you think about them. Enabled means the switch is on, the feature is allowed to run. Active means it is running right now. A feature can be enabled and still sit idle, like a light switched on in an empty room. Mix the two up and someone will read if (isActive) and believe a job is running when it was only ever allowed to run.
The words users see matter just as much. "Failed" blames the user. "Could not complete" does not. "Invalid input" says you did something wrong. "That email address does not look right" says what to fix. An error message is a sentence a person reads when something has already gone wrong. The word you pick decides whether they feel helped or scolded.
Strong words and weak words in logs
Log levels are a strength scale. Debug, info, warn, error, fatal. Each step means more. Log everything as an error and nothing is an error anymore. The real problems drown in the noise. Log a crashed payment as a warning and nobody looks at it until a customer complains.
Ticket titles have the same problem. Critical means something is broken now. Urgent means it needs attention soon. A team that marks every ticket critical will stop believing the word, and then a genuinely critical ticket sits in the queue like all the others. Keep the strong words for the moments that earn them.
One word per idea
The best rule I know for a shared codebase is simple: one word per idea, used everywhere. If the same thing is called a "user" in one file, an "account" in another, and a "member" in a third, every new teammate has to learn that all three mean the same thing. And they will guess wrong sometimes.
Pick one word and use it in the code, in the database, in the API, and in the docs. People call this ubiquitous language: the words the team uses when they talk should be the same words in the code. When a product manager says "order" and the code says "purchase", every conversation has a translation step in it. Translation steps are where bugs are born.
Not sure which word to pick? Ask what the user calls it. Their word is usually the right one, because it is the word everyone outside the code already uses.
When in doubt, keep it plain
When two names both look fine, take the plainer one. It is easier to search for, easier to say in a standup, and easier for a new teammate to understand. getTotalPrice beats computeAggregateMonetaryValue every time. The long name is not smarter. It is only longer, and it makes every line that uses it harder to read.
The same goes for comments. "Temporary workaround, remove after the API fix" tells the next reader exactly what to do. "Utilise provisional mitigation strategy" says the same thing in a way nobody will act on. Plain words get read. Fancy words get skipped.
I still think about that processData function sometimes. It took one rename to fix: four small functions with honest names. Nobody has stared at it for twenty minutes since. Names are the cheapest documentation you will ever write, and the only kind every reader is guaranteed to read.
When two words look the same and I need to see the difference between them, I check NexAuthority. It shows the shades of meaning, so I can see which word carries the right feeling and which one is simply stronger than the next.
Top comments (0)