3 Naming

 

This chapter covers

  • Why we should bother caring about names
  • What makes some better than others
  • How to make choices about language, grammar, and syntax
  • How context influences the meaning of a name
  • A case study of what can happen with poor name choices

Whether we like it or not, names follow us everywhere. In every software system we build, and every API we design or use, there are names hiding around each corner that will live far longer than we ever intend them to. Because of this, it should seem obvious that it’s important to choose great names (even if we don’t always give our naming choices as much thought as we should). In this chapter, we’ll explore the different components of an API that we’ll have to name, some strategies we can employ to choose good names, the high-level attributes that distinguish good names from bad ones, and finally some general principles to help guide us when making tough naming decisions that we’ll inevitably run into.

3.1 Why do names matter?

3.2 What makes a name “good”?

3.2.1 Expressive

3.2.2 Simple

3.2.3 Predictable

3.3 Language, grammar, and syntax

3.3.1 Language

3.3.2 Grammar

3.3.3 Syntax

3.4 Context

3.5 Data types and units

3.6 Case study: What happens when you choose bad names?

3.7 Exercises

Summary