Search code examples
javanaming-conventionsmember-variables

Naming convention for member variables with initials


I was wondering how someone would name the member field that began with initials as opposed to words.

public class MyClass {

    // I know this is how it is for a member field with words.
    private String myString;

    // What about this String? It is representing the term "RV Scale" which is 
    // short for "Reclose Volts Scale."
    private String RVScale;

}

I know that I could just use private String recloseVoltsScale, but I'd rather keep it RVScale. If anyone knows if its supposed to be rVScale or RVScale or something else I'd appreciate the info.

EDIT :

Also, what about a member field like this...

private int RV;

Solution

  • as per java naming convention member field should start with mixedcase so it should be rvScale and member field like RV should be like private int rv;

    Using the right letter case is the key to following a naming convention:

    Lowercase is where all the letters in a word are written without any capitalization (e.g., while, if, mypackage).

    Uppercase is where all the letters in a word are written in capitals. When there are more than two words in the name use underscores to separate them (e.g., MAX_HOURS, FIRST_DAY_OF_WEEK).

    CamelCase (also known as Upper CamelCase) is where each new word begins with a capital letter (e.g., CamelCase, CustomerAccount, PlayingCard).

    Mixed case (also known as Lower CamelCase) is the same as CamelCase except the first letter of the name is in lowercase (e.g., hasChildren, customerFirstName, customerLastName).