Chapter 7. Naming
There are only two hard things in Computer Science: cache invalidation and naming things.
Phil Karlton
7.0 Introduction
Naming is a critical aspect of software development. It directly impacts the readability, understandability, and maintainability of code. You need to choose good names for objects, classes, variables, functions, etc. Good names help reduce confusion and errors and make it easier for other developers to use, modify, and debug code. Names are irrelevant for compilers and interpreters. But writing code is a human-centric activity. Poor naming choices can lead to confusion, misunderstandings, and defects. If a name is too generic or unclear, it may not accurately reflect the purpose or behavior of the code element it represents and makes it more difficult for other developers to understand how to use or modify it, leading to errors and wasted time.
7.1 Expanding Abbreviations
Problem
You have ambiguous abbreviated names.
Solution
Use strong, sufficiently long, unambiguous, and descriptive names.
Discussion
Bad naming is a problem programmers face in most software projects, and abbreviations are contextual and ambiguous. In the past, programmers used short names because memory was scarce but now you seldom face this problem. You should avoid abbreviations in all contexts: variables, functions, modules, packages, namespaces, classes, etc.
Review the following example in standard Golang naming conventions:
package
main
import
"fmt"
type ...
Get Clean Code Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.