/* * Class identifiers: begin uppercase, usually a noun or noun * phrase. Second, third, etc. words have initial capital. * * method identifiers: begin lowercase, usually a verb or a * verb phrase. Second, third, words as above * * variable identifiers: spelling same as methods. Should be a * noun or noun phase. * * Goldilocks rule: variable names should be not too long, not * too short. Single letters such as i, j, k are appropriate for * a loop counter or occasionally a parameter name, because * they are used very close to where they are declared. * * In general, variable names may become longer (and possibly more * informative) the farther they are used from where they are * declared. * int numberEnrolled; * * Blank lines: * Put a blank line before a method comment, instance variable * comment, but not after. * * Constants: * public static final int STUDENT_NUMBER_LENGTH= 9; * * Indentation: * Whenever you encounter a left brace { * indent the following line 4 spaces. * When a line is so long that it's going to continue past the end * of the line in your editor, you can indent it a further * four spaces. You should indent even further if the * following line has a greater indent than the line being * wrapped. * When you encounter a right brace, * } outdent 4 spaces. * * Line B of this example is not indented enough * A if (blah1 && blah2 && * B moreBlah) { * C i= blah; * */ /** * a method comment, before you begin writing the method */ public String sayIt() { if (some Condition ThatWrapsTwice) { complicated; stuff; } } /** * Constructor for case 1 */ public Edifice() { } /** * variable declarations */ int i, j; String s, t; /** * public fields */ public String myIdentifier; /** * the sellTickets method */ public int sellTickets(int num) { ... } /** * sellTickets: subtract the number of tickets from the * total number of tickets available. */