System Software: Question 10
Syllabus 5.2
Farah is a first-year student teaching herself to program, using an Integrated Development Environment (IDE) rather than typing code straight into a plain text editor.
(a) Farah starts typing the name of a built-in function, and the IDE immediately shows her a list of matching function names, along with the parameters each one expects, before she has finished typing. State the name of this IDE feature, and explain how it helps Farah while she is writing code. [2]
(b) Before Farah even tries to run her program, the IDE underlines one line of her code in red and shows a message describing what is wrong with it. State which broad category of IDE feature this is an example of, and explain what it has detected. [2]
(c) Farah's finished code is messy and inconsistently indented. State two separate IDE presentation features that could automatically improve how her code looks, and briefly describe what each one does. [2]
(d) Farah's program now runs without any error message, but it produces the wrong output. Describe how she could use two IDE debugging features together, breakpoints and single-stepping, to find out exactly where in her code the problem first occurs. [2]
Show worked solution Hide worked solution
Worked solution
Part (a): Coding support. Context-sensitive prompts
This feature is a context-sensitive prompt (sometimes called code completion). As Farah types the start of a function name, the IDE looks at what she has typed so far and immediately displays a list of matching, valid function names, along with the parameters each one expects. This means Farah does not need to remember every function name and its exact parameters herself, or look them up in separate documentation; it speeds up writing code and helps her avoid using the wrong number or type of parameters. [2 marks]: [1] for naming the feature (context-sensitive prompts / code completion), [1] for explaining how it helps Farah while coding.
Part (b): Initial error detection
Underlining a line of code and showing a message before the program is ever run is an example of initial error detection, sometimes implemented as dynamic (real-time) syntax checking. It has detected a syntax error, a mistake that breaks the grammatical rules of the programming language, such as a missing bracket or an incorrectly spelled keyword, and flags it to Farah immediately as she types, rather than her only discovering it later when she tries to run or compile the whole program. [2 marks]: [1] for identifying this as initial error detection, [1] for explaining that it detects a syntax error, found as the code is written.
Part (c): Presentation features
Two separate presentation features could help here:
- Prettyprint: automatically re-formats Farah’s code, correcting its indentation and applying consistent colour-coding to keywords, variable names and other elements, making the structure of the code easier to follow at a glance.
- Code folding: lets Farah collapse (hide) a block of code, such as the body of a procedure or a loop, down to a single line, so she can temporarily hide detail she is not currently working on and see the overall structure of her program more clearly.
[2 marks] for two valid, correctly described presentation features.
Part (d): Debugging with breakpoints and single-stepping together
Farah first sets a breakpoint on a line of code where she suspects the wrong value might already have been produced. When she runs the program, execution runs normally until it reaches this line, then automatically pauses there rather than continuing straight to the end, letting Farah inspect the current values of her variables at that exact point without the program finishing first.
From this paused point, Farah then uses single-stepping to execute her code one line at a time, checking the value of each relevant variable again after every single line runs. By comparing the values she expects against the values actually produced as she steps through, she can find the exact line where a variable’s value first becomes wrong. This is the line where the fault in her code actually occurs. [2 marks]: [1] for correctly describing the use of a breakpoint to pause execution at a chosen line, [1] for correctly describing single-stepping from that point to find the exact line where a value first becomes wrong.
Final answers
- (a) Context-sensitive prompts, show matching function names and expected parameters as Farah types, saving her looking them up.
- (b) Initial error detection. Flags a syntax error immediately as the code is typed, before the program is run.
- (c) Prettyprint (auto-indents and colour-codes code) and code folding (collapses a block of code to show overall structure).
- (d) A breakpoint pauses execution at a chosen line; single-stepping from there, one line at a time, pinpoints exactly where a variable’s value first becomes wrong.