CSE 9A Fall 1996 Style Rules This is just a quick rough guide. When in doubt or a point is not covered in these rules follow the style used in the programs in the Savitch text. These will be added to as we go. These are for Assignment 2. Assignment 3 will add more rules. Names: All names must be meaningful. All variable names must start with a lowercase letter. All constant names must be in all caps. All class names must start with an uppercase letter. Constants: Literal constants, such as 3.18 and 45, should not appear in your program (except in very special cases). Instead you should define a named constant (with const) and use that instead. The only exceptions are very well known, very easily recognized, "round" numbers, like 100 for the centimeters in a meter. Before you use an unnamed literal constant, you should check with the instructor or TA (David Noelle) to see if it is OK. It will always be OK to use a named constant so when in doubt, name that constant. Braces there are only two or three styles of {} placement that are acceptable. For a while statement, there are only two: while (count > 0) { future_price = future_price + inflation_fraction * future_price; count--; } and while (count > 0){ future_price = future_price + inflation_fraction * future_price; count--; } are the only two acceptable styles for while. ON a while loop (or anyplace else) it is OK to omit the {} completely if there is only one statement. For an if-else, there are only three: if { do stuff; } else { do stuff; } and if { do stuff; } else { do stuff; } and if { do stuff; }else { do stuff; } are the only three acceptable styles for if-else. similarly on an if or if-else statement you can omit the {} if there is only one statement. Indenting: You must indent each level of nesting. The indenting must be 2, 3, or 4 spaces and must be the same throughout the program. 4 spaces is the suggested amount to indent. Comments: The top of the file should have a comment with the following information: Names and login names of team members Assignment number What problem it is in the text (if it is from the text) Email address for each team member Description of what the program does. The date that the file was last modified. You should need few if any other comments in Assignment 2, but if a point is unclear, then add a comment for it.