2.1.2 Thinking Ahead Flashcards

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

Why is thinking ahead good

A

-maximise code efficiency
-minimise errors

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

Examples of outputs

A

Visual (on-screen, printed, etc.)
Audio
Haptic feedback
Data to be input into another process or system

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

First step of thinking ahead

A

Determine

What inputs the system needs.
What outputs the system should produce.

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

“Write a program to calculate the volume of a fish tank based on its dimensions and report the result to the user.”

Inputs outputs example

A

Inputs:

Length: Real/Float
Height: Real/Float
Depth: Real/Float

Processes:

Length x Height x Depth

Outputs

Volume: Real/Float

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

“Write a program that asks the user for the number of students in their class and prompts them to enter each student’s test score within the range of 0 - 100.
It should then output the highest, lowest and average score.”

A

Inputs:

NumOfStudents: Integer
CurrentScore: Integer

Processes:

TotalScore = TotalScore + CurrentScore
AverageScore = TotalScore / NumOfStudents
• Loop through the array and return the lowest score
• Loop through the array and return the highest score

Outputs:

MinScore: Integer
MaxScore: Integer
AveScore: Real/Float

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

What is a precondition

A

“Conditions that already exist and could affect how you devise a solution to a problem.”

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

Imagine preparing a three-course meal for a group of friends.
What preconditions might you need to consider before you start?

A

-Do you already have any of the ingredients?
-Specialist cooking equipment
-Costs
-Dietary requirements
-Number of friends
-Available time

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

Caching

A

Instructions or data retrieved from secondary storage and placed into main memory often remain there in case they are needed again before the program using them ends.

• Caching results in faster retrieval times, as instructions or data don’t need to be fetched from secondary storage, which is much slower.

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

Prefetching

A

data being requested from main memory by the processor before it is actually required.

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

Prefetching pros and cons

A

• Although it is much quicker to access items from main memory than secondary storage, it is quicker still to access items from registers or dedicated cache memory located on or near the processor.

• For prefetching to work, clever algorithms need to be designed to predict - with a high degree of certainty - that an instruction or piece of data will be required soon

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

Caching web

A

Caching is also used with web pages to reduce the number of requests from the client back to the web server and vice versa.

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

Pros and cons of caching

A

-caching is a good thing, improving speed and efficiency.

Cons:

However, there are potential drawbacks - the nature of predictive logic means caching algorithms can be very complicated to implement.

The wrong data is often fetched and cached - and subsequently, it has to be removed or flushed.

Maintaining the correct sequence of instructions or data items in these circumstances can be problematic.

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

Reusing code pros

A

Shortens development time

Saves systems resources

Lowers development costs

Reduces redundant code

• All of this can be achieved by reusing existing sections of code that have been tested by a previous developer.

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