aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • Engineering
  • Programming

Writing Clean Code: Naming

  • root
  • October 23, 2021
  • 5 minute read

When you start learning how to code your main focus is writing code that works correctly for the problem you are solving. Yes, code needs to work correctly and that is a good place to start learning. However, in a real work environment, you also want to ensure you write clean code.

Clean code is readable, extensible, changeable, and maintainable. These are all important qualities for a codebase to have.


Partner with aster.cloud
for your next big idea.
Let us know here.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

In many professional settings, you are not writing code in complete isolation. There are other people you work with on a team. Your teammates need to be able to easily understand the code you write. They need to understand what it does, how it works, and why it was written that way. It may also be your future self coming back to code you wrote in the past and you will also need to easily understand your code.

Code is read more than it is written. To write code we are constantly reading it. So even if readable code is harder to write we should invest time to do it instead of writing easy unreadable code. Writing clean code is an important skill for any professional developer.

In this article, we are going to learn about the importance of Naming in writing clean code.

Naming is a crucial and daily task for developers in any programming language. It can either make code very hard to understand or if done well, easy to understand.

Names are all over the software developers write. When coding, you should consider naming variables, functions, arguments, classes, packages, source files, and directories that contain those source files, etc.

Below are some popular quotes on naming in programming.

“There are only two hard things in Computer Science: cache invalidation and naming things.” – Phil Karlton

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand” — Martin fowler

Names are the smallest building block of code. Names are the basic building block of clean code. There are some recommended rules for good naming in code. Let us discuss these rules for the rest of this article.

Use intention revealing names

The names you use in your code must be clear and understandable. Choose descriptive and unambiguous names. You should focus on the principle of least surprise. Aim to write code that other people would expect and try not to surprise them with some clever complexities.

The name of a variable, function, or class, should answer all the big questions. It should tell you why it exists, what it does, and how it is used. If a name requires a comment, then the name is not intention revealing.

Below is an example of code that is not intention revealing because it requires a description comment. Just below it, you’ll find a cleaner version with better naming that does not require a description comment.

let rf = 5000 //the rental fee paid by the tenant

use the cleaner version below

let rentalFee = 5000

Classes and objects should have noun or noun phrase names

Classes and objects describe things so their names in code should be a noun or noun phrase. Names such as User, Student, Account, and ErrorLogger are good names for classes and objects. Avoid words like Manager, Processor, Data, or Info in the name of a class. A class name should not be a verb.

Methods/Functions should have verb or verb phrase names

Methods/Functions perform an action in the code so their names should be a verb or verb phrase. Names such as deleteApplication, createUser, or save are good names for methods/functions. By design, a function should have only one responsibility. If the name is anything other than a verb, then either you are naming it wrong or there are some problems in the architecture.

Make meaningful distinctions

You should try to use the same word for the same purpose across the codebase. Avoid using different but similar words to define the same concepts. For example, the three method/function calls below could mean the same thing.

FetchResult() vs GetResult() vs RetrieveResult()

Don’t use fetch, get and retrieve in the same project for the same responsibility.

Use pronounceable and searchable names

When naming things in your code use words that can be pronounced rather than using non-pronounceable words.

Below is an example of a variable name that is not easily pronounceable and a cleaner version with a more pronounceable name.

Date modymdhms;

use the cleaner version below

Date modificationTimestamp;

Replace magic numbers with named constants

When you are using some constant values define them using searchable words. It makes them more understandable to other developers.

Instead of writing code like this:

let totalLoanDays = gracePeriod + 7;

create a named constant and use it like this:

const NUMBER_OF_DAYS_IN_WEEK = 7;
let totalLoanDays = gracePeriod + NUMBER_OF_DAYS_IN_WEEK;

Don’t append type information

When you name your variables avoid appending type information to them. It should be clear from the name of the variable what data it stores and developers can infer the type from there. There is no need to mention the data type in the name.

Instead of writing code like this:

let firstNameString;
let lastNameString;

Use the cleaner version below:

let firstName;
let lastName;

Don’t Be Offensive / Don’t Be A Comedian

Remain professional in how you name things in your code. Do not be offensive or try to be a comedian by giving a variable a funny name. Remember, you are writing production code that other software developers will need to understand easily in the future. Your naming conventions should be generic and should not include any cultural slang.

