fileName or filename?

2022-09-02 00:39:16

Possible Duplicate:
Parameter naming: filename or fileName?

What do you use - filename or fileName? The classes in the JDK use a lower case 'n', e.g. FilenameFilter, so, for consistency, I do too. But the correct way, I believe, should be fileName (as in C#).


答案 1

I'd base that decision on the surrounding identifiers.

If is the only identifier regarding files in its context, I'd stay with that.filename

Example:

public void load(String filename) { ... }

But as soon as you have other file attributes I'd consider using this:

private String fileName;
private long fileSize
private DateTime fileAge;

答案 2

my dictionary says "filename" so i'd keep using a lowercase "n": http://dict.leo.org/?search=filename