Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

A Practical Guide to Naming Things in Code

Choose names by meaning first, then make them clear, specific, and consistent with the conventions of the language and project.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When you ask, “How do I name this?”, start by identifying what the code represents or does. Then choose words that describe it accurately, check that another developer will understand them, and shape the name to fit the language and project. Accuracy and clarity matter more than making a name as short as possible.

A practical way to choose a name

Name selection is easier when treated as three decisions: choose the concept, choose the words that represent it, and construct the final identifier in the form your codebase expects. A study of naming describes this same progression from concepts to words to a constructed name (Naming Guidelines for Professional Programmers).

  1. Identify the concept. Write down what the variable, function, class, module, or domain term represents. For a function, focus on its observable behavior; for a value, focus on what the value means and how it is used.
  2. Choose accurate words. Use the terms that match the code’s real meaning, not merely its current implementation. A function that validates an order should not be named as though it also submits or saves it.
  3. Check for ambiguity. Ask whether a teammate could distinguish this concept from nearby ones without inspecting unrelated code or guessing.
  4. Apply local form. Follow the repository’s conventions for casing, separators, prefixes, exports, and other identifier forms.
  5. Trim only what is redundant. Remove words that add no meaning, but keep words needed to make the identifier accurate and clear.

Prioritize accuracy, clarity, then brevity

When choosing among names, use this order: accuracy first, clarity second, brevity third. Norton’s engineering guide puts it plainly: “Names should be accurate first.” It also recommends choosing the least ambiguous wording when several accurate descriptions are possible (Norton Digital Product Guidebook: Naming).

For example, if a value contains the number of unpaid invoices, unpaidInvoiceCount is more useful than n or count. If the value instead counts invoices awaiting review, calling it “unpaid” would be inaccurate even if that name were shorter. A longer name is justified when the extra words prevent a meaningful misunderstanding.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
NLP: The Essential Guide to Neuro-Linguistic Programming
  • NLP: The Essential Guide to Neuro-Linguistic Programming

Use vocabulary shared by the team

Names work best when they match the language people already use to describe the product: in tickets, discussions, documentation, and user-facing terminology. Norton advises aligning names with the shared domain vocabulary. If two teams use different words for the same concept—or the same word for different concepts—agree on the intended term before encoding it across the codebase.

This is especially important for domain concepts such as subscription, account owner, or shipment. A technically precise but unfamiliar synonym can make code harder to connect to requirements. Conversely, repeating a product term that is overloaded in the code may conceal important distinctions; clarify which meaning the identifier carries.

Choose useful specificity, not maximal detail

A name should distinguish a concept from related concepts without locking it to an incidental implementation detail. cachedCustomer may be accurate when the cache status changes how the value is used; it is misleading if callers should treat it exactly like any customer and the cache is merely an internal optimization. Similarly, a name that is only data may be too broad to explain a value’s role.

Use specificity where it changes interpretation. A function called loadReport suggests retrieval, while generateReport suggests creation; choosing between them should reflect what the function actually does. Do not add a suffix such as Info or Data just to make a name look more descriptive. If two identifiers such as ProductInfo and ProductData have no real semantic difference, the distinction is noise. The Clean Code excerpt recommends role-based names such as source and destination rather than positional names such as arg1 and arg2 (Clean Code excerpt on meaningful names).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Follow the project’s naming conventions

There is no universal casing rule for all languages and repositories. Consistent forms help readers recognize symbol types, but the conventions differ by language and by project. Check the target repository’s official style guide before adopting a casing preference from another ecosystem.

Python

PEP 8 recommends lowercase function and variable names, with words separated by underscores when that improves readability. For a reserved-keyword conflict, it recommends a trailing underscore—for example, class_—rather than an abbreviation or deliberately altered spelling.

JavaScript

Google’s JavaScript style guide ties naming to identifier type and module context. For example, its module namespace imports use lower camel case based on the module name, while named imports generally retain their original names. These are Google project conventions, not a rule that every JavaScript codebase must follow.

Framework and public API design

For framework elements and public APIs, consistency matters because developers must learn and reuse a larger surface area. Microsoft’s Framework Design Guidelines state: “Beyond consistency of form, the names of framework elements must be easily understood and convey each element’s function.” This advice is specifically about framework design; local names still need to fit their own language and repository conventions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use abbreviations only when they help readers

A useful default is to spell out words when an abbreviation makes readers stop and decode the identifier. Norton’s guide favors the whole word because abbreviations can be misunderstood. That does not make every abbreviation wrong: established domain terms and common language-specific forms may be clearer than their expansions. Judge an abbreviation by whether the intended readers recognize it consistently, not by a blanket ban or a personal preference for shorter names.

When no name seems to fit

Difficulty naming something can be a reason to inspect the concept itself. The naming guidance emphasizes accuracy and meaningful distinctions; from that, a practical diagnostic follows: check whether the concept is vague, overloaded, or combining responsibilities. This is a useful prompt, not a proven test.

  • If no concise description seems accurate, define what the value or operation includes and excludes.
  • If one name seems to require “and,” consider whether the code combines separate responsibilities or concepts.
  • If two competing names both seem right, identify the difference each is intended to communicate; if there is none, one name may be redundant.
  • If the team cannot agree on the term, reconcile the domain vocabulary before adding another synonym to the code.

What identifier research can—and cannot—tell you

A 2017 paper, Naming Guidelines for Professional Programmers, describes a prior study involving over 100 programmers. In that study, full-word identifiers improved comprehension ratings and confidence compared with single-letter identifiers. The paper also reports that words and abbreviations sometimes made no difference, so the result is qualified evidence rather than proof that spelling out every identifier always improves comprehension (PPIG 2017 paper).

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.