Making Programs easy to read unit 2 Flashcards

(7 cards)

1
Q

Why is it important to make code easy to read?

A

So others (and your future self) can understand what it does and how it works.

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

What are the four main techniques to improve code readability?

A
  1. Comments
  2. Descriptive names
  3. Indentation
  4. White space
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do comments help readability?

A

They explain what the code does, especially complex parts, without affecting how the program runs.

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

Why use descriptive names for variables and functions?

A

They make it clear what each variable or function represents or does.

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

What does indentation do?

A

It shows the structure of the program, like what belongs inside a loop or if statement.

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

How does white space improve readability?

A

It separates parts of the code visually, making it less crowded and easier to follow.

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

What is the benefit of readable code during debugging or testing?

A

It’s faster and easier to find and fix mistakes.

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