brentwoodhigh.com

AP Central Classroom | repl.it | code.org | BlueJ.org | w3schools | Draw.io | Site Stats
Game | Food Drink | Tardy | login Submissions | Honesty | Absence Late Work |
pl1 Schedule | pl1 LogIn | pl1 Archive | pl1 Resources |
PL2 Schedule | PL2 LogIn | PL2 Archive | PL2 Resources |
APP schedule | APP LogIn | APP Archive | APP Resources |

Naming Conventions

 

 

Naming Variables, Constants, Classes, Methods, and Properties Conventions

ck Use meaningful, descriptive words as identifiers.

ck Do not use abbreviations for identifiers unless it is a well-known abbreviation.

ck With the exception of variables used as iterators for loops, do not use single character identifiers.

ck Use Pascal Casing (first character of all words are uppercase; all other characters are lowercase) for the following:

Class and type identifiers
Method names
Namespace identifiers
Property names

ck Use Camel Casing (first character of all words, except the first word, are uppercase; all other characters are lowercase) for the following:

Local variable identifiers
Object identifiers
Private data members
Parameters

ck Use all uppercase characters to name constants.

White Space and Blank Line Conventions

ck Use white space (one blank line) to separate and organize logical groups of code.

ck Place curly braces ( {} ) at the same level as the code outside the braces.

ck Place curly braces on a new line.

ck Avoid long lines of code. Lines should not exceed 80 characters.

ck If a program statement must be split over multiple lines, use indentation to improve readability.

Variable and Constant Declaration Conventions

ck Use the simplest data type that represents what it could contain. A variable to contain the number of students in a class should NOT be a floating point type (double). No such thing as a 0.37 student.

Here is a common in selecting data types. You want to calculate the average number of students per classroom in a school. The variable holding the average is going to be a double because it is unlike to be an even whole number. Variables for rooms and student should be integers because can't have a half room or half student. Don't make the rooms and students a double because it makes the math easier.

ck Try to initialize variables when they are declared.

ck Floating-point values should include at least one digit before the decimal place and one after.

ck Use the const keyword to define constant values.

ck Constant Identifiers should be in all CAPS

 

 

 

 

 

 

 

 

 

 

Updated: Monday, June 6, 2022 6:16 PM

About Us | Contact Us | ©2005 brentwoodhigh.com

>>>>