I'm reading Clean Code by Robert C. Martin, and the phrase TILT inexplicably appears in some code samples. Example (it's in Java, by the way):

    public String errorMessage() {
      switch (status) {
        case ErrorCode.OK:
          // TILT - Should not get here.
          return "";
        case ErrorCode.UNEXPECTED_ARGUMENT:
          return "Unexpected argument";
        case ErrorCode.MISSING_ARGUMENT:
          return "Missing argument";

From the context, I'm guessing TILT designates a state that is unreachable and only included to satisfy the compiler (for example, in the above code, TILT appears in the ErrorCode.OK case because there shouldn't be an error message if the state is OK), but I'm not sure.

Does anybody know what TILT stands for / means?

  • 1
    Possibly related answer on gaming.stackexchange.com
    – rwong
    Jan 10, 2019 at 2:08
  • 9
    This probably refers to pinball tilt, not poker tilt.
    – Telastyn
    Jan 10, 2019 at 2:28
  • 1
    I ran into the same question reading the book, and can only guess that the author's making a pinball metaphor. Who knows? Given that he dedicates entire chapters to nomenclature and writing clear, meaningful comments, it's surprising to see this mystery phrase in his own code. One of his principles is "Don't be cute". Notably, "choose clarity over entertainment value. Cuteness in code often appears in the form of colloquialisms or slang. [...] Don't tell little culture-dependent jokes[...] Say what you mean. Mean what you say."
    – Théophile
    May 31 at 16:24

1 Answer 1


Physical pinball machines have sensors in them that detect when something outside is trying to exert too much influence the path of the ball by nudging or tilting the machine. (I say too much here because pinball has a long tradition of a a certain amount of motion being acceptable, especially when the ball gets hung up on something.) When the machine goes into the tilted state, anything that could score the player more points is disabled until the ball falls off the bottom of the table. This is usually accompanied by a "Tilt" light on the game and sometimes a warning buzzer. Think of it as the pinball equivalent of raising an exception.

Martin's metaphor is strained because ErrorCode.OK is, presumably, a valid status and not something that tries to force the function into doing something it shouldn't. In other words, that input isn't trying to get the function to return the error message for a missing argument.

The rest of this doesn't answer your question, but it may give you reason to read the rest of the book with a critical eye. I don't have access to the book to see if the text surrounding that example does any hand-waving, but if not, the method does things that don't live up to the title :

First is that it doesn't treat presumably-invalid input or state as an exceptional condition and complain about it. If the method's documentation says it should only be called when the object's status is in an error state, it's clearly a logic problem in the calling code that needs to be corrected.

Second is that it returns a string that's just as valid as any of the others but effectively serves as a magic constant. A caller wanting to know if invoking the method was a mistake will have to check the contents of the return value or blithely pass it on to the human reading it to decipher (e.g., Operation result: with no additional information).

An optional third would be that if the compiler expects full coverage of the enumerated values, using default to catch the un-covered cases is a lot more readable than having to enumerate them individually or in a group. (The filp side is that it might be better to let the compiler complain so that adding a second, non-error status would force the programmer to explicitly declare how it should be handled.)

  • 2
    I don't have my copy of Clean Code at hand, but you missed a fourth possibility: that the method is just a helper function to generate a readable error message for something like an exception object, which would make it perfectly reasonable as it is, without any "hand-waving" required.
    – Doc Brown
    Jan 10, 2019 at 6:53
  • @DocBrown That's a fair point, although the next thing to wonder would be why why an exception object allows itself to be constructed with a non-exceptional status.
    – Blrfl
    Jan 10, 2019 at 12:12
  • 2
    FYI: The classic tilt sensor was a metal pendulum that was allowed to swing freely within the confines of a metal ring. Bumping the machine would increase the swing of the pendulum, and if it made electrical contact with the ring, then you lost that ball. Not bumping the machine for a period of time would allow the swinging to die down. The pendulum was not visible to the player: You just had to learn by trial-and-error how much bumping the machine would tolerate. Jan 10, 2019 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.