DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Naming Matters

Naming Matters

Keeping your code clean and understandable should always be a concern as a developer. Here are a few guidelines that can help make your code cleaner.

Abdul Azeez Idris user avatar by
Abdul Azeez Idris
·
Jun. 07, 17 · Java Zone · Opinion
Like (13)
Save
Tweet
8.73K Views

Join the DZone community and get the full member experience.

Join For Free

Everything around us has a name. I mean everything — otherwise, how would we be able to refer to them, particularly in programming? From our project name, directories, variables, and more, a name must be associated with every item, or else we lose their meaning and use.

So when you decide to work on a project, make sure you keep telling yourself that naming matters. There is more to a program than a compiler understanding what you’ve written and running the code. To create software, writing the code is one thing, maintaining the code is another. Sometimes, maintaining existing code is more difficult than creating a new one. We are afraid we may bring the project down. So, below are some tips I gathered from the book “Clean Code” about how to use good namings when writing programs.

  1. Make sure you use names that show your intentions. Names should explain what they do, why they do what they do, and how they do it.
  2. Endeavor to use names that carry single meaning. Do not use names that might carry very similar meanings to another thing.
  3. When there are differences between names, please make sure the distinction is clear.
  4. Ensure that names you use are easy to pronounce. Beyond communicating with the compiler, you want to be able to communicate with other developers about your project. So, use names that are easy to pronounce and reference.
  5. Use domain-specific namings properly. Use names that easily map to the domain in which you are working, and which also explains exactly how the naming works in that domain.
  6. Do not repeat namings. Ensure that not every variable you create is annotated with a certain prefix such that every name in your program has that name. This could lead to poor searching on your code.
  7. Endeavor to reach out more to the language you are using. Learn the vocabulary of the English language to help communicate more. The more words you know, the easier it is for you to communicate with other programmers.

Note: The tips given here are to guide you and are in no way rules written in stone. As more and more programmers become better aware of using good names, the world of programming would become easier not only to current programmers, but also to other programmers that will join the field later.

Imagine a scenario where you look at a variable name and no idea comes to your mind about why it even exists. You look lost in a sea of code without any idea where to move. But the worse part is you wrote the code yourself and there is no one around to explain exactly what your intentions were when you created that variable or that class.

It’s never too late to start. Start small. Do not run off changing every piece of code you have ever written just yet. You might be overwhelmed. Take it one step at a time.

Published at DZone with permission of Abdul Azeez Idris, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The End of the Beginning for Apache Cassandra
  • Ultra-Fast Microservices: When Microstream Meets Wildfly
  • Top 11 Cloud Platforms for Internet of Things (IoT)
  • What Is Cloud-Native Architecture?

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo