Code review: reading a change you did not write · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.
En anglais

Reading someone else's diff

Computing · Software Engineering · ages 18-20
Name ______________________   Date ____________
  1. A function must return False for an empty list. Your test instead gets IndexError. Which comment identifies the required behavior problem?

    • Empty input raises IndexError instead of returning False.
    • I prefer a different private variable name in this function.
    • I prefer an extra blank line before this function's return.
  2. Which set of checks best describes a code review?

    • The author's experience and the edit date.
    • The file's length, the author's naming taste and the number of comments.
    • Required behavior, effects on other code and ease of understanding.
  3. Renaming a function used by other code is always a personal preference and cannot break behavior.

    Circle one:   True   False

  4. A search function now returns 0 for no results, as its new requirement says. A caller still tries to count the returned list. What should the reviewer inspect?

    • Callers that still expect the function to return a list.
    • Only tests of the function's new 0 result, ignoring callers.
    • Only the changed function's formatting, ignoring returned values.
  5. You are unsure whether a changed function handles empty input as required. Which comment checks that uncertainty?

    • Use my preferred empty-input result.
    • What happens when this function receives empty input?
    • The empty-input handling is defective, although I have not checked it.
  6. The requirement says to reject negative quantities. You reproduce a total of -6 for quantity -2. Which comment gives evidence for the required repair?

    • Permit quantity -2 and its total of -6.
    • Quantity -2 gives -6, but the requirement says to reject negative quantities.
    • Quantity -2 gives -6, so rename the total variable without changing its behavior.
  7. The request says a missing discount must give 0 and prices must stay exact. A diff also changes a price of 8.75 to 9. Its missing-discount test passes. Which pair of review checks is needed?

    • Check the missing-discount result and price precision.
    • Check names and blank lines.
    • Check indentation choices and the author's preferred naming style.
  8. You verify a crash for an input the function must accept. You also dislike a clear private variable name that follows team rules. What should lead the review?

    • Require your preferred name before reporting the verified crash.
    • Treat the crash and your optional naming preference as equally blocking.
    • Report the crash first and identify the rename as optional.
LightMySky · lightmysky.comW1-mt_Hhe1Ou709s-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Reading someone else's diff W1-mt_Hhe1Ou709s-s1

  1. Empty input raises IndexError instead of returning False. · The exception differs from the required False result. The other comments express personal preferences.
  2. Required behavior, effects on other code and ease of understanding. · Review checks requirements, effects on code using the change and clarity for future readers.
  3. False · Other code may still call the old name, so a function rename can break callers.
  4. Callers that still expect the function to return a list. · The function meets its new return-value requirement, but 0 is not the list its caller expects.
  5. What happens when this function receives empty input? · The specific question asks for the behavior you have not yet established.
  6. Quantity -2 gives -6, but the requirement says to reject negative quantities. · The useful comment connects the tested input and observed total with the requirement they violate.
  7. Check the missing-discount result and price precision. · The passing discount test addresses one requirement. Changing 8.75 to 9 violates the separate requirement to preserve exact prices.
  8. Report the crash first and identify the rename as optional. · The crash violates required behavior. The stated naming concern is a personal preference.
Worksheet · LightMySky