section 7 - design, testing, IDE's Flashcards

1
Q

well-maintained programs

A

When using structured programming, it’s important that your code is well-maintained.
A well-maintained program makes it easy for other programmers to understand what the code does. They should also be able to change parts of the source code without the risk of causing problems elsewhere in the code (e.g. knock on effects).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

features that improve the maintainability of source code - Comments

A

useful for explaining what the key features of a program do - well written and clear comments are fundamental for helping other programmers understand your programs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

features that improve the maintainability of source code - indentation

A

used to separate different statements in a program. This allows other programmers to see the flow of the program more clearly and pick out the different features.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

features that improve the maintainability of source code - naming of Variables, sub programs and parameters

A

Variables, sub programs and parameters should be named so that they refer to what they actually are. This helps programmers to understand what they do, and makes it easier to keep track of them. It’s also important that they follow the standard naming conventions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

features that improve the maintainability of source code - use of sub programs

A

Using sub programs can make it easier for other programmers to see how different parts of a program work, which can help them understand the overall program faster.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Defensive Design

A

When programs are functioning correctly they should never break or produce errors. In practice this is difficult to achieve.

Programmers try to protect their programs through defensive design. They will try to:

  • Anticipate how users might misuse their program, then attempt to prevent it from happening.
  • Ensure their code is well-maintained
  • Reduce the number of errors in the code through testing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

input validation

A

Checking if data meets certain criteria before passing it into the program.
E.g. checking that an email address contains an @ symbol and has a suitable ending (.com, .co.uk, etc).

This prevents users from accidentally or intentionally misusing a program when entering data.

Programs can use a mixture of input validation checks to verify that the inputted data has an acceptable format before passing it into the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

types of input validation check you can use

A

Range check
Presence check
Format check
Look-up table
Length check

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Range check

A

Checks the data is within a specified range

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

presence check

A

Checks the data has actually been entered.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

format check

A

Checks the data has the correct format (e.g. a date).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

look-up table

A

Checks the data against a table of acceptable values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

length check

A

Checks the data is the correct length.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

authentication

A

Authentication can confirm the identity of a user before they’re allowed to access certain pieces of data or features of the program. A common way that programs do this is using passwords - It’s important that programmers get the level of authentication correct - too much authentication can affect a program’s functionality and put people off using it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

authentication - passwords

A

Passwords are usually associated with a username. When someone tries to access a protected part of the program, it should ask them for their password to check that they are who they claim to be.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

common ways to increase the security of a password-based authentication system

A
  • Force users to use strong passwords (see p.46) and get them to change their passwords regularly.
  • Limit the number of failed authentication attempts before access to an account is lost.
  • Ask for a random selection of characters from the password on each authentication.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

syntax errors

A

when the compiler or interpreter doesn’t understand something you’ve typed because it doesn’t follow the rules or grammar of the programming language.

Syntax errors can be diagnosed by compilers and interpreters - they’ll be unable to translate the source code and a syntax error (with its location) will be returned.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

logic errors

A

when the compiler or interpreter is able to run the program, but the program does something unexpected.

Logic errors are more difficult to diagnose and track down - compilers and interpreters won’t pick them up. Logic errors are found through general use of the program and by systematically testing it using a test plan.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Programming Errors

A

It’s quite typical for a program to contain errors during its development these errors need to be found and corrected as soon as possible.
The first task is to figure out what type of error has occurred.
Once you have identified the errors in a program, you can then refine your code to fix them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Iterative testing

A

the program is tested while it is being developed. Often a programmer will test a module, fix any errors they find and then test it again. They will repeat the process until the module is working correctly.

Iterative testing is used to identify and fix small errors, which will help prevent larger (and more difficult to fix) errors from occurring later on in the development process.

21
Q

Final (terminal) testing

A

the program is tested at the end of the development process. The whole program is tested at the same time to check that it’s working correctly.

Final testing is also important as modules may work perfectly on their own, but errors may occur when the modules interact with each other in the program.

22
Q

Testing

A

Using a combination of iterative testing and final testing is a good way to help minimise the total number of errors or bugs that a program has when it is released.

23
Q

test plan

A

outlines exactly what you’re going to test and how you’re going to test it.
It should cover all the possible paths through a program.

A good test plan will anticipate all of the potential issues with the program and select appropriate test data to test for these issues.

24
Q

test data categories:

A

Normal data
Boundary (extreme) data
invalid data
erroneous data

25
Q

Normal data

A

things that a user is likely to input into the program.

26
Q

Boundary (extreme) data

A

values at the limit of what the program should be able to handle.

27
Q

Invalid data

A

inputs with a correct data type that should be rejected by the program.

28
Q

Erroneous data

A

