• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Variable Naming conventions

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Code Conventions for the Java Programming Language
 
james render
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)?
 
reply
    Bookmark Topic Watch Topic
  • New Topic