|
As a programmer i get seriously frustrated when the code given to me for analysis or debugging is not in a proper standardised format. it always help to get the code clean and well documented.
even in cases where the person in question is a superb programmer, i am sure that he will get confused if the variables are named hapazardly.
The importance of standardisation is too much to be ignored. esp. when the work has to be done by a team and they have to share the code.
The Debugger
|
|
|
|
|
Maybe you should have a poll on the coding styles mentioned?...
Signing Off....
ByteGhost
|
|
|
|
|
|
|
I realized that,
- We'd rather have some formal coding guideline.
- My coding is quite like some (camelCasing x PascalCasing) hybrid.
I would like some links on "formal coding".
10x
:: YOU make history ::
^_^
-- modified at 6:30 Wednesday 31st August, 2005
|
|
|
|
|
normally when ever such questions come up people start using two basic points to argue about naming conventions:
"modern strongly typed languages make it safe"
"with the modern IDE's you get all the help you need"
when you have to do half your work using vi to write C code where some of the types feel a bit "lax", and mixing int's with enum's is common practice both arguments quickly loose their edge.
now and then i get told to "follow the standards", but when i ask "where are they written down" people suddenly go quiet, and drop the topic for a few days *rolls eyes* says it all really.
over the years i have read lots on this subject, and experimented with various different styles and methods. i have concluded there are no "perfect" answers, but the best advice i have ever come across on the subject is:
* try to be clear, after all, you may be maintaining the code
* try to be consistent with the rest of the file you are editing - our code varies from file to file, but if you try to be consistent then it helps reading it, and being clear later on.
* taking a slight aside, comments are good if they are updated, regardless what people say about them
just about everything else seems to be either "religious" belief, or arguments based on "this (insert tool name) program makes it so easy that you don't need to make the code and variables obvious"
zen is the art of being at one with the two'ness
|
|
|
|
|
If you write in .NET, especially in C#, you should (I may say you must) use the Common Language Specifications. For example never use underscores in the var names, and use for them the camelCaseNotation. For classes and namespaces names, you should use the PascalNotatation. Try also to do not use names that are keywords in other .NET languages.
Personally I HATE underscores and uppercase constants' names: I refuse to read things like MAX_REQUESTS or m_Val... MaxRequests and mVal are more more more clear!!!
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
Dario Solera wrote:
I refuse to read things like MAX_REQUESTS or m_Val... MaxRequests and mVal are more more more clear!!!
really ???
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Really!!!
I have to say that the IDEs help a lot, for example placing different icons for different data types, so the notation becomes less important to understand the code.
But I really hate underscores: they waste space and (in my opinion) don't make the code more readable.
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
i think you're making a problem of another thing...
underscores are not so unreadable. some people love, some support with difficulty, some "HATE", but i never heard someone that was refusing reading a word containning an underscore (you notice that i say underscore in plain text to allow you see what i write ). you might not undertood much thing of what you read this way if you jump over every words containing a '_' (oops, sorry )...
personnally, i find the m_var more useful than mVar because i see at reading it that it is a member of a class. for me (but it my convention maybe), when the first lower case letter is sticked to the identifier, it descibes the type of that identifier... mVar could represent a variable which type is a user defined one, such as a map, a matrix, and so on...
the most important is that you have your own rules, and follow them at the bottom of the letter...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Maybe I was too strong. Obviously if I have to read code written by someone and it contains stuff like m_var, I understaind it without problems. I don't *refuse* to read it!!!
Since ... I don't remember when ... I used some specific notation rules, that are comfortable to me. These rules came from my teachers, my manuals and my programming books, and fortunately I found almost always the same conventions. So, as a result, I never use underscores, and since I write only OO programs, ALL the variables are class members...
mVar was only an example. Usually I write vars like ... mousePos. I intend the first word as the data type only for UI vars, for example btnSend, frmLogin and so on...
In every case I use always the same notation.
I believe I'm a pretty good programmer regarding notations ... or not?
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
Dario Solera wrote:
I believe I'm a pretty good programmer regarding notations ... or not?
maybe, but i cannot say, i never read code of your own.
Dario Solera wrote:
since I write only OO programs, ALL the variables are class members...
oh, and what happens to local variables ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You're right but personally I like to use the same camelCase notation. Since no one, up to now, has slammed my habit, it means it is understandable.
In Italy we say: 'Le cattive abitudini sono dure a morire', that means: Bad habits die hard.
So, if you really believe I'm wrong, I say: can you tell what notation is the best? If the most people have a behavior, this does not mean that it is the best one. In both the cases.
And here comes the importance of code documentation...
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
Dario Solera wrote:
If you write in .NET, especially in C#, you should (I may say you must) use the Common Language Specifications. For example never use underscores in the var names, and use for them the camelCaseNotation.
No-no for (leading) underscores is because some languages don't support them. When you use _variables for private members, you are still CLS-safe In this case it it really only personal preference. And since private variables are hidden, I prefer easiest way to make up their names. That is, underscore + name (of coresponding property usualy). That way I have no problem with this or property called Namespace (since namespace is keyword, and nameSpace is plain ugly). Hmm yes, I spend waaay tooo much time about this issue in past
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
Hmmmm...
Do you really need to use 'this' and 'namespace' as var names?
However we discussed about private variables names.
To make my thesis (see previous posts) more convincing, I suggest you to scan the MSDN Library: for C++ articles, the 'classical' C notation is used, for all the other languages, You may say that each author uses a different notation, but all of them converge to the camelCaseNotation for vars names and PascalNotation for classes, namespaces and public members names.
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
Dario Solera wrote:
Do you really need to use 'this' and 'namespace' as var names?
I didn't mean this as variable name, but as in this.var when you have argument of same name. How would you call varible representing namespace (e.g XML namespace)? ns, nameSpace, myNamespace, xmlNamespace (this is probably the best alternative,)? All long or ugly/nondescriptive IMHO. And yes I am talking about private variable names, too...
Dario Solera wrote:
To make my thesis (see previous posts) more convincing, I suggest you to scan the MSDN Library: for C++ articles, the 'classical' C notation is used, for all the other languages, You may say that each author uses a different notation, but all of them converge to the camelCaseNotation for vars names and PascalNotation for classes, namespaces and public members names.
And I suggest you to download Rotor and see that you can find _underscore, camelCase and even m_prefix :P It is just a convention...
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
Since I used it, I would call it xmlNS.
Excuse my ignorance: what the hell is Rotor?
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
|
As far as I know the CLS has nothing to do with naming conventions -- do you have any links to the CLS that provide member naming guidelines?
|
|
|
|
|
CLS naming guidelines can be found here.
|
|
|
|
|
Yeah I know about those naming guidelines - but they're not part of the CLS spec. I was specifically asking about the CLS naming guidelines that the author of the thread mentioned, and that I didn't think existed.
|
|
|
|
|
Amen and amen. I really dislike seeing underscores everywhere; heck, Microsoft scrapped an entire language (Managed C++) partially because of its ugly double-underscore syntax in favor a new sytax without underscores. That should mean something to developers: most people hate underscore syntax. I think the only place I use underscores is in event handlers: if there's a Button called buttonCancel, I might have a Click handler called buttonCancel_Click(object, EventArgs).
I disagree with the whole m suffix to signify member variables. If I want to access a member variable, I'll use the 'this' keyword. Honestly, in these days of autocomplete and intelligent IDEs, we don't need short abbreviated names, nor do we need suffixes or naming conventions to let us know their names; unless you're using a plain text editor (in which case, I wouldn't hire you), all the necessary information is available right in front of you. For instance, Visual Studio tells me the type of the variable as it pops up in intellisense, and also tells me if its part of my class. I don't need ugly naming conventions telling me the type or in which class it resides.
I'm just glad the .NET framework designers realized the ugly all-uppercase conventions, the butt-ugly underscore conventions, the and cryptic abbreviated conventions, all of which the C & C++ languages and most libraries are plagued by, are done away with in the clean framework that is the .NET FCL.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
I agree at all!
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|
I had to vote 'Yes, and they must be adhered to'. I was the one that made the guidelines.
|
|
|
|
|
|