Naming things 📝
Ari
”There are only two hard things in computer science: cache invalidation, and naming things.” - Phil Karlton
Its just a name. You can always change it later right? Before you know it, that kubernetes namespace you spun up last week, that you named DookieStainz4Ever1337
is now being used by your client as a testing environment, and it can’t be renamed either. Shit.
Files and Folders 📂
Based on the work of Anne Thompson of the University of Edinburgh, we can establish a couple of good rules to follow whenever we are naming folders, files, records and systems.
1. Keep file names short 🤏 (but meaningful!)
Some words add length to a file name but do not contribute towards the meaning, for example words like “the”, “a”, and “and”. Remove them, always. Long file names lead to long file paths and long URLs that are hard to remember and are error prone.
Correct ✅ | Incorrect ❌ |
---|---|
2015GlobalMarketShare | The2015_Talent_Engagement_Global_market share_report |
2. Always state dates “back to front” 📅
- When using dates in filenames, state the year first Like this: YYYY, YYYY.MM or YYYY.MM.DD
- Naming the file’s dates “back to front” means that the chronological order is maintained when the files are sorted by their names!
Correct ✅ | Incorrect ❌ |
---|---|
2015.02.Agenda | Feb2015Agenda |
2023.12.12journalEntry | 12.12.2023journalEntry |
3. Use two-digit numbers when numbering 0️⃣ 1️⃣
To maintain the numeric order when file names include numbers it is important to include the zero for numbers 0-9. This helps to retrieve the latest record number. i.e. 01, 02 … 99, unless it is a year or another number with more than two digits.
Correct ✅ | Incorrect ❌ |
---|---|
HugeBeansV01 | HugeBeans1 |
HugeBeansV05 | HugeBeans5 |
HugeBeansV11 | HugeBeans11 |
HugeBeansV10 | HugeBeans10 |
4. Use meaningful folder names 💡
Avoid using team names as the basis for folder names as your organisational structure may change; and, vague names like Misc. Folder names should indicate the folder’s contents and reflect the functions, activities and transactions that you carry out.
Correct ✅ | Incorrect ❌ |
---|---|
customers/ | misc/ |
mortgageCalculatorApi/src/types | teamScoobyApi/src/types |
5. Avoid abbreviations 💡
Don’t use initials, abbreviations and codes that are not commonly understood by your audience. If you are in doubt, just spell out the damn thing. Even though it might conflict with rule #1 mentioned above.
Correct ✅ | Incorrect ❌ |
---|---|
AntiMoneyLaundering | AML |
HugeBeansV05 | HugeBeans5 |
HugeBeansV11 | HugeBeans11 |
HugeBeansV10 | HugeBeans10 |
Naming variables and functions 🔢
”Redundancy. Inefficient by defintion - Serves as the antidote to confusion” - James Gleick
This is strongly opinionated, however I’d rather be verbose, than concise when naming functions and variables that I know is going to be read and maintained by other developers. Always focusing on reducing those WTF’s / per minute 💯
- In practice, I try to follow the rules below:
- Name a function the exact same thing as what it does
- I find that consistently doing so makes it apparent if I end up breaking my SRPs or not.
- Name a variable the exact same thing as what it contains
- Avoid using abbreviations as much as possible.
- Name a function the exact same thing as what it does
COVID-19 themed baby names 👶
When it comes to naming babies, try to avoid COVID-19 themed names.
That is it for now. See you guys next week! 🌭