Thinking Ahead Flashcards

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

What is the Advantage of Thinking Ahead

A
  • Allows developers to consider problems that may arise later
  • Taking these factors into account at an early stage, developers can design strategies to make programs easy and intuitive to use
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the Elements of Thinking Ahead

A
  • Inputs and Ouputs
  • Preconditions
  • Cashing
  • Decompoistion
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe the Inputs and Ouputs of Thinking Ahead

A
  • Inputs include any data that is required to solve a problem and the method of input
  • Outputs are the results that are passed back once the inputs have been processed and the problem solved
  • Designers must decide on a suitable data type, structure and method to use in order to present the solution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is good to specificy preconditions

A

Specifying preconditions means that a subroutine can expect the parameters to meet certain criteria

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

Why is it good to specificy preconditions in the documentation accompying code

A
  • Reduces the length and complexity of the program
  • Saves time needed to debug and maintain a longer program
  • Sub-rountines can be reused without error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe examples of some methods and their preconditions

A
  • Linear search - data must be in a structure that can be moved through one element at a time
  • Binary search - data must be in order and must be in a structure where elements can be directly accessed
  • Binary search tree - data must be stored in a tree structure and ordered to allow a binary search
  • Hash table - data must be stored in a hash table and the method of dealing with collisions must be understood
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How is Cashing used in Thinking Ahead

A
  • Caching is the process of storing data in cache memory after it have been used
  • This saves time which would have been needed to store and retrieve the data again
  • When you are designing your own programs, you should pay attention to any areas where caching might be beneficial
  • If you need to process all of the records in a file, it might be more effective to read the whole file into an array, and carry out subsequent processes against the array, than to repeatedly read and write to an external file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the Potential Drawbacks of Caching

A
  • Cache can become outdated if original is updated leading to inconsistences in the data (secuirty risk against data protection if stayed in cahce for a long time)
  • Larger cache takes long time to search through
  • Takes up storage space
  • Only limited storage space
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Prefetching

A
  • A more advanced variation of caching
  • In which algorithms predict which instructions are likely to soon be fetched
  • The instructions and data are loaded and stored in cache before they are fetched
  • By thinking ahead, therefore, less time is spent waiting for instructions to be loaded into RAM from the hard disk
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the Limitations of Prefetching

A
  • The accuracy of the algorithms used in prefetching is a limitation, as they can only provide an informed prediction as to the instructions which are likely to be used and there is no guarantee that this will be right
  • The effectiveness of caching depends on how well a caching algorithm is able to manage the cache, larger caches still take a long time to search and so cache size limits how much data can be stored
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How is Decomposition used in Thinking Ahead

A
  • By breaking the task into smaller simplier tasks
  • It allows programers to identify where program components developed in the past, or externally-sourced program components, can be reused to simplify the development process
  • Common reused used functions are libraries
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the Advantages of using Reusable Components

A
  • Better tested so more reliable
  • Saves time creating code
  • Saves development costs.
  • However, it may not always be possible since components may not be compatible
How well did you know this?
1
Not at all
2
3
4
5
Perfectly