Writing maintainable code Flashcards

1
Q

What is the purpose of defensive design in programming?

A

To anticipate and handle potential errors or misuse

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

What is the purpose of using comments in maintainable code?

A

Explain the purpose of the program. Explain sections of code (selections

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

How can white space improve code readability?

A

It makes sections of a program easier to see by visually separating them.

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

Why is indentation important in code?

A

It makes sections of a program easier to see by visually separating them.

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

Why is indentation important in code? (duplicate question)

A

It is used for every selection and iteration branch to improve readability and structure.

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

What should you consider when naming variables?

A

Use descriptive variable names and explain their purpose when declared.

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

What are the benefits of using procedures and functions in code?

A

Structure the code. Eliminate duplicating code.

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

Where should user constants be declared in a program?

A

At the top of the program.

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