This document provides programming style guidelines including naming conventions, formatting, and declarations. It recommends using capitalization to distinguish class, method, and variable names. Class names should start with capital letters while variables and methods start with lowercase. Static methods should be accessed through the class name rather than an object instance. Declarations, fields, and constructors should be ordered and formatted consistently.
This document provides programming style guidelines including naming conventions, formatting, and declarations. It recommends using capitalization to distinguish class, method, and variable names. Class names should start with capital letters while variables and methods start with lowercase. Static methods should be accessed through the class name rather than an object instance. Declarations, fields, and constructors should be ordered and formatted consistently.
Begin method, local and instance variable names with small letters ..
Good choice Poor choice
Professor myClass teachSections4to8 do cs1201Professor x More Programming Style DO
DON’T int numSectors // in circle int count, size int sectorSize // in degrees
For Static methods: classMethod();
AClass.classMethod(); anObject.classMethod(); More Convention Declarations only at the beginning One per line No literals (except for -1, 0, and 1 in loops) Qualify names fully
Access static methods by class name
Use parentheses liberally
Declare public only if necessary
Declaration "fields" then "method“, Constructor
first Initialize basic type fields at declaration