引用路径和文件名的正确术语是什么?
我想使用正确的术语使我的 API 尽可能直观,因此当参数预计是完整路径和文件名(例如“C:\Users\Max\Documents\MyDocument.txt”)时,正确的是什么学期?
- 文件名 - 那就是 MyDocument.txt,对吧?
- 路径 - 那就是 C:\Users\Max\Documents,对吗?
我应该使用什么作为参数名称? “文件”是合适的名称吗?
我觉得问这个问题有点愚蠢,但我想确保它是正确的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
对于指向文件的某些路径,我的建议是“绝对文件路径”,而我将使用“绝对目录路径”作为指向目录的路径
如果是相对路径,则更改应该是明显的。
如果没有别的事,您始终可以在文档中创建一个部分来描述您使用的某些术语的含义。
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.
正确的术语是“完全限定名称”(有时为“FQN”)。
您应该在 API 中使用的术语是“QualifiedName”或“QualifiedFilename”
维基百科有一个条目“完全限定文件名”,并将其定义为“计算机上的文件,其确切名称已完全指定,因此它是明确的,不会被误认为是该系统上的任何其他文件。”
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."
经常过度使用的术语是 URI,尽管您的示例实际上并不是其中之一。我想如果您只使用“文件路径”或“路径名”,您就会非常清楚。
例如,Java 的文件对象使用“pathname”作为其 文件 对象。
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.
通常路径是完整的
C:\Users\Max\Documents\MyDocument.txt
而C:\Users\Max\Documents\
部分通常称为基目录或者只是目录。您会在很多示例代码中看到人们编写的:
C:\path\to\the\document.txt
Usually path is the full
C:\Users\Max\Documents\MyDocument.txt
while theC:\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
我会使用 fullPath 就像你说的路径是 C:\Users\Max\Documents 但读取 fullPath 会建议路径 + 文件名。
I'd go with fullPath like you said path would be C:\Users\Max\Documents but reading fullPath would suggest path + filename.
我认为没有一个正确的答案,也许有一些共识,但这就是我们所能希望的。我通常尝试遵循我正在使用的库的约定(例如,Cocoa、Java 或 PHP)。如果我没有什么可依据的,我会说:
/Users/Max/Documents/FooBar
,../Sibling/Zardoz
FooBar
, <代码>Zardoz,文档
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:
/Users/Max/Documents/FooBar
,../Sibling/Zardoz
FooBar
,Zardoz
,Documents
您可能已经考虑过的一种更简单的解决方案是告诉 API 的使用者 XML 文档中期望什么,如果您使用文档编译程序集并分发 .xml 文件,该文档也将出现在 Visual Studio 智能感知中。
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.