Avoid writing code like this:

function killThemAll();

use the cleaner and professional version below

function deleteAllUsers();

Closing thoughts

In this article, we have explored some of the best practices for naming things in your code, and some things you should avoid doing. Naming may appear to be a small part of a software developer’s job but it is very important and can be the main difference between having a clean codebase that is a joy to work with or a complex codebase that is difficult to understand and navigate.

“One difference between a smart programmer and a professional programmer is that the professional understands that clarity is king. Professionals use their powers for good and write code that others can understand.”

You should never ignore the importance of naming practices in your codebase as bad names will become a big hurdle in future development plans. Changing the codebase at that point is unnecessary overhead and can be avoided in the very beginning by following good practices.

Read More  Unlock Real-Time Insights From Your Oracle Data In BigQuery

This article was originally published on The New Developer.


For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

root

Related Topics
  • Coding
  • Computer Science
  • Developers
  • Programming
  • writing clean code
You May Also Like
Points, Lines and a Question
View Post
  • Architecture
  • Design
  • Engineering
  • People

What Is The Point In Making Points?

  • November 26, 2025
View Post
  • Engineering
  • Software Engineering

Development gets better with Age

  • October 9, 2025
aster-cloud-sms-pexels-tim-samuel-6697306
View Post
  • Programming
  • Software

Send SMS texts with Amazon’s SNS simple notification service

  • July 1, 2025
aster-cloud-website-pexels-goumbik-574069
View Post
  • Programming
  • Software

Host a static website on AWS with Amazon S3 and Route 53

  • June 27, 2025
View Post
  • Engineering
  • Technology

Apple supercharges its tools and technologies for developers to foster creativity, innovation, and design

  • June 9, 2025
View Post
  • Engineering

Just make it scale: An Aurora DSQL story

  • May 29, 2025
View Post
  • Engineering
  • Technology

Guide: Our top four AI Hypercomputer use cases, reference architectures and tutorials

  • March 9, 2025
View Post
  • Computing
  • Engineering

Why a decades old architecture decision is impeding the power of AI computing

  • February 19, 2025

Stay Connected!
LATEST
  • 1
    Expectations vs. Reality: The AI We Thought We’d Have in 10 Years
    • June 19, 2026
  • digital-nomad-freelancer-worker-2151205464 2
    One paperwork problem – Get your Digital Nomad Visa employment documents fast from UK, EU or Singapore
    • June 16, 2026
  • 3
    Samsung Art Store Brings Art Basel to Homes Worldwide With New Curated Collection
    • June 15, 2026
  • 4
    You Do Not Need to Invest in the IPO of SpaceX, Anthropic, and OpenAI
    • June 10, 2026
  • 5
    The consequences of relying on AI for accurate news
    • June 10, 2026
  • 6
    Connecting AI agents with unstructured data using Google Cloud Storage MCP Servers
    • June 10, 2026
  • 7
    WWDC26: Apple unveils next generation of Apple Intelligence, Siri AI, powerful parental controls, and an expansive set of software improvements
    • June 8, 2026
  • 8
    IBM and Google Cloud Announce Strategic Partnership to Scale AI with Human Expertise and AI‑Powered Delivery
    • June 4, 2026
  • Data center 9
    Data Sovereignty in Spain. It’s Not Just About the Law, It’s About Efficiency
    • June 3, 2026
  • 10
    Ink vs Pixels. What you miss versus what you are actually missing.
    • June 1, 2026
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    Banks race to patch new cyber vulnerabilities, and other cybersecurity news
    • May 25, 2026
  • pope-leo-xiv-cq5dam-1500.844 2
    Pope Leo XIV to Publish First Encyclical on Artificial Intelligence and Human Dignity on 25 May
    • May 22, 2026
  • 3
    Portfolio to Clients, and is Strengthened by Ongoing Project Glasswing Work
    • May 20, 2026
  • reMarkable Paper Pure 4
    Everything The reMarkable Paper Pure Actually Does
    • May 14, 2026
  • 5
    Scaling cloud and AI: Microsoft Azure’s commitment to Europe’s digital future
    • May 11, 2026
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.