Skip to content
Ameen Abozaid
In reviewJNR-055-L02

Prompts with context: code, constraints, conventions

  • Lesson 2 of 6
  • 11 min read
  • Junior
On This Lesson 4 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

write prompts that get useful answers.

Planned topics

  • Give the relevant code, not the whole project.
  • State constraints: Java version, libraries allowed, no behavior change.
  • State conventions: naming, test style, formatting used by the team.
  • Say the expected result: "return a refactored method and a list of changes".
  • Ask for small steps, then check each one.
Draft outline details

Demonstration

text
Context: Java, Shop Core, CheckoutService.calculateTotal (code below).
Constraints: no behavior change; keep the public signature; no new libraries.
Conventions: JUnit 5, AssertJ, method names in camelCase.
Task: extract the discount block into a private method.
Result: the changed code only, plus one line per change.

Check your understanding

Name three things a good prompt includes.

Show answer

Code, constraints, conventions, and the expected result: any three.

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.

Continue to next lesson

Type to search levels, phases, modules and lessons.