Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POST]: #1 Naming Things #2

Open
arienshibani opened this issue Nov 2, 2023 · 0 comments
Open

[POST]: #1 Naming Things #2

arienshibani opened this issue Nov 2, 2023 · 0 comments
Labels
published Label used for published blog posts

Comments

@arienshibani
Copy link
Owner

arienshibani commented Nov 2, 2023


title: Naming things 📝
subtitle: The hardest problem in computer science.
description: A couple of tips when it comes to naming things.
slug: naming-things
tags: [conventions, computer science, naming, things]
category: blog
image: https://www.com/blog/wp-content/uploads/2020/08/hello-world.png
date: 2023-11-02
canonical: https://niceblogg.netlify.app/

"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 The_2015_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.

COVID-19 themed baby names 👶

When it comes to naming babies, try to avoid COVID-19 themed names.

{% twitter https://twitter.com/JennaPhile/status/1245129920923217921 %}

That is it for now. See you guys next week! 🌭

@arienshibani arienshibani added the published Label used for published blog posts label Nov 2, 2023
@arienshibani arienshibani changed the title [POST #1]: Naming Things [POST]: #1 Naming Things Nov 2, 2023
@arienshibani arienshibani added featured Featured posts will be displayed on the front page and removed featured Featured posts will be displayed on the front page labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
published Label used for published blog posts
Projects
None yet
Development

No branches or pull requests

1 participant