views:

267

answers:

6

For what I know, it's best practice to name files like this: file_name.txt - or if you want to file-name.txt.

Now some people seem to like to name their files fileName.txt or FILENAME.TXT or "File Name.txt" - how do explain them that it's not a good idea? Why exactly is the aforementioned file naming best practice?

I only vaguely know some file systems have trouble with uppercase, and that URIs should be lowercase only to avoid confusion (Wikipedia does have uppercase characters in their URLs though e.g. http://en.wikipedia.org/wiki/Sinusitis )

W.

+2  A: 

Well, a problem with uppercase letters would be that some filesystems (like NTFS) ignore them and treat filename.txt and FILENAME.TXT as the same file, whereas other filesystems (ext for example, I think) thinks of these as 2 different files.

So, if you have some reference to a file that you called file.txt, and the reference points to the file File.txt, then on NTFS this would be no problem, but if you copy the files to a file system like ext, the reference would fail because the filesystem thinks there is no such file as File.txt.

Because of this, it's best practice to always use lowercase letters.

Maximilian Mayerl
Unless, of course, you're programming in Visual Studio and the name of the class and the name of the file go hand-in-hand and the framework design guidelines say that class names should start with an uppercase letter and be in camel-case. Honestly, I don't know of any such "best practice" that is universal. It's all context dependent.
tvanfosson
Of course, if you are sure that you will never copy the files to any filesystem other then for example windows file systems, you are fine with uppercase letters. I use them myself (in VS, just as you said). But what I wrote is the reasoning behind this "best practice".
Maximilian Mayerl
I'd love to see an example of where this might happen "if you have some reference to a file that you called file.txt, and the reference points to the file File.txt", especially in today's drag-and-drop user environment.
Lazarus
A: 

The POSIX standard (IEEE Std 1003.1) defines a character set for portable filenames (however, it does indicate that case should be preserved). At least it removes spaces and other "special" characters from the set.

The set is, from memory: [a-zA-Z0-9_-.]

Jon Ward
A: 

Maximilian has good point!

It's best practice to avoid the possibility of confusion (dissimilar names treated as identical) but I work in a place where various systems are used, from DOS to Windows to Unix, and I have never been able to convince those users that the CAPS LOCK should be avoided.

Since I mostly deal with Unix-like systems, I would dearly love to legislate for lower-case everywhere, but I'm beating my head against a brick wall.

Best Practice is an alien concept to most computer users.

If your colleagues are programmers you might stand a chance.

pavium
Surely hard to convince the DOS users to not use CAPS, I don't think they have an option... should your standard then be all caps and 8.3 notation?
Lazarus
I think Wolfr really meant best practice for programmers (since this is SO) and maybe he meant Windows programmers, but he asked about creating files, and a heck of a lot of non-programmers create files these days, using (in my experience) DOS, Windows *and* Unix. I can't see a way to impress these users with any concept of 'best practice'. It's mixed environments like this where best practice becomes blurred.
pavium
I'm a front end developer and designer. My colleagues are designers and developers and are not clueless, I was looking for an argument that wasn't empty. I can't say "only use az09-_ in your filesnames" without specifying a good reason.At one point I wrote up a company rule that every class and ID in HTML/CSS should be written camelCase for consistency across sites, and some people started doing that in their filenames too. (which wasn't my intention)Most people work on Macs here, a few on windows. The issue was that sometimes a file could not be found due to case differences.Thanks all!
Wolfr
+1  A: 

The argument that all lower case is the 'best practice' would easily vindicate using all CAPS as best practice as well.

I think it's fair to say that the vast majority of users don't operate in multi-platform environments, or at least not in a manner that's likely to cause them to encounter the issue raised here.

The issue is really only a problem when copying from a case-sensitive environment to a non-case sensitive one where you have multiple variants of a filename within a single directory (somewhat unlikely). The idea that a file reference would be the crux for me falls down when you consider that directory structure variation is likely to be an equal issue in such situations.

At the end of the day, in a corporate environment, there should be a published standard for such things that everyone is at least encouraged to follow, that for me is best practice. Those that follow the standard don't only have themselves to blame.

Lazarus
A: 

If your colleagues are clueless, then you might be able to convince them that ALL CAPS takes more storage, uses more power, and is more likely to get deleted.

However, if they are as knowledgeable about filenames as you, there's little you can to get them to side with your preference.

In this situation, I like to take the absurdist approach, to help my colleagues want to have a reasonable approach. I suggest you start naming files with CrAzY cAsE. After a few directories of CrAzY cAsE, your ALL CAPS colleagues and your lowercase colleagues will come to you and ask you to stop. You then say, Well we should have standard naming convention, I'm impartial to the results if we can agree on a standard. Then nudge the discussion toward lower case names, and declare that as the binding compromise.

brianegge
A: 

I recommend a cricket bat.

Blank Xavier