What is the correct term to refer to the path and file name?

I want to use the correct term to make my API as intuitive as possible, so when it is expected that the parameter will be the full path and file name (for example, "C: \ Users \ Max \ Documents \ MyDocument.txt"), what is the correct term?

  • filename - this will only be MyDocument.txt, right?
  • path - it will only be C: \ Users \ Max \ Documents, right?

What should I use for the parameter name? Will the "file" match the name?

I feel stupid asking about it, but I want to make sure it is right.

+7
language-agnostic parameters naming-conventions
source share
7 answers

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 Full File Name "and defines it as" a file on a computer whose exact name is fully specified so that it is unambiguous and cannot be mistaken for any other file on this system. "

+2
source share

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

In the 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 that you use.

+3
source share

The term URI is often used for this, although your example is actually not one of them. I think it will be completely clear to you if you simply use the "file path" or the "path".

For example, a Java file object uses the "path" as the parameter name for the constructor on the File object.

0
source share

Typically, the path is the full C:\Users\Max\Documents\MyDocument.txt , and part of C:\Users\Max\Documents\ usually called the base directory or simply a directory.

You will see in many code examples people write: C:\path\to\the\document.txt

0
source share

I would go with fullPath, as you said, the path will be C: \ Users \ Max \ Documents, but reading fullPath will suggest the path + file name.

0
source share

I do not think that there is one True answer, maybe some consensus, but all that we can hope for. I usually try to follow the conventions of the library I use (e.g. Cocoa, Java or PHP). If I have nothing to do, I would say:

  • File: abstract thing referenced by name: file descriptor
  • Path: a string indicating the location of the file or directory, absolute or relative: /Users/Max/Documents/FooBar , ../Sibling/Zardoz
  • Name: file or directory name, without location: FooBar , Zardoz , Documents
-one
source share

A simple solution that you may already have considered tells the consumer API what is expected in the XML documentation, which will also appear in Visual Studio intellisense if you compile the assembly with the 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) { } 
-one
source share

All Articles