Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variable Naming conventions

 
james render
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys!
Just wondering what people out there are doing for their variable naming.
You see I would normally prefix parameter variables with an underscore, to differentiate them from member variables.
But I vaguely recall from the sun conventions that using _ and $ is a no-no (system variables?).
So would it be okay to prefix member variables with 'm_' as I HATE using this.
What are other people doing? This is a VERY IMPORTANT point I feel
Don't think that Sun mentions anything so is it a free for all so. So maybe something that improves readability is good, as this is a key requirement.
Basically I'm looking to pinch a few ideas
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code Conventions for the Java Programming Language
 
james render
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks eugene, I've studied the conventions and was just wondering how people differentiate between member, local and parameter variables.
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should be no differentiation between member, local and parameter variables, when it comes to naming. The only exception is final static constants that should be delcared in all caps with underscores, by convention.
The best thing that you can do for clarity and quality is to use meaningful names, declare objects in the narowest scope possible, avoid extra local variables, make your methods focused, etc. In other words, refactor your code if you think it's not clear from the code which variables are what.
[ May 23, 2003: Message edited by: Eugene Kononov ]
 
Billy Tsai
Ranch Hand
Posts: 1304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so should we use String to represent all the fields in the flat file database , even include the ID and $(charge)?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic