Code Smell 153 - Too Long Names

Photo by Emre Karataş on Unsplash

Code Smell 153 - Too Long Names

Names should be long and descriptive. How Long?

Maxi Contieri
·Jul 29, 2022·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Table of contents

  • Problems
  • Solutions
  • Context
  • Sample Code
  • Detection
  • Tags
  • Conclusion
  • Relations
  • More Info
  • Credits

TL;DR: Names should be long enough. No longer.

Problems

  • Readability

  • Cognitive Load

Solutions

  1. Use names related to the MAPPER

Context

We used very short names during the 50s and 60s due to space and time constraints.

This is no longer the case in modern languages.

Sometimes we get too excited.

Naming is an art and we should be cautious with it.

Sample Code

Wrong

PlanetarySystem.PlanetarySystemCentralStarCatalogEntry

// Redundant

Right

PlanetarySystem.CentralStarCatalogEntry

Detection

[X] Semi-Automatic

Our linters can warn us with too long names.

Tags

  • Bloaters

  • Naming

Conclusion

There are no hard rules on name length.

Just Heuristics.

Relations

More Info

Credits

Photo by Emre Karataş on Unsplash


Many people tend to look at programming styles and languages like religions: if you belong to one, you cannot belong to others. But this analogy is another fallacy.

Niklaus Wirth


This article is part of the CodeSmell Series.

 
Share this

Impressum

Technical Opinions are my own. I don't have the revealed truth.

Software Design is a creative activity. These are hints and not rigid rules.

I write on BackEnd Business Systems and OOP Design. My advice/experience might not suit other systems.

You can write me at info(at)maximilianocontieri.com