(1) Every .java FILE must include a header comment with this format, as the first information in the file: /* AUTHOR: put your name here PROJECT: program number or topic DUE DATE: from web page SUMMARY "Blurb on the cover" that tells what the program does INPUT Keyboard, file, none, ....? What data types? BAD DATA CHECKING: if you do some, tell about it OUTPUT Tell what shows up on the screen, what is written to any files, etc. CLASS HIERARCHY Include the full hierarchy starting from the Object class for every class you define in the file. Any format is acceptable - text or diagram. ASSUMPTIONS What do you expect the user to know, to do, to NOT do, etc. */ (2) All code, comments, and output should fit on the page; i.e., they should not wrap around or be truncated. Long statements that would run off the page should be split in a logical manner and should be indented at least 3 spaces. (3) Each statement begins on a new line. (4) Identifiers must be meaningful - variable, constant, method, class names Exceptions: (1) Names that Sun uses (String [] args, Graphics g, etc.) (2) Simple for loop index (i,j, etc.) declared in the loop for (int i = 0; i < maximum; i++) (5) Java is case sensitive. Class names should start with a capital letter and use mixed case. variable and method names should start with a lower case letter and use mixed case. CONSTANTS (final variables) should be all capitals and use underscore to separate words. (6) Comment all variables, constants, methods, classes, lines of code, etc. whose meaning would not be obvious to a beginning programmer. Names like temp and button3 are not meaningful. (Often, a better name for a variable can be found in the comment. Then you don't need the comment any more!) (7) Blank lines separate logical blocks of code. (like paragraphs) (8) Comment logical blocks of code (like chapter titles in a book). (9) Left braces { must appear on a new line right under the first character of the previous line. Right braces } must line up with the corresponding left brace and have a comment telling what is ending. For example: class Hello { public static void main (String [] args) { System.out.println("hello world!!"); } // main } // Hello (10) Indent 3 spaces inside each pair of {} or each control statement. (Use a fixed width font (Monaco, Courier, etc.) so the spaces show up.) while (x < 3) x += 4; while (y > 4) { x++; y += x + z; z = y + x; } // while (11) Put a space before and after all binary operators. (12) Only one exit point in every loop. (do not use continue. break should be used only in switch statements) (13) A for loop is a contract - don't break the contract by changing the loop control variable in the body of the loop. (14) In classes, put the variables first, constructors second, other methods third, inner classes fourth, and methods with no code last. (15) Instance variables should hold information that is essential for defining an instance of the class or describing the current state of the class, or that is used in more than one method. For example, loop counters, etc. should be local to the method that needs them. (16) Anonymous classes should contain no more than 5 lines of code in only one method. Otherwise write a separate class or have some other class implement the interface (or extend the adapter in the case of event handlers).