|
|
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
|
|
|
|
|
Eddy Vluggen wrote: the guidelines from Microsoft
So, ummm... explain why Hashtable and DataTable don't agree.
|
|
|
|
|
I'm not an employee, and I didn't claim it was consistent. It is however, always a good starting place for ideas, and a good place to end discussions.
Bastard Programmer from Hell
|
|
|
|
|
That's because one is a republican and the other, a democrat.
|
|
|
|
|
Mostly filename
But that's because I had to forcibly break myself of using strFilename ...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Did you used to have lots of lngFilename or blnFilenames as well?
Bastard Programmer from Hell
|
|
|
|
|
I saw a variable declared as longAss. Ass was short for assignment no.
|
|
|
|
|
That'd be a bigAss in Sql Server types
Bastard Programmer from Hell
|
|
|
|
|
|
In this case, path . This is in keeping with Microsoft's convention for naming files.
|
|
|
|
|
now do you use "filepath" or "filePath"?
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.
|
|
|
|
|
|
What if it doesn't have a path, just the name of the file itself?
|
|
|
|
|
fileName and filenameAndPath .
Meh..
..is that with or without extension? A UNC-path, or local?
Bastard Programmer from Hell
|
|
|
|
|
Then just filename. It's a standard concatenation and MS is fairly clear on naming for contractions like this; all lower case.
|
|
|
|
|
'filename' (or 'Filename' if it's a property or 'DoSomethingWithFilename' etc) for me. I think of filename as a single composite word.
|
|
|
|
|
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.
|
|
|
|
|
variables: filename
Properties, classes, methods... : FileName
I hate constructs like sFileName or bMyBool to also indicate the type and also gVariable or _variable to indicate global or class variables, but that might be personal.
V.
|
|
|
|
|
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 on fileName (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 of fileName , but I'm 75% sure I've seen it somewhere... As a second point filename looks odd set aside filePath .
So the answer is for consistancy go for fileName , but filename 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.
|
|
|
|
|
Keith Barrow wrote: As a second point filename looks odd set aside filePath
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!
Kevin
|
|
|
|
|
|
Hi,
you can use StyleCop for coding convention. there are some rules for naming in it.
thanks
-Amit.
|
|
|
|
|
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 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
|
|
|
|