2.5.2 The Integrated Development Environment
Programmers do not usually write code in a plain document and then use many separate programs to run it. They use one package of tools called an IDE.
You need to know four features of an IDE: the editor, error diagnostics, the run-time environment and the translators. For each one, know what it is and how it helps a programmer.
Editor
A basic text editor only lets you type. The editor in an IDE has extra features that make code easier to write and read.
| Feature | What it does | How it helps |
|---|---|---|
| Line numbers | Shows a number beside each line | Error messages say which line to look at, so the mistake is easy to find |
| Syntax highlighting | Shows keywords, strings, numbers and comments in different colours | The code is easier to read, and a missing quote or misspelt keyword is easy to spot |
| Auto-complete | Suggests the rest of a word or command as you type | Saves time and cuts down on spelling mistakes |
| Auto-indent | Moves code in automatically after an if or a loop | Keeps the structure of the code clear and easy to follow |
| Bracket matching | Shows which bracket closes the one you are on | Helps you avoid missing or extra brackets |
| Commenting tools | Marks lines as comments with one key | Saves time and makes it easier to explain code |
| Find and replace | Searches the code for a word and can change it everywhere | Quick to make the same change in many places |
// Syntax highlighting would colour this code
for i = 0 to 9
print("Number " + str(i))
next i
Error diagnostics
There are two kinds of tool: those that find errors in the code before it runs, and those that help you look at the program as it runs.
Finding errors
- •The IDE can highlight a mistake, such as a missing bracket, a misspelt word or a missing
endif, as soon as you type it. It may underline the code or show a marker next to the line. - •After translation, the IDE shows an error report. It gives the line number and a message that says what is wrong. This saves you from searching through the whole program.
- •Messages explain the type of error, for example a syntax error (the code breaks the rules of the language) or a run-time error (the program stops while it runs).
Debugging tools
A logic error does not stop the program, but gives the wrong answer. These are the hardest to find, so an IDE offers tools to look inside the program while it runs:
- •Breakpoints: you mark a line where the program should pause. You can then check the values of the variables at that point.
- •Stepping: run one line at a time, so you can watch what happens after each line.
- •Variable watch: shows the current values of the variables as the program runs. This works like a trace table that fills itself in.
total = 0
for i = 1 to 4
total = total + i
next i
print(total)
Using stepping and a variable watch, the programmer sees that the loop stops when i is 4. total is 10, not 15. The programmer then sees that the loop should be
for i = 1 to 5.Run-time environment
With a run-time environment the programmer can:
- •Run the program at the click of a button.
- •Type in data and see the output, for example in a built-in console or window.
- •Test the program with different data.
- •See run-time errors when the program stops, with a message and the line where it happened.
- •Stop a program that is stuck, for example one that has been caught in an endless loop.
Translators
An IDE includes a translator, which is a compiler or an interpreter (see topic 2.5.1). It turns the source code into machine code so the program can run.
How the translator helps:
- •The programmer does not need to install or start a separate translator.
- •The program can be translated and run with one click.
- •The translator reports errors in the IDE, with line numbers, next to the code.
- •Some IDEs can work with different translators for different languages, so one IDE can be used for several languages.
Summary of the four features
| Feature | What it is | How it helps |
|---|---|---|
| Editor | Where code is typed and changed | Easier to write and read code, with fewer typing mistakes |
| Error diagnostics | Tools to find and understand errors | Locates and explains mistakes quickly |
| Run-time environment | Lets you run and test the program | Test and fix in one place |
| Translators | Turn the code into machine code | Program is translated without leaving the IDE |
Exam technique
- •State or give: name a feature. "Give two features of an editor in an IDE."
- •Describe: say what the tool does. "Describe what is meant by error diagnostics."
- •Explain how a feature helps: give a reason. "Syntax highlighting helps because keywords are in different colours, so a misspelt word is easier to spot."
- •Name the feature and then say the benefit to the programmer. A feature on its own earns the mark only if you say what it does.
- •Use the correct term for the part of the IDE: editor, error diagnostics, run-time environment, translator.
- •"It makes it easier" is too vague. Say what is easier and why.