Coding Tips #1: Name Your Maps Like You Care About Your Future Self

Let’s say you’re reading some Go code and stumble upon this: for _, transaction := range transactions { customer := customerMap[transaction.Ref] sendReportEmail(customer.Email) } At first glance, it works. But if you’re the poor soul maintaining this code, questions start flooding in: What is customerMap actually mapping? What is transaction.Ref referring to? Is it a Customer ID? A Card ID? A National ID? What does that string key even represent? You’re stuck. You can’t proceed confidently until you understand what customerMap is mapping from and to. So, what’s your next move? If you’re lucky

Apr 7, 2025 - 07:06
 0
Coding Tips #1: Name Your Maps Like You Care About Your Future Self

Let’s say you’re reading some Go code and stumble upon this:

for _, transaction := range transactions {
    customer := customerMap[transaction.Ref]
    sendReportEmail(customer.Email)
}

At first glance, it works. But if you’re the poor soul maintaining this code, questions start flooding in:

  • What is customerMap actually mapping?
  • What is transaction.Ref referring to? Is it a Customer ID? A Card ID? A National ID?
  • What does that string key even represent?

You’re stuck. You can’t proceed confidently until you understand what customerMap is mapping from and to.

So, what’s your next move?
If you’re lucky