liveBook · Manning

Predictability

As explained in API Design Patterns

Predictability is the property of a system or naming scheme whose meanings and behavior can be reliably inferred from established patterns.

Predictability lets API users infer unfamiliar meanings and behavior from patterns they already understand. Consistent names and methods reduce research, prevent surprises, and make APIs faster to learn. section 1.4.4 section 7.0

Design for predictability with these practical rules:

  • Use the same name for the same concept: call message content text everywhere rather than mixing text, inputText, and content. section 1.4.4 section 3.2.3
  • Keep names general enough for legitimate future variation, but impose explicit language and syntax rules to prevent arbitrary alternatives. section 3.3
  • Apply standard methods consistently across resources; define edge behavior, errors, and authorization semantics instead of leaving them ambiguous. section 7.0 section 7.2

One concept, one name

A message handler checks message.topic before calling PurgeTopic with messagingTopic. Because the two names appear to represent different concepts, users must stop and investigate instead of safely inferring their meaning. Renaming the request field to topic restores the expected pattern. section 3.2.3

Listing 3.1 Example frustrating code due to inconsistent naming
function handleMessage(message: Message): void { {
  if (message.topic === "budget.purge") {    #1    
    client.PurgeTopic({
      messagingTopic: "budget.update"       #2
    });
  }
}

Inspect the inconsistent topic and messagingTopic example to see how a small naming mismatch disrupts API reasoning. section 3.2.3

Predictability also depends on behavior, not only vocabulary. Standard Get, List, Create, Update, Delete, and Replace methods need shared semantics; otherwise identical actions become different puzzles on different resources. section 7.0 section 7.2

How API Design Patterns covers it

How deep it goes
Explains naming patterns, generality trade-offs, standard methods, and error ambiguities, but stops short of complete method specifications.
Examples
Uses text and DetectLanguage, topic and messagingTopic, standard resource methods, and delete responses as concrete examples.
What you can do after
Evaluate API designs for consistent terminology, reusable method behavior, and explicit edge-case semantics.
How it connects
Connects API naming with standard methods, resource identification, authorization, and HTTP status codes.

Also explained in

Compare how 2 books explain predictability →

Related concepts

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