views:

120

answers:

7

I want to use the correct term to make my API as intuitive as possible, so when a parameter is expected to be a full path and filename (ex "C:\Users\Max\Documents\MyDocument.txt") what is the correct term?

  • filename - that would just be MyDocument.txt, right?
  • path - that would just be C:\Users\Max\Documents, right?

What should I use for the parameter name? Would "file" be the appropriate name?

I feel kind of dumb asking this, but I want to make sure it's right.

A: 

A term often overused for this is URI, though your example isn't really one of those. I think you'll be perfectly clear if you just use "filepath" or "pathname."

For example, Java's file object uses "pathname" as the parameter name for the constructor on their File object.

iandisme
+1  A: 

Usually path is the full C:\Users\Max\Documents\MyDocument.txt while the C:\Users\Max\Documents\ part is usually known as the base directory or just directory.

You'll see in a lot of example code people write: C:\path\to\the\document.txt

slebetman
+4  A: 

The correct term is "Fully Qualified Name" (sometimes "FQN").

The term you should use in your API is "QualifiedName" or "QualifiedFilename"

Wikipedia has an entry for "Fully qualified file name" and defines it as "a file on a computer whose exact name is completely specified such that it is unambiguous and cannot be mistaken for any other file on that system."

David
Really? I've heard of FQDN for domain names, but never for files. Show me a piece of code in actual use somewhere that uses the term QualifiedName or QualifiedFilename.
benzado
I wonder how many programmers would balk at that because of the "Qualified" and the answer makes me sad.
iandisme
Something in the back of my head says there's a Java API call for 'getQualifiedName' but I'm not recalling which class off the top of my head.
David
Even money says that getQualifiedName referred to a class and not a file.
iandisme
Google suggests you are thinking of XML node names, when dealing with namespaces.
benzado
OK, I concur that Java's use of "Qualified Name" is with respect to classes. And certainly, "qualified" refers to XML node names and domain names. But, Wikipedia does have that entry on "Fully qualified file name" and it seems to fit the need expressed by the original question.
David
I've unaccepted the answer for now hoping for more discussion, but I think this is probably the correct answer. Wikipedia does concur with David and it does make sense. If nothing else, I think it's definitely intuitive.
Max Schmeling
+1. I've used the term fully qualified in reference to file names (as distinct from domains) for a great many years. Can't remember where I first heard it, but my programming history pre-dates the internet.
Bob Moore
@Bob what exactly do you call the parameter for fully qualified file name? qualifiedFileName like David suggests? or actually fullyQualifiedFileName?
Max Schmeling
A: 

I don't think there is One True Answer, maybe some consensus, but that's all we can hope for. I usually try to follow the conventions of the library I'm using (e.g., Cocoa, Java, or PHP). If I've got nothing to go by, I'd say:

  • File: the abstract thing being referred to by a name: the file handle
  • Path: a string indicating the location of a file or directory, either absolute or relative: /Users/Max/Documents/FooBar, ../Sibling/Zardoz
  • Name: the name of the file or directory, without location: FooBar, Zardoz, Documents
benzado
+1  A: 

I'd go with fullPath like you said path would be C:\Users\Max\Documents but reading fullPath would suggest path + filename.

slayerIQ
+4  A: 

My suggestion would be "Absolute file path" for some path pointing to a file, where as i would use "Absolute directory path" for a path pointing to a directory

In case of relative paths the change should be obvious.

If nothing else, you can always make a section in your documentation where you describe the meaning of certain terms you use.

Zuu
A: 

One easier solution you may have considered already is telling the consumer of the API what is expected in the XML documentation, which will also appear in Visual Studio intellisense if your compile the assembly with documentation, and distribute the .xml file.

/// <summary>
/// Saves the provided file to disk.
/// </summary>
/// <param name="filePath">The full path, including the filename of the file.</param>
public void SaveFile(string filePath)
{

}
Chris S