Skip to main content

Code Smell 153 - Too Long Names

Names should be long and descriptive. How Long?

Published 1 min readMarkdown
Part of seriesCode Smells
Code Smell 153 - Too Long Names

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.

About the author

  • I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.

No comments yet. Be the first to comment.

Code Smells

Part 1 of 50

In this series, we will see several symptoms and situations that make us doubt the quality of our developments. We will present possible solutions. Most are just clues. They are no hard rules.