Name things consistently
Think about the following scenario:
- Your project is called
sales-forecast
- It lives in a Git repository hosted on GitHub called
forecast-2020
- Your conda environment is named something you copied and pasted from a tutorial, say
my_env
- Your custom source code is named
my_source
.
🤯🥹☠️
Are you going to be able to ever mentally map them to one another? Probably not, though maybe if you did put in the effort to do so, you might be able to. That said, if you work with someone else on the project, you're only going to increase the amount of mental work they need to do to keep things straight.
Now, consider a different scenario:
- Your project is called
Sales Forecast 2020
- Your Git repository is called
sales-forecast-2020
- And your custom source code package is called
sales_forecast_2020
.
Does the latter seem saner? I think so too 🙂.
What constitutes a "sane" name?
I think the following guidelines help:
- 2 words are preferred, 3 words are okay, 4 is bordering on verbose; 5 or more words is not really acceptable.
- Explicit, precise, and well-defined for a "local" scope, where "local" depends on your definition.
I would add that learning how to name things precisely in English, and hence provide precise variable names in Python code, is a great way for English second language speakers to practice and expand their language vocabulary.