Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: naming convention question

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question naming convention question

    I'm going to be receiving an angle from a gyroscope, an angle from a joystick, and an angle from a wheel in relation to a robot. I was going to store the data in 3 variables. my current names are "jAngle" for joystick angle, "gAngle" for gyroscope angle, and "bWAngle" for bot wheel angle. do you think these names are appropriate or if not what should I name these variables.


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: naming convention question

    They seem ok. Most of naming convention is up to the developer. Sometimes developers like to use extremely length and descriptive names in large programs to make it more readable and easier for other developers to work with. Some developers might even say: joystickAngle or I've even seen things like joystick_Angle. I would assume the latter example would be more unconventional, since I believe the consensus is that underscores should only be used with constants (and constants should be in all caps). But keep in mind that if your goal is to give a full description of a variable, you should do so in comments immediately before creating the variable, not necessarily in the variable name itself. So if you were to use a name like jAngle, make sure to leave a comment immediately before where you create the variable that simply says the variable is meant to represent the joystick angle.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: naming convention question

    See the Java Code conventions, which might help in naming.
    Code Conventions for the Java Programming Language
    Always be descriptive, as you may not know what a variable is sometime down the line if not named carefully

  4. #4
    Junior Member
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: naming convention question

    so it sounds like its ok. I'm working on a project with a team of new programmers so I wanted to make sure im teaching proper naming conventions. thanks for the help.

Similar Threads

  1. Replies: 2
    Last Post: February 19th, 2012, 07:36 AM
  2. Tic Tac Toe = Naming Winning Player & Restarting Program
    By Override in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 28th, 2010, 12:20 AM