Lessons17-18

Lessons17-18 - CSE115 Course Notes Lesson 17: Identifiers:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE115 Course Notes ©2009 C. Alphonce and A. Decker Page 45 Lesson 17: Identifiers: Rules and Conventions An identifier is a name. As a programmer, you have the freedom to choose names for various components of your programs. However, there are a few rules that you must follow when choosing identifiers. These rules that are enforced by the compiler; if we break rules that the compiler enforces then our program will simply not be translated from high-level form into low-level form. The rules for naming identifiers are pretty simple: Identifiers must begin with a letter or underscore ‘_’ (Remember: don’t include the quotes if using the underscore.) The first character of an identifier can then be followed by zero or more letters, digits, or underscores. Other than letters, digits, or underscores, no other characters can be part of an identifier. That means no spaces, or other special characters (like the ‘*’ or ‘;’). 13 Keywords 14 are not allowed to be identifiers. As long as we follow these rules, the compiler will let us name our packages anything we want. You should note that the Java language is case-sensitive. That means an upper case letter and a lower case letter are different to Java. So, the identifiers hello and Hello are distinct in Java. Therefore, it is important to watch the capitalization of words in your program. While the compiler enforces many rules, it does not regulate everything a developer does. We must keep in mind as developers of software that the code we write will read by other developers. We must therefore strive to make our code as clear and understandable as we can. For instance, when we name things we need to make sure that these names make sense in the context of the program we are trying to build. Conventions are not enforced by a compiler, but they may also impose constraints on how you write your code. Conventions are sometimes called coding standards. Coding standards are put into place to enhance readability. Coding standards ensure that all code written within an organization will have the same style regardless of who wrote it, which makes it easier to read the code and understand what it does than if everyone wrote code
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

Lessons17-18 - CSE115 Course Notes Lesson 17: Identifiers:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online