When transitioning from a casual computer user to an IT professional, one of the first habits to correct is how files and directories are named. While operating systems try to be user-friendly, improper naming conventions can cause significant issues in coding, command-line operations, and server management. Below are the five essential rules for professional file naming.
1. Eliminate Spaces
Spaces in file names might look clean to the human eye, but they complicate technical workflows. In command-line interfaces, a space is often interpreted as a separator between commands or arguments, requiring the use of escape characters or quotation marks to function correctly. Similarly, spaces are invalid in URLs, often converting to messy “%20” characters. Instead of spaces, professionals use specific casing or separators:
- Underscores (snake_case):
my_project_file.py - Hyphens (kebab-case):
my-project-file.py(Note: some languages treat hyphens as subtraction operators). - CamelCase:
myProjectFile.py(First letter lowercase). - PascalCase:
MyProjectFile.py(First letter capitalized).
2. Avoid Special Characters
Stick to the safest characters: A-Z, 0-9, and the underscore. While modern systems can handle various symbols, special characters like exclamation points, dollar signs, and ampersands can trigger unintended behaviors in scripts and software tools. The dot character (.) should be reserved exclusively for file extensions (e.g., .py) or hidden system files.
3. Be Descriptively Concise
Naming is a balance between clarity and brevity. File names should be descriptive enough to explain the file’s content to a coworker (or your future self) without opening it, but short enough to type easily without frustration. Avoid vague names like file1.txt, but also avoid overly verbose sentences.
4. Respect Case Sensitivity
Beginners often overlook that File.txt and file.txt are treated as different files by many operating systems (particularly Linux/Unix servers). To prevent confusion and errors when moving files between different environments, assume case sensitivity always matters. The safest and most common convention in server environments is to use all lowercase letters.
5. Use ISO Date Formats for Sorting
When including dates in file names (e.g., for logs or backups), relying on formats like “Month-Day-Year” results in incorrect sorting because computers sort characters from left to right. To ensure files appear in chronological order, always use the ISO standard format: YYYY-MM-DD (Year-Month-Day). This ensures that a file from 2024 appears after a file from 2023 regardless of the month.
Bonus: Consistency is Key
Once a naming convention is chosen, stick to it. Professional development teams often use style guides to dictate these rules. Inconsistency not only looks unprofessional but disrupts workflow and annoys peers.
Mentoring question
If a new developer joined your team today, would they be able to understand the purpose and organization of your files simply by reading their names, or would they find inconsistent patterns and ambiguous titles?
Source: https://youtube.com/watch?v=pjnSE99-cz0&is=YuY14tz1K93x0VCy
Leave a Reply