inputs with an incorrect data type that should be rejected by the program

29
Q

test plan example

A
30
Q

high level languages

A
  • One instruction of high-level code represents many instructions of machine code.
  • The same code will work for many different machines and processors.
  • The programmer can easily store data in lots of different structures (e.g. lists and arrays) without knowing about the memory structure.
  • Code is easy to read, understand and modify.
  • Must be translated before a computer is able to understand it.
  • You don’t have much control over what the CPU actually does so programs will be less memory efficient and slower.
  • (e.g. Python, C++)
31
Q

low level languages

A
  • One instruction of assembly code usually only represents one instruction of machine code.
    Usually written for one type of machine or processor and won’t work on any others.
  • The programmer needs to know about the internal structure of the CPU (see p.2-3) and how it manages the memory.
  • Code is very difficult to read, understand and modify.
  • Commands in machine code can be executed directly without the need for a translator.
  • You control exactly what the CPU does and how it uses memory so programs will be more memory efficient and faster.

They consist of machine code and assembly languages

32
Q

translators

A

Computers only understand instructions given to them as machine code, so high level
languages need to be translated before a computer is able to execute the instructions.
There are two types of translator that you need to know about: compilers and interpreters.
The type of translator used will depend on which programming language and IDE you’re using

33
Q

compiler

A

Translates all of the source code at the same time and creates one executable file.
Only needed once to create the executable file.
Returns a list of errors for the entire program once compiling is complete.
Once compiled the program runs quickly, but compiling can take a long time.

34
Q

interpreter

A

Translates and runs the source code one instruction at a time, but doesn’t create an executable file.
Needed every time you want to run the program.
The interpreter will return the first error it finds and then stop - this is useful for debugging.
Programs will run more slowly because the code is being translated as the program is running.

35
Q

linker

A

If the program is stored over multiple source code files then a linker is used to join all of the separate compiled codes into one executable program.

36
Q

IDE

A

An integrated development environment is a piece of software that provides features to help a programmer to develop their program. Most IDEs will have similar features

37
Q

code editor

A

The code editor is the main part of an IDE, it’s where the code is written. Most code editors will have line numbering and auto-colour coding for things like strings, functions, variables and comments. Good code editors will also have other automatic features like auto-correct, auto-indentation and auto-complete.

38
Q

run-time environment

A

A run-time environment allows the code to run quickly within the IDE - this is done using a start or run button. The run-time environment can also help to identify logic errors in the program as the programmer can see which part of the code is running when errors occur.

39
Q

output window

A

An output window to
show the output from a program when it is run.

40
Q

Error diagnostics and debugging tools

A

Error diagnostics and debugging tools help to find and fix errors in a program - they’ll tell you the location of the error and often suggest ways to fix it.

41
Q

Breakpoints

A

Breakpoints are a common debugging tool, they stop the program on certain lines so you can gather information like the value of variables as the program is running.

42
Q

Auto-documentation

A

Auto-documentation helps with the maintenance of programs. It can extract certain features
of a program, like the names of variables, names of sub programs and comments.
This information is stored in a separate document to give a summary of what the code does.

43
Q

Graphical User Interface (GUI) builder

A

A Graphical User Interface (GUI) builder helps the programmer design a user interface by building up graphically rather than having to design it using source code. It allows you to drag and drop different objects and customise them, so you can make the interface look exactly how you want it to.

44
Q

structure diagrams

A

1) Structure (or modular) diagrams show the smaller tasks of a larger program.

2) They are made by decomposing the program that you want to write into manageable modules. Each of those modules is then decomposed even further into smaller modules and eventually into modules that perform individual tasks.

3) Simple sub programs can be written to carry out each individual task. Then the bigger modules and main program can be written using these sub programs.

45
Q

structure diagrams example

A

For example, to design a program simulating a game of noughts and crosses you might have:

46
Q

Advantages of using Structure Diagrams

A

Coding is easier because you’re only writing code to carry out very simple tasks.

Lots of programmers can work on one program as each module can be written independently.

It’s easier to test structured programs as each module can be tested individually

Individual sub programs and modules can be fixed and updated without affecting the rest of the program.

You will be able to reuse the sub programs and modules in programs you write in the future.

47
Q

Trace tables

A

1) Trace tables give a simple way of testing that a piece of code is working correctly.
They keep track of the values that certain variables take as you go through the code.

2) Their main use is to ‘dry run’ a sub program or algorithm to make sure there are no logic errors.

3) The columns of a trace table usually represent variables. Each row of a trace table represents the values that the variables take at a particular point in the algorithm.

4) The columns of a trace table might not always be variables - they could be any information that the programmer is interested in. For example, they might have a column for the length of an array or for the output of the algorithm

48
Q

Trace tables example

A