Magic Number

Noun · Slang & Abbreviations

Definitions

  1. A hardcoded numeric literal in code whose meaning is not obvious. 'if (retries > 7)' — why 7? Name it: MAX_RETRIES = 7. Magic numbers are code smells that make future developers (including yourself in 6 months) curse your name.

    In plain English: A mysterious number sitting in code with no explanation of what it means or why that specific value was chosen.

Related Terms