6.031
6.031 — Software Construction
Fall 2020

Addendum: Addressing PS0 Code Review Comments

For all problem sets in this course, you are expected to address code review comments in your beta submission.

For PS0, however, that expectation is stronger in one specific way: if Checkstyle complained about any magic numbers in your code, you must fix them. For PS0, all magic numbers must be eliminated from your beta submission. You can’t address them by simply writing a comment saying that you disagree with Checkstyle.

This is a required part of your practice with PS0. You should apply the principles of the course in this specific way, to avoid magic numbers.

First, before you start revising, make sure to turn on Checkstyle in Eclipse so that you can see where your magic numbers are.

Then, think about how to write your code so that it is:

  • safe from bugs, so that dependencies between constants are expressed by computations as much as possible, so that a future maintainer could (for example) figure out how to scale your personal art by 2x without introducing bugs.
  • easy to understand, so that (for example) a potentially-mysterious number like 4 is instead described by a clear name like sidesOfSquare.
  • ready for change, so that (for example) if the Turtle library suddenly switched from using degrees to using radians, it won’t be hard to find the constants in your code that represent angles, and you would only need to make a small change to adapt.

If you have questions about good ways to eliminate magic numbers, please ask on Piazza or in lab hours!