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. This list includes common
style mistakes but does not list every possible style mistake.
For more information about style, please refer to the style guide on
the homework page.
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. 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 8: Huffman
- Homework 7: 20 Questions
- class design errors:
- data structure errors:
- not using x=change(x) when appropriate to simplify code
- poor choice of constructors when designing a node class (e.g., unused
constructors or just a zero-argument constructor)
- miscellaneous errors:
- using \n to produce more than one line of output with a single
print/println/printf
- poor choice of constructor when using a node class (e.g., setting fields immediately
after construction when they could have been set by using a
different constructor)
- Homework 6: Anagram Solver
- data structure errors:
- poor use of collections (e.g. for each looping over a Stack)
- Homework 5: Grammar Solver
- control structure errors:
- method errors:
- 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)
- miscellaneous errors:
- Homework 4: Evil Hangman
- method errors:
- 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)
- using a collection inappropriately
- miscellaneous errors:
- Homework 3: Assassin
-
commenting errors:
- 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
- commenting on a specific client of the class (e.g. AssassinMain)
- readability errors:
- control structure errors:
- method errors:
- miscellaneous errors:
Homework 2: Guitar Hero
-
commenting errors:
- implementation details included in comments for a class or its
public methods
- readability errors:
- method errors:
- class design errors:
- miscellaneous errors:
Homework 1: LetterInventory
-
commenting errors:
- class header missing or doesn't describe both student and
program
- method header missing or does not document pre and post-conditions
- method header does not describe exceptions that are thrown when
preconditions are violated, including the specific type of exception and the
conditions under which it is thrown
- method header does not document important behavior including
subtle cases like an empty structure or a search value not
found
- blind copying of text from assignment writeup
-
readability errors:
- bad indentation
- some method or constructor does not have a blank line before
it
-
control structure errors:
-
data structure errors:
-
extra data structures that aren't necessary
-
bad usage of arrays (e.g., funky/incorrect indexing/usage)
-
class design errors:
-
miscellaneous errors:
In general, once a class has been discussed, it is available for use by
students. For example, the String class and the Arrays class were covered in
the CSE142 course, so it is reasonable to assume that you can use methods
from those classes without asking permission. Student should realize,
however, that saying that you are not forbidden from using a certain
construct is not the same thing as saying that it is a good idea to use a
certain construct. We don't give advice to students about which constructs
to use in order to solve the homework assignment as this is the skill you
are working to build up. You have to use your best judgment to decide and you might lose
style points if you make a poor choice. In addition, there are some
constructs that you are not allowed to use, as described in the next
paragraph.
Forbidden features
Java has grown to be a complex language with many features. We don't have
time to teach all of these features in CSE143. We have a general rule that
students should not use "advanced" material that we have not covered in
class. In addition, we have identified several Java features that we do not
want students to use. It is not necessarily bad style to use these features, but we want
to have a level playing field for all students. For any one of these
features, we prefer that either everyone in the class knows about it and can
use it or nobody is allowed to use it. The following features should not be
used in CSE143 homework or exam solutions:
- break, continue, return from a void method
- try/catch, annotations
- Java 8 features (e.g., lambdas, streams, method references)
- Java 11 features (e.g., local variable type inference)
- toArray, clone
- StringBuilder, StringBuffer, StringJoiner, StringTokenizer, and String
methods toCharArray, join, matches
- Arrays.asList, Arrays.copyOf, Arrays.copyOfRange, Arrays.sort
- Collections.copy, Collections.sort
- LinkedHashMap
Many students find themselves wondering, "What is that feature you are
describing?" If you don't recognize it, then you're unlikely to use it, so
the best answer is, "Something that we have decided not to teach you in this
class so that we will be able to focus on the really important concepts you
need to learn."