LESSON 01 / 9·2 min readIntermediate

How do I check correctness?

01 Understand02 Recall03 Prepare

Understand the concept

Correctness means the implementation satisfies the required behavior for valid, invalid and concurrent inputs. A review begins with the intended rule, because readable or compilable code can still implement the wrong rule. Trace the inputs, state changes and outputs before judging style.

Important ideas

  • Compare code with the required behavior, including empty and invalid inputs.

  • Trace state changes and check return values.

  • Ask whether concurrent requests can break the rule.

  • Write down an invariant such as “stock cannot become negative” and look for a path that violates it.

PAUSE & RECALL

Can you explain it without the notes?

How do I check correctness?

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

Correctness means the implementation satisfies the required behavior for valid, invalid and concurrent inputs. A review begins with the intended rule, because readable or compilable code can still implement the wrong rule. Trace the inputs, state changes and outputs before judging style.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

  • Explain the failing input or interleaving clearly enough that another developer can reproduce the problem.
Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: How do I check security?

Adapted from 11_AI_CODE_REVIEW.md · “How do I check correctness?”. Examples are study fragments; framework behavior can depend on your version.