mvmrocks
mvmrocks

Reputation: 85

Proper File Naming

So here is a question my buddies and I have been throwing around for awhile. What is the most common way programmers name files? I know its good practice to start a file name with a letter. Also You should not use symbols like: @ $ &. But are there any other practices I should consider when naming a file?

Upvotes: 0

Views: 390

Answers (3)

Sun
Sun

Reputation: 2715

The answer to your question depends on the environment that you are programming in. Be mindful of the different environments your program may be used in. Alphanumeric is a safe bet while staying away from reserved words:

http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words

Upvotes: 1

Murtuza Kabul
Murtuza Kabul

Reputation: 6514

Most of the modern file systems allow good length of name and also support file name without extensions and some special characters such as underscore ("_"). There are few things which can be followed while naming the file in order to make it more logical and accessible.

  • File which has something to do with time or has multiple version, the name should contain the date and time. It is preferable to have it in a format which cause no confusion. i.e. FN20121214_xxx.txt.

  • Name should be indicative of the application to which the file is associated with.

  • It is possible to have spaces in the name but not preferable as it mandates special treatment in some command line utilities.

  • Should be consistent. Once you follow a particular naming convention, you should keep it following unless otherwise you have a good reason to change it.

  • Do not use multiple periods in file name (e.g. file.name.txt) as it confuses many applications.

These are very common things to do.

Further, if you want your files to be compatible with legacy systems, you should limit the file name length to 8 as many legacy systems does not allow file names longer then it.

Most of these rules are not mandatory, it is a convention which you can follow to avoid confusions and make the work easy.

I hope this is what you are looking for.

Upvotes: 1

paxdiablo
paxdiablo

Reputation: 881303

Naming a file depends entirely on the capabilities of your particular filesystem (or the "lowest common denominator" of the filesystems where you may want to transfer that file to), but you should generally follow one rule and one rule only.

The intent of the file should be clear from its name. In other words, a record of your share trading transactions should be called something like ShareTxns.ods rather than xyzzy_plugh.ods.

Upvotes: 2

Related Questions