re: What are your personal stories/examples of "naming things"? VIEW POST


I am annoyed when variable names seem correct at first glance, but turn out to be not exactly what the name says. I was working on a project, where the was a variable called n_items, and you would assume, that it stored the number of items. However, it was calculated like this:

n_items = item_ids.max()

where the array of item_ids goes from 0 to the number of items minus one. So actually, n_items was the number of items minus one. Super confusing, super dangerous. I encountered that discrepancy, because I saw these kinds of loops, further below:

for elem in range(n_items + 1):

Yuck. Thanks for sharing :)

code of conduct - report abuse