General Style Deductions
Students in CSE143 are expected to demonstrate good programming style in
their homework solutions. Every homework 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.
TAs provide feedback on graded homework assignments and often give a "-0"
warning to indicate a style issue that is not being penalized but might be in
a future assignment. Because of the timing of CSE143 assignments and
duedates, students will not receive their graded homework solution prior to
submitting the next solution. As a result, TAs will spend some time in each
Thursday section discussing common style issues that they saw in the previous
homework.
The list below indicates general style issues that will not be graded as
"-0". Homework assignments are listed in reverse order because once a style
issue is included for one homework, it is included for all future homeworks.
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.
- Homework 7: 20 Questions
- class design errors:
- not using calls on this(...) to eliminate redundancy by having
one constructor call another
- data structure errors:
- not using x=change(x) when appropriate to simplify code
- poor choice of constructors for a node class (e.g., unused
constructors or just a zero-argument constructor)
- Homework 4: Evil Hangman
- method errors:
- not throwing exceptions as early as possible
- using if/else instead of if for exception code (non-exception
code should not be in an else branch)
- not decomposing complex methods into logical subtasks that each
have their own method
- data structure errors:
- excessive inefficiency when using collections (e.g., using a
foreach loop to find a value of a map when a call on get would
return the value)
- Homework 3: Assassin
- readability errors:
- nondescriptive names for fields, local variables, or methods
- control structure errors:
- bad use of loops (e.g., including an unnecessary check before a
loop that repeats the loop test)
- method errors:
- modifying a parameter to a method when such modification was not
part of the intended behavior
- miscellaneous errors:
- failure to simplify code (e.g., not factoring out common code,
extra tests or loops that aren't necessary)
- Homework 2: Guitar Hero
- commenting errors:
- implementation details included in comments for a class or its
public methods
- method errors:
- unused parameters or return value
- reimplementing methods (i.e., writing code for a commonly used
method such as Arrays.toString)
- extra public methods not in the specification
- not including either "public" or "private" for a method
declaration
- miscellaneous errors:
- redundant code
- 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)
- not using interfaces when possible to refer to variables,
parameters, and return values
- not using generic types properly (e.g., manipulating a Stack
versus a Stack<Integer>)
- use of <> operator
Homework 1: LetterInventory
- commenting errors:
- class header missing
- class header doesn't describe both student and program
- method header missing
- method header does not document return value and
post-conditions
- method header does not document important behavior including
subtle cases like an empty structure or a search value not
found
- method header does not document exceptions thrown including the
specific type of exception and the conditions under which it is
thrown
- blind copying of text from assignment writeup
- implementation details included in comments for a class or its
public methods
- readability errors:
- bad indentation
- lines over 100 characters
- no blank lines between methods
- not following Java naming conventions (e.g., not using camel
case, not using uppercase letters for constants)
- one letter field names
- control structure errors:
- bad Boolean Zen
- bad use of if/else (e.g., empty branch, if/if instead of if/else,
poor factoring, unnecessary tests)
- data structure errors:
- extra data structures that aren't necessary
- bad usage of arrays (e.g., funky/incorrect indexing/usage)
- class design errors:
- extraneous data fields
- static fields
- incorrect constant declaration (e.g., not final, not static)
- initializing data fields outside of a constructor
- non-private data fields
- miscellaneous errors:
- use of break, continue, try/catch, or using return from a void
method