Shared rules for talking

Think of it when two programs that each work cannot understand each other, or you decide how a program reports an error.

In everyday life

Radio talk between a pilot and a control tower: fixed words such as “roger” and “say again”, in a fixed order. Two fluent speakers who skip those rules can still misunderstand each other.

One case

A hotel booking server replies to every request with the status codeA number at the start of an HTTP reply that says how the request went: 200 means OK, 404 means not found, 500 means the server failed. 200, “OK”, and puts any error in the message text. The last 2 rooms go at 18:00. The next 4 guests get 200 with the text “sold out”. The phone app checks only the code and tells all 4 “Booking confirmed”.

The server said “OK” for rooms it did not have
The case, cell by cell1 cell = 1 booking request
What really happened
bookedbookedfullfullfullfull
What the app told the guest
bookedbookedbookedbookedbookedbooked
Guests told a false yes
4
Errors the app saw
0
Every reply carried the code 200. The error was hidden in the text.

Every case

Two programs can each be correct and still fail together if they read the rules differently. A protocol fixes the rules in advance, so a browser from one company can talk to a server from another. HTTP, for example, puts a code in every reply: 200 for success, 404 for “not found”, 500 for a server error. A program that bends these rules blinds every tool that relies on them.

The word

Engineers call this

protocol, HTTPThe shared rules two programs follow to talk: who speaks first, how a message is laid out, how each side says “done” or “error”. HTTPThe protocol browsers and apps use to send requests to web servers and get replies. is the protocol of the web.

Follow the shared rules exactly, including the rules for errors. Report a failure the way the protocol reports a failure, so every other program can see it.

Where this idea leads

Skills that encode it

  • principle-boundary-discipline pstackAt boundaries such as network protocols: “validate, return errors, handle defensively”, so a failure travels as a failure.