When im naming a variable for a directory should i end the variable name with path, folder or directory.
Im writing my code in .net..
When im naming a variable for a directory should i end the variable name with path, folder or directory.
Im writing my code in .net..
I use "path" to refer to the full path of a file (directory + file name). I'd recommend "folder", "directory" or even "dir".
It doesn't matter - all are more or less synonymous and should be clearly understood in context.
The only caveat I'd say is that path could be a web location or a file, where folder and directory won't be, if that helps your decision.
There is no official coding convention for this out there. I prefer this style:
*Path (SystemPath, AppPath) for "C:\Windows\Systems32" or "file://..." or "../../bin/Debug"
*Dir (ImageDir, ThemeDir) for ("img" or "theme")
Ok, first some definitions:
C:\Temp\Foo.txt
), or a relative path (..\Temp\Foo.txt
). (I would consider the file name (Foo.txt
) to be a relative path as well).Therefore, if a variable is ambiguous, (i.e. could point to either a file or a directory, like when recursively walking through the directory tree,) I would call it FooPath
.
If your variable always points to one file, I would call it FooFile
If your variable is always the name of a directory, and never of a file, I would let this reflect by calling it FooDirectory
, or FooDir
for short.
But of course the most important rule is consistency: Choose one naming convention and stick with it. Do not call one variable FooDirectory
, the next BarDir
and the third BuzzFolder
.