Inconsistent Names — Code Smells Catalog Skip to content

Inconsistent Names

Also known as: Use Standard Nomenclature Where Possible

Lexical Abusers Names Code Smell Within Class

The mental shortcuts that let developers navigate by pattern break when one class calls it store(), another says add(), and a third insists on put(). Same operation. Three names. Zero muscle memory.

2 min read 1 source

Overview

Human brains work in a pattern-like fashion. Starting from the first class, the concept of operation and use of each subsequent class should be generalized throughout the project, facilitating and iteratively accelerating the speed of understanding how the code works.

For this reason, once we know that one class uses the method, store(), we should expect that another class for the very same mechanic also uses the store() name for that, instead of add(), put() or place().

Causation

In a team project, members could have omitted checking the existing naming in other classes [1]. They could also intentionally choose different naming methods to distinguish classes according to the naming convention of functions.

Problems

📖
Comprehensibility

Standardized communication through names is vital for mental shortcuts.

🌊
Flow State Disruption

The developer expects a method inside a sibling class but can't find it and has to look up synonymous variations of the method he wants.

Example

1class Human:
2    def talk():
3        ...
4
5class Elf:
6    def chat():
7        ...
PYTHON

Refactoring

  • Rename Method

Sources

Browse All 56 Smells