Programming 3- module 13) Flashcards

1
Q

What are subroutines?

A

Blocks of code that can be put anywhere in a program + ‘called’ in body of code just by naming them.

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

What is code written without subroutines often called?

A

‘Spaghetti code’.

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

Why is code written without subroutines often called ‘spaghetti code’?

A

As so much longer.

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

Why is structured programming so helpful?

A

Breaks any big task into little 1s (decomposition) makes tasks more achievable.
Updating code made easier as subroutines can be edited individually.
Using code modules or subroutines (1 for each part of the task) makes easy to see which part of code does specific task.

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

What are the advantages of subroutines?

A

Iteration.
Keeps code shorter.
Easier to test large tasks.
Can access + use any variable from main code without having to refine it.

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

How does iteration help as an advantage of subroutines?

A

Code can be written once, then used again.

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

How does keeping the code shorter act as an advantage of subroutines?

A

Only writing code once for subroutine. No matter how many times need it, code can be considerably shorter.

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

How does the code being easier to test large tasks act as an advantage for subroutines?

A

If decomposed into smaller subtasks. Can be easy to test 1 module- or subroutine- at a time.

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

When programming what is it important to remember?

A

Code using subroutines not linear so can be placed at any point within a program.
Subroutines need to be clearly identifiable.
Planning ahead really important.

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

What are translators usually included within?

A

Programming software.

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

What 3 types of translator are there?

A

Assemblers.
Interpreters.
Compilers.

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

What is the purpose of an assembler?

A

Translates assembly language to machine code so fewer errors in translation.

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

What is the advantage of assembler?

A

Far closer to machine code, so fewer errors in translation.

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

What are the disadvantages of assembler?

A

Very device specific with limited instructions available.

More difficult to code + complex tasks require long programs.

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

What is the purpose of a compiler?

A

Translates program that programmer wrote into machine code in 1 sweep before program run.

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

What is the advantage of a compiler?

A

Much faster than running interpreted code as once compiled can be done.