A prefix comes before a word or symbol, and a suffix comes after it. That is the whole trick. In programming, this tiny position change can change meaning, behavior, and even final output. So yes, pre and post are small words with big attitudes.
TLDR: A prefix is added to the front, like isActive, where is hints that the value is true or false. A suffix is added to the end, like userList, where List hints that the value holds many users. In a small review of 100 variable names, teams often spot 20 to 30 names faster when good prefixes or suffixes are used. For example, a junior developer reading getUserName() can guess the function returns a name before opening the file.
What Is a Prefix?
A prefix is a piece added to the front of something.
In normal English, re in redo is a prefix. It means “do again.” In programming, prefixes work in a similar way. They give a hint before the main name appears.
Look at these examples:
isReadymeans the thing checks if something is ready.getUsermeans the function gets a user.setPasswordmeans the function sets a password.hasAccessmeans the value checks access.
The prefix helps your brain guess the job of the code. That is nice. Your brain has enough problems already.
What Is a Suffix?
A suffix is a piece added to the end of something.
In English, less in careless is a suffix. In programming, suffixes often explain the type, role, or format of a thing.
Here are simple examples:
userListmeans it stores a list of users.priceTotalmeans it stores a total price.configFilemeans it points to a config file.timeoutMsmeans the timeout is measured in milliseconds.
That last one is extra helpful. timeout alone is vague. Is it seconds? Minutes? Tiny dragon heartbeats? timeoutMs says “milliseconds.” No guessing. No pain.
Prefix vs Suffix: The Quick Difference
The difference is position.
- Prefix: goes before the main word.
- Suffix: goes after the main word.
That sounds almost too easy. The catch is that programming likes making easy things weird.
For example, ++x and x++ look almost the same. They are not the same in many languages, such as JavaScript, C, C++, and Java.
let x = 5;
let y = ++x;
Here, ++x is a prefix increment. It increases x first. Then it gives the new value to y. So x is 6, and y is 6.
let x = 5;
let y = x++;
Here, x++ is a suffix, or more often called postfix increment. It gives the old value to y first. Then it increases x. So x is 6, but y is 5.
It drives me a little nuts that one tiny symbol can cause a bug that takes 18 minutes to find. But that is programming. Tiny marks. Big drama.
Common Prefixes in Programming Names
Good prefixes make code easier to scan. They act like little signs.
is: usually means true or false. Example:isOpen.has: checks if something exists. Example:hasItems.can: checks permission or ability. Example:canEdit.get: returns a value. Example:getEmail.set: changes a value. Example:setEmail.on: often handles an event. Example:onClick.
These are not magic rules. They are habits. Good habits save time.
For example, when you see isDeleted, you expect a boolean. That means true or false. If isDeleted returns a full user object, people will sigh loudly. Maybe at their desk. Maybe into a snack.
Common Suffixes in Programming Names
Suffixes often help with type or purpose. They answer the question, “What kind of thing is this?”
List: many items. Example:taskList.Map: key and value pairs. Example:userMap.Id: an identifier. Example:orderId.Url: a web address. Example:imageUrl.Count: a number of items. Example:errorCount.Ms: milliseconds. Example:delayMs.
These endings reduce confusion. users is okay. userList is clearer in many codebases. delay is okay. delayMs is better if units matter.
Prefix Operators vs Suffix Operators
Some programming terms use prefix and suffix for operators, not names.
An operator is a symbol that does work. Think of +, -, !, or ++.
A prefix operator appears before the value.
!isLoggedIn
++score
-type
A suffix or postfix operator appears after the value.
score++
items?
The exact meaning depends on the language. Some languages use ?, !, or other marks in special ways. Always check the language rules. Yes, I know. Reading docs is not always fun. But neither is fixing a bug at 4:57 p.m.
Prefix Notation, Infix Notation, and Postfix Notation
Programming also borrows terms from math.
Most people write math in infix form. The operator sits in the middle.
2 + 3
In prefix notation, the operator comes first.
+ 2 3
In postfix notation, the operator comes last.
2 3 +
Postfix is another word you will often see instead of suffix. In operator talk, postfix is the more common term. It means “after the value.”
This may look odd. But computers can process prefix and postfix forms neatly. Some calculators and stack-based languages use postfix ideas.
File Suffixes Are Everywhere
File names also use suffixes. You may know them as extensions.
app.jsis usually a JavaScript file.style.cssis a CSS file.index.htmlis an HTML file.data.jsonis a JSON file.
The suffix tells tools what kind of file they are handling. A code editor may color .js files one way and .css files another way. A build tool may treat them very differently.
Changing a file suffix can break things fast. Rename main.css to main.txt, and your lovely page styling may vanish. Very rude. Very common.
When Prefixes Go Bad
Prefixes are helpful until people overdo them.
Old code sometimes uses prefixes for types, like strName for a string or intAge for an integer. This style is often called Hungarian notation.
It can help in some systems. But it can also get stale. If strAge becomes a number later, the name lies. Lying names are worse than vague names.
Use prefixes when they add meaning. Skip them when they add clutter.
When Suffixes Go Bad
Suffixes can also become noisy.
userDataObject is not very useful. Almost everything in code is data or an object somewhere. The suffix adds bulk but not meaning.
Better names are more specific:
userProfileuserSettingsuserPermissions
Each one tells a clearer story. That is the goal. Code is read more often than it is written.
Simple Rules You Can Actually Use
Here are practical naming rules:
- Use
is,has, orcanfor booleans. - Use
getfor functions that return values. - Use
setfor functions that change values. - Use suffixes like
List,Map,Id, andMswhen they clarify type or unit. - Avoid prefixes and suffixes that repeat obvious facts.
- Keep names honest after code changes.
A Tiny Real World Scenario
Imagine a team has a checkout page with 40 variables. Some are named price, time, and user. That sounds fine until bugs appear.
Which price? Which time? Which user?
Now rename them:
cartTotaldiscountAmountsessionTimeoutMscurrentUserId
Suddenly, the code feels less foggy. A new developer can guess more without opening five extra files. If that saves even 5 minutes per bug check, across 12 checks a week, that is 60 minutes back. One full hour. Enough time for coffee and one peaceful thought.
The Main Idea
Prefixes and suffixes are tiny clues. A prefix sits at the front. A suffix sits at the end. In programming, they help explain names, types, units, actions, files, and operators.
Use them with care. Keep them clear. Keep them honest. Your future self will thank you, probably while fixing one less silly bug.



