The shape of the lesson
By the end of the lesson, learners can
- Coding and error detection: These features help while the code is being typed, before it is ever run.
- Presentation features: Code is read far more often than it is written.
- Debugging tools: When a program runs but gives the wrong result, debugging tools let you watch it run.
- Coding: context-sensitive prompts (auto-complete, parameter hints).
- Initial error detection: dynamic syntax checks as code is typed.
- Presentation: prettyprint; expand and collapse code blocks.
- Debugging: single stepping, breakpoints, watching variables and expressions, report window.
One picture every idea returns to
An Integrated Development Environment (IDE) is a single program containing the tools needed to write, translate, test and debug code. For coding it gives context-sensitive prompts (auto-complete). For initial error detection it carries out dynamic syntax checks as code is typed. For presentation it provides prettyprint and expanding and collapsing code blocks. For debugging it provides single stepping, breakpoints, the ability to watch variables and expressions, and a report window.
Forty-five minutes, phase by phase
| Time | Phase | What happens in the room | Grouping |
|---|---|---|---|
| 0 to 5 min | Hook: predict | Open with the question in the title, One window, every tool.. An Integrated Development Environment puts an editor, a translator and a debugger in one place. Put the figure on the board: it is the one picture every idea in the lesson returns to. | Whole class, then pairs |
| 5 to 13 min | Teach and check: Coding and error detection | These features help while the code is being typed, before it is ever run. | Whole class, then pairs |
| 13 to 21 min | Teach and check: Presentation features | Code is read far more often than it is written. | Pairs |
| 21 to 30 min | Teach and check: Debugging tools | When a program runs but gives the wrong result, debugging tools let you watch it run. Project tab 1 of the lab (Single stepping with a trace of the variables) and let a student drive it while the class predicts. Model the worked example Find the logic error on the board, one line at a time. Your turn: Explain the difference between single stepping and using a breakpoint. | Frayer Model |
| 30 to 36 min | Check | The four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong. | Individual, then whole class |
| 36 to 43 min | Plenary | The exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording. | Individual, random call |
| 43 to 45 min | Exit and homework | Set the worksheet below (6 questions, 18 marks). Learners self-assess against the objectives before they leave. | Individual |
Protect the parts that carry the learning
The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.
Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.
Cut first if the build overruns: the last check in Debugging tools, never the check or the plenary.
In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.
Frayer Model
Pairs fill a four-box grid for the key term: definition, characteristics, examples and non-examples. The non-examples box is where the misconceptions surface, so give it the most time.
The full structure, with its variations and the other twelve, is on the cooperative-learning page.
What to head off, and how
| Trap learners fall into | Teaching move that pre-empts it |
|---|---|
| A dynamic syntax check finds syntax errors only. | It cannot find a logic error, such as using < where <= was needed: that needs testing and the debugging tools. |
| Prettyprint does not change what the program does. | It only changes how the code is displayed to make it more readable. |
Features of an IDE: worksheet
6 questions, 18 marks. Written in the style of the papers; no past paper question is reproduced.
Identify four features of a typical IDE that help a programmer to debug a program.
Describe how a dynamic syntax check helps a programmer.
Describe two IDE features that improve the presentation of code, and explain how each helps.
Explain how context-sensitive prompts help a programmer to write code.
A program should output the largest of 10 numbers stored in an array but outputs a number that is not the largest. Describe how a programmer could use IDE debugging features to find the error.
A programmer says: "My IDE shows no syntax errors, so my program must be correct." Explain why this is not necessarily true.
Answer key and marking notes
- Single stepping.
- Breakpoints.
- Watching variables / expressions (watch window).
- Report window. (Also accept dynamic syntax checking for initial error detection.)
- Each line is checked for syntax errors as it is typed.
- Errors are highlighted immediately, so they can be corrected before the program is translated / run.
- Prettyprint: colour codes keywords, identifiers and strings and indents the code consistently.
- This makes the structure easier to read and errors such as a missing ENDIF easier to spot.
- Expand and collapse code blocks: whole procedures, loops or selection statements can be hidden or shown.
- This lets the programmer focus on one part and see the overall structure of a long program.
- The editor suggests keywords, declared identifiers or a routine's parameters based on what is being typed.
- This speeds up coding and reduces errors such as misspelt identifiers or wrong parameters.
- Set a breakpoint at the start of the loop / at the line that updates the largest value.
- Use single stepping to execute the loop one statement at a time.
- Watch the variables (index, current element, largest so far) in the watch window.
- Find the statement where the largest value is not updated as expected, i.e. the logic error, and correct it.
- Dynamic syntax checks only find syntax errors (code that breaks the rules of the language).
- The program may still contain logic errors (or run-time errors), giving wrong results, which need testing and the debugging tools to find.
6 multiple-choice questions on this lesson
From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.
As a programmer types OUTPUT Sco, the editor offers the identifiers Score and ScoreTotal to choose from. Which IDE feature is this?
- AContext-sensitive prompts
- BDynamic syntax checking
- CPrettyprint
- DA watch window
Which IDE feature is used for the presentation of code?
- AExpanding and collapsing code blocks
- BBreakpoints
- CSingle stepping
- DDynamic syntax checks
Which error would a dynamic syntax check not find as the code is typed?
- AUsing
<where<=was needed in a loop condition - BAn IF statement with no matching ENDIF
- CA keyword spelt as
OUPTUT - DA missing closing quotation mark on a string
What is the difference between single stepping and using a breakpoint?
- ASingle stepping pauses after every statement; a breakpoint lets the program run normally until a chosen line, then pauses
- BSingle stepping pauses at a chosen line; a breakpoint pauses after every statement
- CSingle stepping shows variable values; a breakpoint shows only the program's output
- DSingle stepping finds syntax errors; a breakpoint finds logic errors
This code should find the largest value in Values, which holds 3, 9, 4, 7 at indexes 1 to 4. A breakpoint is set on the OUTPUT line. What value does the watch window show for Max when the program pauses?
Max ← Values[1]
FOR Index ← 2 TO 4
IF Values[Index] < Max THEN
Max ← Values[Index]
ENDIF
NEXT Index
OUTPUT Max- A3
- B9
- C7
- D4
A programmer single steps through this code with Total in the watch window. What value is shown for Total just after the assignment has been executed for the third time?
Total ← 0
FOR Index ← 1 TO 5
Total ← Total + Index * Index
NEXT Index- A14
- B9
- C55
- D6
Quiz key
Context-sensitive prompts suggest keywords, declared identifiers and parameters as code is typed. A dynamic syntax check highlights errors as lines are entered, prettyprint colours and indents code, and a watch window shows variable values while a program is paused.
Expanding and collapsing blocks (like prettyprint) changes how the code is displayed so it is easier to read and navigate. Breakpoints and single stepping are debugging tools. Dynamic syntax checks are for initial error detection.
Using the wrong comparison operator is a logic error: the code is valid, so only testing and debugging tools reveal it. A missing ENDIF, a misspelt keyword and an unclosed string all break the syntax rules, so a dynamic syntax check highlights them straight away.
Single stepping executes one statement at a time; a breakpoint runs at full speed up to a marked line and pauses there. The second option reverses them. Neither tool itself shows values: the watch window does that while paused. Both are used to find logic and run-time errors, not syntax errors.
Max starts at 3. None of 9, 4 or 7 is less than 3, so Max is never changed and the watch shows 3. The comparison should be > to find the largest (9). 9 is the intended answer, not what this code gives. 7 would be the last value, and 4 is the next value after 9, neither of which this code stores.
After three passes Total = 1 + 4 + 9 = 14. 9 is only the amount added on the third pass. 55 is the final total after all five passes. 6 is 1 + 2 + 3, adding Index instead of Index * Index.
What to project
The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.
Slides for this lesson
A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.