2.10. Programming: Assistance in selected tasks
Learn to program code without AI writing code
Subject: Programming · Grade: 9 (age 14–15) · Duration: 1 double lesson (90 min) · AI: Assistance WITH AI
| AI-related competencies (DUAL.AI.TEACHer Framework) – teacher level | Subject-specific learning objectives – student/learner level |
|
AF-TL-2b (AI foundations and applications × Teaching & Learning, Level 2 – Reflective Implementation):
“Teachers can organise lesson elements that embed AI use with clear pedagogical roles and strategies to verify the output elements.”
AF-FC-2b (AI foundations and applications × Facilitating Learners’ (AI) Digital Competence, Level 2 – Reflective Implementation):
“Teachers can implement guidance that helps learners developing practical AI skills, adapting the tasks to learners’ prior knowledge and the AI tools available.” |
By the end of the lesson, students can:
|
Take-home message: Students need to know the basics of programming if they want to evaluate the results given by a model. So students in the first steps of learning programming must use AI models to do supportive and repetitive tasks related with programming, but not use them to produce code. They can also use the model to ask for possible improvements in the code, so students can test their programming abilities.
Fig 1. Image generated with Gemini (3.6 Thinking), September 8, 2026.
Content
Programming education is changing in a context where AI systems can generate, explain, and review code. While these tools offer new opportunities for learning, they also introduce an important educational challenge: students need sufficient programming knowledge to evaluate whether an AI-generated suggestion is correct, efficient, or even relevant to the task at hand. Without a basic understanding of programming concepts, students may accept incorrect solutions, overlook errors, or fail to recognize better alternatives. For this reason, learning programming fundamentals remains essential, even when AI tools are available.
In introductory programming courses, AI should be positioned as a learning support tool rather than as a substitute programmer. Students can use AI effectively for repetitive or low-level tasks that do not reduce the cognitive effort involved in learning to program. Examples include formatting and indenting code, generating documentation comments, explaining error messages, summarizing syntax rules, or helping students understand the purpose of specific programming constructs. These uses allow students to focus their attention on the underlying logic, algorithms, and problem-solving processes that are central to programming competence.
Another productive use of AI is code review. Instead of asking an AI model to write a solution, students can write their own code first and then ask the model to identify potential improvements. The AI might suggest clearer variable names, better code organization, reduced redundancy, improved readability, or alternative approaches that the student can evaluate independently. This transforms the AI into a feedback partner, allowing students to compare their own reasoning with external suggestions and assess the strengths and weaknesses of their solutions.
However, AI-generated feedback should not be accepted uncritically. Models may recommend changes that are unnecessary, inefficient, or based on incorrect assumptions about the code's purpose. A central goal of this lesson is therefore to develop students' ability to critically evaluate AI suggestions. Students will learn to ask an AI model not only what improvements it proposes, but also why it considers those changes beneficial. By comparing the model's reasoning to established programming principles, students can judge whether the proposed optimization genuinely improves the code or merely represents a different design choice.
This lesson treats AI as a tool that supports reflection, self-assessment, and code quality improvement rather than code generation. Students practice writing their own programs, using AI to perform supportive tasks, requesting feedback on their work, and critically analyzing the quality of the responses they receive. The ultimate objective is to help students become both better programmers and more informed users of AI systems.
Lesson plan
| Phase | Time | Activity |
| Introduction | The |
|
| Input | The teacher introduces appropriate uses of AI in programming education, emphasizing the |
|
| Exploration | 15 min | Students |
Improvement Cycle |
35 min | |
| Reflection | 20 min | Whole-class |
Guiding questions: layering complexity
PairsStudents work through as many of the following rounds as time allows induring the 3535-minute minutesImprovement (most manage two; the third is an extension for early finishers).Cycle. Each round follows the same four-step cycle:process: Write → Ask → Evaluate → Revise
- Round 1 —
limitUsingtheAIprey'sforfoodSupportivesupply (a carrying capacity):TasksPredict:Write:BeforeCompleteyouastartshortprompting,programmingaksexerciseyourself:independently.
what - Ask:
doRequestyousupportexpectfromtothehappenAI for a non-programming task related to thecyclecode,ifsuchtheas:prey'sgrowth - improving
slows down once the population gets large, instead of growing without limit? Sketch the curve you expect.indentation, Prompt:generatingAskcomments,
Predict:Write:IfReviewayourthirdcompletedspeciesprogramnowandcompetesidentifywithpartsthethatpreycouldforpotentiallyfood,beor preys on it as well, or if prey growth now depends on temperature what do you expect this to do to the original two-species cycle?improved.Prompt:Ask:ChooseRequestanotherimprovementfactorsuggestionsandwithoutwrite a prompt askingallowing the AI toaddrewriteittheascode.aFornewexample:
"Suggest three ways to theimprove existingthis onesprogram's —readability specifyand exactlymaintainability, howbut itdo shouldnot interactprovide withreplacement thecode."
Test& compare:Observe the simulation over several cycles. Does the original two-species rhythm survive, get distorted, or disappear?Diagnose:Evaluate:TheWhichoriginalsuggestionsmodelseemassumedvaluable?eachWhichpopulationsuggestionsdependswouldonlyhave little impact on theother.program?
Predict:Write:If one parameter (e.g. the predation rate) is no longer fixed but drawn randomly withinSelect arange at each time step, what do you expect for the long-term stabilitysection oftheyourpopulations?code that performs a repetitive task or uses loops.Prompt:Ask:AskRequest optimization suggestions and require the AI toreplacejustifyoneitsconstant parameter with a randomised value and to keep track of whether either population reaches zero.
Example prompt:
"Explain how this code could be optimized and why each proposed optimization would improve performance or readability. Do not provide the optimized code."
Reflection Questions:
Closing question (for the Reflect phase):
How whichmuch roundprogramming didknowledge theis simulationnecessary stopto producingdetermine whether an AI suggestion actually improves a clean, repeating cycle —program, and what doesrisks thatarise tellwhen youusers aboutrely howon manyAI-generated real-worldadvice factorswithout understanding the originalcode Lotka–Volterrathemselves?
has to leave out in order to stay solvable and easy to interpret?
Materials
- One laptop per student
pair,pair with abrowserprogramming environment - Access to an
LLMAI chatinterface via the internet,assistant oralocallyinstalledhosted language modelif internet access is restricted at school
