Thinking ahead Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the purpose of thinking ahead?

A

To make programs easy and intuitive for users to use

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

Define inputs

A

Any data that is required to solve a problem. usually entered into the system by the user

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

Define outputs

A

The results that are passed back once the inputs have been processed and the problem solved

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

What 3 considerations do programmers need to make about inputs and outputs when thinking ahead?

A
  • Method of input/output (device used)
  • Data structures used
  • Data types used
  • Order of data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Identify the inputs and outputs that are likely to be used in a book reservation system i.e. at a library

A

Inputs:

  • Book details e.g. name, author
  • Borrow details e.g. name, library card number

Outputs:

  • Expected waiting time
  • Confirmation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are preconditions?

A

Requirements which must be met before a program can be executed

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

Where can preconditions be defined?

A

Within the code or within documentation

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

Give an example where preconditions are required

A

Stack functions:

  • Check that a stack is not empty when popping an element from a stack
  • Check that a stack is not full when pushing an element onto a stack

Factorial function:
- The number passed to the function cannot be negative

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

State 2 advantages of including preconditions within the documentation accompanying a subroutine

A
  • Reduces the length of the program
  • Reduces the complexity of the program
  • Saves time needed to debug and maintain a longer program
  • Makes subroutine more reusable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define caching

A

The process of storing instructions or values in cache memory after they have been used, as they may not be used again

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

How is caching used in storing web pages?

A

Web pages that a user frequently accesses are cached, so the next time one of these pages is accessed, content can be loaded without delay

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

What are the disadvantages of caching web pages?

A
  • Content can be loaded without delay
  • Images and text do not have to be downloaded again multiple times
  • Frees bandwidth for other tasks on a network
  • Less time is spent waiting
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the name given to the technique in which algorithms are used to predict which instructions are likely to soon be used?

A

Prefetching

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

What are some advantages of caching?

A
  • Allows for faster use in the future than fetching if from secondary storage or online usage
  • Speeds up loading and minimises system resources needed to load a page
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Give a limitation of caching

A
  • Accuracy of the algorithms used
  • Effectiveness of algorithm in managing the cache
  • Size of the cache
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Give 3 advantages of using reusable program components

A
  • More reliable than new components, as they have already been tested
  • As developing from scratch is not required, this saves time, money and resources
17
Q

Give 2 examples of reusable program components

A
  • Abstract data structures e.g. queues and stacks
  • Classes
  • Subroutines
  • Use of external libraries