Skip to content
Ameen Abozaid
In reviewJNR-055-L06

Demo: refactoring a long method with an assistant under green tests

  • Lesson 6 of 6
  • 11 min read
  • Junior
On This Lesson 3 topics

The content for this lesson is written and waiting for review. The outline below shows what it covers. It will be published once it is approved.

In this lesson

refactor CheckoutService with an assistant while keeping tests green. Prepares JNR-055-LAB1.

Draft outline details

Step by step

  1. Run the tests: green. Open the log file for prompts.
  2. Write a context-rich prompt to extract the discount block; read the proposed diff.
  3. Accept the small change; run the tests; log what you accepted.
  4. Planned mistake: accept a large suggestion that also changes rounding; a test fails. Fix: reject it, log the reason, and ask again for only the extraction.
  5. Ask the assistant for missing tests; check each assertion; delete one that asserts nothing useful.
  6. Commit with a note that AI helped, if the team requires it.

Check your understanding

What do you do with a big suggestion that breaks a test?

Show answer

Reject it and ask again for a smaller step.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.