Rules in Naming Variables PDF

Document Details

CureAllNobelium

Uploaded by CureAllNobelium

Quezon City Science High School

Tags

programming variables naming conventions best practices

Summary

This document outlines rules for naming variables in programming. It emphasizes the importance of clear, concise names that reflect the variable's purpose, avoiding special characters and duplicate names. The document also highlights the significance of using descriptive variable names for better code readability and maintainability.

Full Transcript

Rules in Naming Variable: 1. It must begin with a letter or an alphabet and may be followed by combinations of alphanumeric characters. 2. There should be no special character like @, &, $, # and period (.). 3. It must be unique. You can't repeat names within the same level of scope. For example, yo...

Rules in Naming Variable: 1. It must begin with a letter or an alphabet and may be followed by combinations of alphanumeric characters. 2. There should be no special character like @, &, $, # and period (.). 3. It must be unique. You can't repeat names within the same level of scope. For example, you can't declare two variables named age within the same procedure. However, you can declare a private variable named age and a procedure-level variable named age within the same module. 4. The name of the variable should be indicative of the value it holds. 5. Avoid using confusing letters and numbers such as Zero and letter O. 6. Use underscore _ in replacement of space. 7. Lessen the number of characters of your variable. The shorter the variable, the better and more efficient the program will be so Variable names can’t exceed 256 characters in length. 8. In most cases, uppercase and lowercase letters are read differently. A and a may hold different data. 9. Variable names must not be a reserved word. Generally, you shouldn't use any names that are the same as the function, statement, method, and intrinsic constant names used in any host application

Use Quizgecko on...
Browser
Browser