APCS Coding Conventions
Below are the coding conventions you will be held to this year. This is a living document and will be revisited as we learn more syntax. Feel free to comment if you disagree with any thing or would like to add something. For reference, Sun’s recommended code conventions can be found here.
We are trying to achieve CONSISTENCY. There is some variability allowed here as long as you are consistent. Here are the subset of Conventions you must obey to get full credit for your projects.
Naming
Names must always be descriptive of the element they represent.
Classes – nouns in mixed case with first letter of internal words capitalized
class Raster
class ImageSprite
Methods – verbs in mixed case with first letter lowercase and first letter of internal words capitalized
run();
runFast();
Variables – mixed case with first letter lowercase and first letter of internal words capitalized
int maxSize = 100;
double perCent = .25;
Class Constants - all capitalized characters and should be created at the top of the Class
public static final type SIZE = 4;
Indentation
Increase level of indentation after all opening curly braces
Stay at a single level of indentation for an entire block
Close curly braces at the same level as the corresponding opening curly brace
When continuing a line, indent one more tab than the original one
Other formatting
Header Comment: Each class must have a comment in this format:
/* Name:
Date:
Assignment:
Description blahblahb
*/
Method Description: Each new method needs to have a description comment above its declaration briefly describing its functionality.
New Line: Start a new line after every ; or }
Space between Methods: Skip exactly one line between methods
Main Placement: Main method must be at the top
Max Line Length: The maximum line length should be 100 characters for readablity. Continued lines should indent one more tab relative to their original one
(Leveraged from Ms Martin’s Coding Conventions in previous years, these are good & standard one’s)




