Prompts with context: code, constraints, conventions
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
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.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.