liveBook · Manning

Stuttering

As explained in Go by Example

Stuttering is repetitive naming in which a package-qualified identifier redundantly repeats information already conveyed by the package name.

Stuttering is repetitive naming in which a package-qualified identifier repeats information already supplied by the package name. Prefer concise package names and exported items that read clearly together: url.Parse communicates its purpose without becoming url.ParseURL. section 2.2.1

Apply the guideline with context rather than mechanically:

  • Avoid repeating the package name when it adds no understanding; link.Shortener is preferable to link.LinkShortener. section 8.1
  • Accept stuttering when removing it would make an identifier confusing or too generic inside its package; link.Link, url.URL, time.Time, and list.List are valid examples. section 8.1 section 2.2.1
  • Use documentation for additional detail instead of lengthening an otherwise clear identifier. section 8.1

A readable package-qualified name

uri, err := url.Parse("https://github.com/inancgumus") reads naturally because the package name supplies the URL context. Naming the function ParseURL would produce the repetitive form url.ParseURL. section 2.2.1

uri, err := url.Parse("https://github.com/inancgumus")

Inspect the complete url.Parse example showing a concise package-qualified identifier in use. section 2.2.1

How Go by Example covers it

How deep it goes
Explains the naming rule through contrasting identifiers and justified exceptions rather than prescribing a strict prohibition.
Examples
Uses url.Parse, url.ParseURL, link.Link, link.Shortener, url.URL, time.Time, and list.List.
What it assumes
Assumes familiarity with Go packages and exported identifiers while clarifying their interaction in qualified names.
What you can do after
Apply concise package-qualified naming while recognizing when repetition preserves clarity.
How it connects
Connects package names, exported identifiers, documentation, clarity, and maintainability.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Go by Example. The section links point to the parts of the book it draws on.