2.1.2. Thinking Ahead Flashcards

(17 cards)

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

What is the definition of an input?

A

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

What is the definition of an output

A

results passed back when inputs have been processed and the problem is 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
  1. data structures used
  2. data types used
  3. method of input/output (device)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
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
6
Q

What 2 places can preconditions be defined?

A

within the code or documentation

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

What are 2 examples of where preconditions are required?

A
  1. stack functions 2. factorial function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What 2 ways does a stack function make use of preconditions?

A
  1. checks that a stack is not empty when popping an element from a stack
  2. checks that a stack is not full when pushing an element onto a stack
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does a factorial function make use of preconditions?

A

checks the number passed into the function is not negative

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

What are 3 advantages of including preconditions within the documentation accompanying a subroutine?

A
  1. reduces complexity of the program
  2. reduces time needed to debug and maintain a large program
  3. makes the subroutine more reusable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the definition of caching?

A

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

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

How is caching used in storing web pages?

A

web pages that a user frequently accesses are cached, so next time they are accessed, content can be loaded without delay

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

What are 3 advantages of caching web pages?

A
  1. content can be loaded without delay
  2. images and text do not have to be downloaded multiple times
  3. bandwidth is freed for other tasks on a network
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is prefetching?

A

where algorithms are used to predict what instructions are likely to be be used soon

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

What are 2 limitations of caching?

A
  1. size of the cache
  2. effectiveness of algorithms managing the cache
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are 2 advantages of using reusable program components?

A
  1. more reliable than new components as they have already been tested
  2. time, money and resources are saved as developing from scratch is not required
17
Q

What are 3 examples of reuseable program components?

A
  1. abstract data structures eg queues and stacks
  2. classes
  3. subroutines