6.031
6.031 — Software Construction
Spring 2022

Problem Set 0 Addendum

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

For Problem Set 0, however, that expectation is stronger in one specific way: all magic numbers must also be eliminated from your beta submission.

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

Before you start revising, make sure to turn on ESLint as described at the bottom of this page, 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!

Fixing test failures

During each problem set, you will receive an alpha autograding report that shows the results of hidden tests Didit ran against your code: tests to check the correctness of your implementation, and in many cases, tests to check the correctness of your tests!

Those hidden tests remain hidden as you revise for the beta. You will not see results on those tests again until the beta autograding report.

Before you start revising, review your autograding report and write regression tests that reproduce any failures.

Using ESLint

Run npm run lint to see the ESLint output on the command line.

For more convenient ESLinting, you can install the ESLint plugin in your Visual Studio Code. Go to View → Extensions, search for the ESLint extension (by Dirk Baeumer) and install it. You should now be able to open one of your ps0 .ts files in the Visual Studio Code Editor, and see ESLint’s warnings in the Problems pane, and as orange jagged underlines in the code.