On Meaningful Names

Karan Chawla / April 12, 2021

1 min read

Use intention revealing names — names that let the reader know explicitly the intention behind a line of code. e.g.: time_in_seconds_

Avoid disinformation — Spelling similar concepts similarly is information. Using inconsistent spellings is disinformation.

Make meaningful distinctions — Avoid noise words and redundant words. Distinguish names in such a way that the reader knows what the differences offer.

Use Pronounceable names — Because clean code is readable.

Use Searchable namesThe length of a name should correspond to the size of its scope

One difference between a smart programmer and a professional programmer is that the professional understands that clarity is king.

Classes and objects should have noun or noun phrase names like Customer, WikiPage, etc. A class name should not be a verb.

Functions should have verb or verb phrase names like postPayment, deletePage, etc. Accessors, mutators, predicates, should be named for their value and prefixed with get, set, and is etc.

Add no more context to a name than is necessary.

Subscribe to the newsletter

Get emails from me about future of technology, philosophy, and human behavior.

- subscribers