Hasty Briefsbeta

Bilingual

Index, Count, Offset, Size

7 days ago
  • #programming
  • #naming-conventions
  • #bug-prevention
  • The article discusses the challenge of naming variables in programming to minimize bugs, especially in indexing and off-by-one errors.
  • It introduces a naming convention used at TigerBeetle: 'count' for the number of items, 'index' for pointing to a particular item, 'size' for the count of bytes, and 'offset' as the bytewise counterpart of 'index'.
  • The convention helps in making wrong combinations of variables stand out, enhancing code readability and reducing errors.
  • The article also mentions the importance of consistency in naming, such as using 'big endian naming' and ensuring dual names have the same length for alignment and bug detection.
  • It concludes by emphasizing that while a naming convention alone isn't a silver bullet, layering such defenses can exponentially decrease the probability of bugs.