Naming Question
-
I prefer
filename
. However, in public APIs, I name propertiesFileName
andUserName
in keeping with Microsoft's convention. /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
In this case,
path
. This is in keeping with Microsoft's convention for naming files.Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
now do you use "filepath" or "filePath"? :confused:
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
-
Properties would start with a capital-letter, but a variable wouldn't :) Locals are usually Pascal-cased.
Bastard Programmer from Hell :suss:
Yes, I know. I was referring to the case of the letters within the identifier. I thought that was blindingly obvious. :) /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Yes, I know. I was referring to the case of the letters within the identifier. I thought that was blindingly obvious. :) /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
When naming variables, do you use "filename" or "fileName"? I find myself going back and forth, and can't get my mind to pick one and stick with it.
-
now do you use "filepath" or "filePath"? :confused:
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
LOL!
-
In this case,
path
. This is in keeping with Microsoft's convention for naming files.Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
What if it doesn't have a path, just the name of the file itself?
-
With programmers, nothing is "obvious" unless it's in the specs. I assumed that everyone would simply follow the guidelines from Microsoft, making this a non-question.
Bastard Programmer from Hell :suss:
Probably a dumb question, but where can I find the Microsoft guidelines for this? :(
-
Probably a dumb question, but where can I find the Microsoft guidelines for this? :(
-
Mostly
filename
But that's because I had to forcibly break myself of usingstrFilename
...Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
What if it doesn't have a path, just the name of the file itself?
-
Caydence wrote:
Probably a dumb question
It's not, but I'm glad to see that you rather make a "dumb" impression and get an answer than look intelligent and move on without one. Here they are[^] :)
Bastard Programmer from Hell :suss:
I don't mind admitting I don't know something. :)
-
What if it doesn't have a path, just the name of the file itself?
Then just filename. It's a standard concatenation and MS is fairly clear on naming for contractions like this; all lower case.
Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
With programmers, nothing is "obvious" unless it's in the specs. I assumed that everyone would simply follow the guidelines from Microsoft, making this a non-question.
Bastard Programmer from Hell :suss:
Eddy Vluggen wrote:
the guidelines from Microsoft
So, ummm... explain why
Hashtable
andDataTable
don't agree. :suss: -
When naming variables, do you use "filename" or "fileName"? I find myself going back and forth, and can't get my mind to pick one and stick with it.
For a (local) variable or a private field I use the former; otherwise "FileName". Camel case is only for use with Hungarian; and Hungarian is to be avoided. X|
-
Eddy Vluggen wrote:
the guidelines from Microsoft
So, ummm... explain why
Hashtable
andDataTable
don't agree. :suss: -
Probably a dumb question, but where can I find the Microsoft guidelines for this? :(
VS' Code Analysis' built-in dictionary checks your identifiers for spelling, grammatical case and other naming conventions of the .NET Framework guidelines. It's a great a way to gets started, and it's easy to modify/override spellings and naming conventions where necessary. /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
When naming variables, do you use "filename" or "fileName"? I find myself going back and forth, and can't get my mind to pick one and stick with it.
-
When naming variables, do you use "filename" or "fileName"? I find myself going back and forth, and can't get my mind to pick one and stick with it.
I personally prefer
filename
just as other people have stated, it is easy to read. Arguably it is becoming part of the language as a single word, I tend to think of filename as a more specific concept than name of a file that the version with the space implies. As an aside some dictionaries seem to agree .http://dictionary.reference.com/browse/filename[^]. FXCop disagrees and insists onfileName
(see this blog post/[^]), and consistency are important. I'd rather agree with the framework and I assume MS uses FXCop's default rules .I can't find an example offileName
, but I'm 75% sure I've seen it somewhere... As a second pointfilename
looks odd set asidefilePath
. So the answer is for consistancy go forfileName
, butfilename
isn't so bad that you shouldn't use it if you find it easier to read, the important thing is to stick to one version in your code.Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
Eddy Vluggen wrote:
the guidelines from Microsoft
So, ummm... explain why
Hashtable
andDataTable
don't agree. :suss: