Edexcel International Advanced Level Computer Science, point 6.3.1
Definition and function
An integrated development environment (IDE) is a software application that brings together the tools needed to write, run, test and debug programs in one place. Examples: IDLE, PyCharm, Visual Studio Code, Visual Studio, Eclipse.
Why needed: it makes programming faster and less error-prone, because the tools work together and point out problems as you work. You use an IDE of your choice in the Unit 2 practical exam.
a. Text editor
- Definition: the part where you type and edit the source code.
- Features: syntax highlighting (colours for keywords, strings, comments), line numbers, automatic indentation (important in Python), bracket matching, find and replace, code folding.
- Benefit: the code is easier to read, and mistakes stand out.
b. Autocomplete
- Definition: the IDE suggests the rest of a name or command as you type, from the language and your own code.
- Function: it saves typing, reduces spelling errors, and shows available functions, methods and parameters.
- Benefit: faster coding, fewer typos, and helps you discover library functions.
- Drawback: suggestions can be wrong, and it can make you rely on it and not learn the names.
c. Syntax checker
- Definition: a tool that checks the code against the rules of the language and flags errors, often as you type (underlining the problem), or when you run it.
- Catches: syntax errors (a missing colon or bracket, a misspelt keyword, wrong indentation).
- Doesn't catch: logic errors (the program runs but gives wrong results), and many run-time errors.
- Benefit: errors are found early, with a message and line number.
d. Debugger
A debugger lets you control a program as it runs, and look inside it, to find and fix faults.
Breakpoints
- Definition: a marker on a line of code where the program pauses when it reaches it.
- Use: run at full speed up to the suspect part, then stop and inspect. A conditional breakpoint pauses only when a condition is true (for example
i == 50).
Stepping
- Definition: running the program one statement at a time.
- Forms:
- Step over: run the next line (a whole subprogram call counts as one step).
- Step into: go inside a subprogram and run its lines one by one.
- Step out: finish the current subprogram and return to the caller.
- Use: follow the exact order of execution, and see where it differs from what you expected.
Variable watch
While paused, the debugger shows the current values of variables, which you can watch change as you step. This does the same job as a trace table, automatically.
e. Memory inspection
- Definition: a tool that shows what is stored in memory: the values of variables, objects and data structures, and the call stack (1.2.4).
- Use:
- See the contents of lists, dictionaries and objects.
- See which subprograms are active, and their local variables (the call stack).
- Find why a value is wrong, and memory problems such as uncontrolled recursion.
- Benefit: it makes hidden state visible, so you don't need many
printstatements.
Other common features
- Run/translator built in: an interpreter or compiler (Python is interpreted).
- Error messages with line numbers.
- Project management, version control support (6.3.2), libraries and package management.
- Refactoring tools (renaming a variable everywhere).
- Profilers to find slow code.
- Documentation pop-ups.
Benefits and drawbacks
- Benefits: all tools in one place, faster development, errors found early, easier debugging, good for large projects and teams.
- Drawbacks: can be large and slow to start, with a lot of features to learn, may hide what the language is doing (beginners rely on it), and settings vary between IDEs.
Worked example
Task: this code is meant to print 3, 2, 1, but it prints 3, 4, 5, ... and then stops with a RecursionError. Explain how an IDE's tools would find the problem.
def countdown(n):
if n == 0:
return
print(n)
countdown(n + 1)
countdown(3)
- The syntax checker shows no errors: the code is valid Python, so the fault is in the logic.
- The error message gives the line number of the recursive call,
countdown(n + 1). - Put a breakpoint on that line and run. Step into each call and watch
n: it goes 3, 4, 5, ..., moving away from the base casen == 0. - Memory inspection of the call stack shows a new frame for every call, each with its own
n, piling up until the stack runs out of space. - Cause: the recursive call increases
ninstead of decreasing it, so the base case is never reached. Fix:countdown(n - 1).
Exam tip: for each feature say what it does and how it helps. Be clear about what the syntax checker can and can't find. A breakpoint pauses at a chosen line, stepping runs one line at a time, and memory inspection shows stored values. A good answer links tools to finding a particular type of error.
Check yourself
What is an IDE?
Software that combines the tools for writing, running, testing and debugging programs in one application.
What is a breakpoint?
A marker on a line of code where the program pauses so you can inspect it.
What type of error can a syntax checker find, and what type can it not find?
It finds syntax errors (breaking the language's rules). It can't find logic errors, where the program runs but gives wrong results.
What is the difference between step over and step into?
Step over runs a subprogram call as one step. Step into goes inside the subprogram and runs its lines one at a time.
What can memory inspection show while a program is paused?
The current values of variables, the contents of data structures and objects, and the call stack (which subprograms are active, with their local variables).