CS 115: Introduction to Computer Science 1, UAE edition

Assignment 2 Common Errors

Overall, assignment 2 showed improvement over assignment 1.

Contracts

Many students did not include type restrictions in the contracts. For example, in question 4, the bin-num is a string of length 4; a restriction of [len = 4] can be included for the parameter type string.

Tests

Many students were missing the boundary test cases:

  • Question 1: Test where the string is length 1.
  • Question 2: Test where the number of people is 0.
  • Question 3: Tests where bin-num is all 0s.

Constants

In question 2, many students did not define any constants. For instance, 10% can be defined as discount. Constants allow you to give names to numbers, thus improving readability.

Helper Functions

  • Question 2: Some students did not use helper functions and they repeated these expressions several times in their main function:
    (* num-people cost-per (- 1 discount))
    (* num-people cost-per)
    

    If you move these expressions into helper functions, then you won't have to repeat them over and over. You will still have to apply the helper functions multiple times, but the function applications will be shorter than the above expressions.

  • Question 3: Some students did not use helper functions for this question, consider create a helper function that counts the number of 1's in bin-num.
Valid XHTML 1.0 Strict Valid CSS!

Last modified on Tuesday, 09 October 2012, at 15:43 hours.

Course Supported by Instructional Support Group