Naming Question
-
Eddy Vluggen wrote:
the guidelines from Microsoft
So, ummm... explain why
Hashtable
andDataTable
don't agree. :suss: -
Did you used to have lots of lngFilename or blnFilenames as well? ;P
Bastard Programmer from Hell :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.
-
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.
Hi, you can use StyleCop for coding convention. there are some rules for naming in it. thanks -Amit.
-
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.
There are so many criterias.If it is a public property , make it "FileName".If it is a private member make it "_fileName" n for local variable make it "fileName".There are naming standards of c#.Go and read it.Or else install SCA for VS and make all naming warnings as errors.It will give u a good idea. :)
-
I don't mind admitting I don't know something. :)
The link Eddy refers to is out of date (though probably still applies). The latest is here. http://msdn.microsoft.com/en-us/library/ms229042.aspx[^]
Kevin
-
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 mostly go for filename as it is often interpreted in various places as a single word, e.g., http://en.wikipedia.org/wiki/Filename[^]. Sometimes it depends on what code I'm integrating with. I try to be as consistent as possible in the given context.
Kevin
-
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[^]Keith Barrow wrote:
As a second point
filename
looks odd set asidefilePath
That raises another question. I notice that sometimes an api uses filename to refer just to name of the file, other times to mean the file path. That can be confusing. I tend to adopt a convention of using path for full path and name for just the name. But there is some MS class where in one method they use name to mean just the name and in another method to mean the full path! :omg:
Kevin