Naming Standards, Rules, and Keywords
Programming languages contain rules for naming classes, variables, and methods. The names you use are called identifiers. Rules are built into the programming language and differ from standards. If you violate a naming rule, your application may not run. If you violate our naming standards, your application still runs, but you are not following the Northwood Tech established naming standards, which tend to follow industry standards. Keywords are reserved words that are used by the programming language itself. You should NEVER use keywords when choosing names for your identifiers.
Naming Standards
Identifiers are a more human friendly way we keep track of data, classes, methods, and other things within our programs. For ease of maintenance and design, it is important to choose identifier names that reflect their intended purpose. This section mainly covers naming variables and named constants. We use variables to hold values that can change. We use named constants to hold values that we do not want to change. Please remember that although we have a naming standard for named constants, that standard does NOT make it unchangeable. There are language specific rules to follow in order to make the named constant unchangeable.
Please become familiar with the PL Development Standards web page. You are excepted to follow these standards when writing programs. You can always access this page from the “Handy Pages” menu item that is on all pages of this website.
Below is an overview of some concepts.
- Variables names should be a noun (think... person, place, or thing).
- Variable names should be full words instead of abbreviations. Doing so will make your code easier to read and understand.
- If your variable name is more than one “word”, camel case your variable name as follows:
- Start the variable name is a lowercase letter
- Start each subsequent word in the name with an uppercase letter
- An example is the variable
firstName
- Variable names are case-sensitive. That means phoneNumber with a lowercase ‘p’ is NOT the same as PhoneNumber with an uppercase ‘P’. Please remember this very important concept.
- Always use meaningful names that convey the purpose of the variable
- The name you choose for a named constant should be in all uppercase letters
- If your named constant is more than one word, separate each word with a underscore. An example would be
TAX_RATE - By convention, named constants are the only time you should use an underscore or all uppercase letters.
- If your named constant is more than one word, separate each word with a underscore. An example would be
Remember, the Program Logic Development Standards, which is a subset of the Northwood Tech Development Standards, mimic industry standards. Getting to know our standards will help you identify entities within a specific programming language. You can read more about Java Naming Conventions (aka standards) on the Geeks for Geeks website.
Naming Rules
Remember, naming rules are built into the programming language. If you violate a naming rule, your application may not run. So in addition to our development standards, you must also keep language specific naming rules in mind.
- Although it is “legal” in many programming languages to start an identifier name with a dollar sign or underscore, doing so violates our software development standards
- After the first character in your identifier name, it is “legal” to use letters, digits, dollar signs, or underscore characters. Keep in mind:
- Using dollar signs and digits in an identifier name is not part of the Northwood Tech Software Development Standards
- Accept for named constants, using underscores in your identifier name is not part of our standards
- Spaces are not permitted when naming identifiers. In other words, your identifier name must appear as one continuous string of characters. This is the norm for high-level languages.
Keywords
Another name for keywords is reserved words. Keywords are reserved words that are used by the programming language itself. You should NEVER use keywords when choosing names for your identifiers.
Below are some of the Java keywords that must be avoided as identifier names. Please note, this is not an exhaustive list and they are not in any particular order. You are likely to encounter some or all of these keywords within the first year of programming at Northwood Technical College. Technically true, false, and null are literals, however you still cannot use them as identifiers in your programs. Many of these keywords are not Java exclusive. Please take time to review the list of keywords below.
What You Learned
- Any identifier name must not violate naming standards, naming rules, or be a keyword of the language.
- Identifier names and keywords are case sensitive
- Variable names should be a noun
- The PL Development Standards is a subset of the Northwood Tech Software Development Standards
There were many terms used in this chapter that were not fully explained. I recommend you re-visit this chapter after reading the chapter about variables, data types, and named constants.
Test Your Knowledge - Interactive Activity
Test how well you retained what you learned by using this interactive activity. If you did not get 100% the first time, review the chapter and take it again.
What's next?
The next chapter in this unit is: Variables and Data Types.