![]() |
|
#1
|
||||
|
||||
Re: Naming ConventionsI just posted a GID Community blog entitled: Naming Conventions.
Quote:
Please let me know what you think. This is an auto-generated message posted by GIDNetwork™ on behalf of the author. |
||||
|
#2
|
||||
|
||||
|
I wanted to add one thing to the end of Walts excellent tutorial on variable names.
#3) Be consistent. While I feel that it is important to consistantly code with the same naming convention once you find one that works for you, it is even more crucial in a project to be consistent with a naming convention. At times you will have to work on a project that has already been started with a differing naming convention than what you would choose. If you have to maintain code that is not yours, keep the naming conventions that were originally started. Last edited by admin : 23-Oct-2005 at 09:58.
Reason: Split discussion into it's own thread.
|
|
#3
|
|||
|
|||
[Discussion][Tutorial] Naming ConventionsThanks. This is helpful. I've settled in on using a single letter to indicate a variable's type. But I'm differentiating strings from char by using s for strings, which means I'm using h for short. But I really never use short anyway.
Thanks again. Last edited by admin : 23-Oct-2005 at 09:57.
Reason: Inserted link/reference to original thread
|
|
#4
|
||||
|
||||
|
These two comments should be moved...
As far as using a single letter before your variable name to denote the type... it's a good idea, however it's not very useful except in very large programs with a lot of different data types where another programmer is going to be reading your code. I've tried this method as well, and it just makes the code ugly and actually more difficult to read. There's also the problem with data types that use the same prefix. Anyway, you can do what you want, but if you're just coding simple programs right now, it's really more of a hassle to use prefixes, and it doesn't make understanding any easier. __________________
-Aaron |
|
#5
|
||||
|
||||
|
Quote:
Otherwise you learn to program with multiple styles, for small, medium, large programs. Try your way for a while and see if the prefixes help or hinder on your small programs, then decide whether to adopt or toss the idea. It certainly doesn't hurt to experiment at the beginning. __________________
Definition: Politics Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers |
|
#6
|
||||
|
||||
|
Well, honestly, I think that if you give your variables good names, prefixes are not necessary. I can always find a name that makes sense for a variable in relation to it's data-type, and I never have problems remember what the data-type of the variable is, because its name, as well as the context in which I find it, will tell me what type of variable it is without using an ugly little prefix :-P
__________________
-Aaron |
|
#7
|
||||
|
||||
|
Hmm for me, using prefix is a good way to differentiate your variables, even for small problems. If you are familiar with MFC, it actually would need you to use the prefix in naming your variable, then you could differentiate if its a classobject or a data type.
anyway, it all depends on ones preferblity. ![]() __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#8
|
||||
|
||||
|
Well, it also depends on ease of understanding. When I read microsoft's code and see a bunch of prefixes, I have no idea what they mean. It's impossible to understand someone else's prefixes (unless they're totally standardized, which they aren't, except for maybe hungarian notation) unless you have some kind of legend to use as a reference.
__________________
-Aaron |
|
#9
|
||||
|
||||
|
Quote:
Bottom line here is we are all correct. Yes you can name variables well, but that doesn't necessarily help you with the type. And using the prefix to denote the type can help obscure the 'name' of the variable. It's all a matter of style. __________________
Definition: Politics Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers |
Recent GIDBlog
Configuring iptables for Webmin Servers Index Module by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Style Guide Books?? | BobbyMurcerFan | C++ Forum | 4 | 16-May-2004 13:19 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The