Notes-Naming Convention
CamelCase Convention
- use the camelCase convention for every identifier name you create.
- What is the camelCase convention?
- the words are joined together -- no spaces between the words
- each word after the first begins with an uppercase letter
- Examples: isVisible, firstName, getFirstName, setFinalMark
Length of identifiers
- should be short yet meaningful -- names should not be overly long
- abbreviations should be avoided
- all identifiers must start with a letter
- avoid special characters -- use letters and numbers only
Naming Variables, Fields -- Attributes
- begin with a lowercase letter
- use camelCase convention, except with CONSTANTS
- variable name should describe the data that they hold
- one character names can be used for temporary throwaway variables. i,j,k,l for integers, c, d and e for characters
Constants
- type in all uppercase letters
- use the underscore to deliminate words. i.e. MAX_NUMBER
- constants once set never change
Naming Methods, Procedures and Functions -- Actions
- use a verb
- use "set", "get" and "is" as a preface to method names to indicate the type of action performed on a specific attribute
- method name should describe the action that the method will perform
- start with a lower case letter, except the constructor method,
- in Java, the constructor method starts with a upper case letter
- in Java, a constructor method MUST have the same name as the class.
Naming Classes
- begin with an uppercase letter
- use nouns that are simple and descriptive
- use the whole word, avoid abbreviation unless the abbreviation is commonly used min, max, URL
Naming GUI elements