All learning paths Learn See Try Make Compare two code answers fairly What this lesson is about Pick the better answer by running both against the same task, not by which one looks tidier.
Two people sent solutions for the same task. One is tidy, one is eight messy lines. Where do you start?
A Run the tidy one on your inputs, and read the messy one to see what it does. B Run both answers on the same inputs before you form any opinion. C Run each one on the inputs its own author wrote down, so both get a fair test.
Check my recall Why this matters Judging two code answers is paid work, and the usual mistake is to rank the writing instead of the result. Tidy code that returns the wrong total is worse than untidy code that returns the right one. The run settles it; reading only starts the argument.
Rank two answers to one task on evidence you produced, not on which one looks tidier.
Judging two code answers is paid work, and the usual mistake is to rank the writing instead of the result. Tidy code that returns the wrong total is worse than untidy code that returns the right one. The run settles it; reading only starts the argument.
Run both answers on the same inputs before you form any opinion. Rank on: answers the question, survives the edge inputs, is safe, can be read. Length, comments and confident naming are not evidence and decide nothing. Task Two answers total orders by city. One is tidy with comments, one is eight messy lines.
Weak approach Reads both and ranks the tidy one first, for its comments and its clear names. The other is called hard to follow, and neither answer was ever run on a file.
Stronger approach Runs both on the same file. The tidy one drops rows with an empty city. Ranks the messy one first and says why.
Why the stronger approach works Reading ranked the style. Running ranked the result, which is what the task asked for.
Try a changed situation You must rank two answers today and the laptop that holds the data is not available. What order do you judge in?
Make something yourself Take two answers to one task. Run both on the same inputs, including one edge input. Write the inputs, what each returned, your ranking, and the reason in one sentence.
Lesson 7 of 10 on Coding for evaluation work next Spot unsafe code in an answer Part 3 ends in a work sample you can send
Read the primary or official source: GitHub Docs · Reviewing proposed changes