General Style Deductions
Students in CSE142 are expected to demonstrate good programming style in
their programming assignment solutions. Every programming assignment will describe specific
style requirements and expectations that students should keep in mind when
writing their solutions. This page lists general style issues that are
likely to be relevant to multiple assignments. This list includes common
style mistakes but does not list every possible style mistake.
TAs provide feedback on graded programming assignments and sometimes give a "-0"
warning to indicate a style issue that is not being penalized but might be in
a future assignment. The list below indicates general style issues that may
not be graded as "-0". Programming assignments are listed in reverse order
because once a style issue is included for one programming assignment, it is included for
all future assignments. The list is not meant to be exhaustive, although it
includes the most common style issues. Students should not ask about the
details of style grading on the message board, but can ask their TA or a TA
at the IPL to explain any of these style categories.
note: in the below list, "e.g." should be read as "for example" and "i.e." should be read as "in
other words"
Mar 4, 2020 11:15 AM
Assignment 8
- control structure issues:
- bad use of
if/else (e.g., empty branch, unnecessary tests,
redundant branches that can be combined with logical or)
- class design issues:
- initializing non-
final data fields outside of a constructor
- non-
private data fields
Feb 26, 2020 11:15 AM
Assignment 7
- method issues:
- unnecessary return from a method
- data structure issues:
- extra data structures that aren't necessary
- bad usage of arrays (e.g., funky/incorrect indexing/usage)
Feb 19, 2020 11:15 AM
Assignment 6
Feb 5, 2020 11:15 AM
Assignment 5
- control structure issues:
- including code in a loop that should be executed once either
before or after the loop
- method issues:
- miscellaneous issues:
- unnecessarily inefficient code (e.g., constructing a new object
on every iteration of a loop when it could have been constructed
once before the loop or including an unnecessary test in a
conditional)
- using
\t instead of individual spaces to align output
Jan 29, 2020 11:15 AM
Assignment 4
- commenting issues:
- method header does not describe the action/behavior of the method
- method header does not describe the purpose of each parameter or
does not describe the meaning of the return value of a non-
void
method
- readability issues:
- lines over 100 characters
- nondescriptive variable names
- control structure issues:
- using incorrect
if/else structure
- failing to factor out redundant code in
if/else structures
- method issues:
- do-all methods (i.e. methods that contain most or all of the work that should be done in
main)
- miscellaneous issues:
- incorrect use of type (e.g.,
double instead of int, int instead
of boolean, String instead of char for a value known to be exactly
one character)
- using
\n with print/println or to produce more than one line of
output with a single printf
- not combining
print/print or print/println statements when
possible
- using
print/println/printf with the empty string ("")
- constructing more than one
Scanner for console input
Jan 22, 2020 11:15 AM
Assignment 3
- readability issues:
- not following Java naming conventions (e.g., not using camel
case, not using uppercase letters and word-separating underscores
for constants)
- not including a blank line between methods
- long lines
- method issues:
- unused parameters or passing a constant as a parameter
Jan 15, 2020 11:15 AM
Assignment 2
- readability issues:
- method header comment missing or does not adequately describe what the
method does
- bad indentation
- control structure issues:
- bad use of loops (e.g., 1 to 1 loops, including an unnecessary
check before a loop that repeats the loop test)
- method issues:
- nondescriptive method names
- class design issues:
- incorrect constant declaration (e.g., not
final, not static)
Jan 8, 2020 11:15 AM
Assignment 1
- commenting issues:
- class header missing or doesn't describe both student and
program
- readability issues:
- miscellaneous issues:
- use of
\n or advanced material (see below)
Jan 8, 2020 11:15 AM
General Rules