Explain a draft before you trust it · 3 Lessons
English

Understand and Review AI Code

Module 1 – Explain a draft before you trust it

Page 1 of 3 · About 15 minutes per lesson, including practice.

Start with a requirement you can check

Suppose the requirement says: a score passes when it is at least 70. An AI assistant returns the candidate below. Before running it, translate the function into one plain sentence and trace the exact boundary input. A clear explanation is a test of your understanding; a confident description from the assistant is only another claim to examine.

with Ada.Text_IO;

procedure Main is
   function Passed (Score : Integer) return Boolean is
   begin
      return Score > 70; -- Deliberate candidate to review
   end Passed;
begin
   Ada.Text_IO.Put_Line (Boolean'Image (Passed (70)));
end Main;

The candidate says “strictly greater than 70,” so 70 produces FALSE. That disagrees with “at least 70.” The example is intentionally wrong at the boundary. Keep the requirement separate from the implementation so that you do not accidentally rewrite the expected behavior to match whatever the draft does.

Reference: AdaCore: expressions and control flow.

Example code on Agila Forge ↗

Complete this lesson

Answer every check correctly to earn your lesson certificate. Feedback helps you review and try again.

Sign in · Save your progress and earn a certificate for this lesson.