02 - Short units Flashcards

1
Q

What is the maximum amount of lines for a unit?

A

15 lines

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

What are the main benefits of short units in our code?

A
  • Easy to test
  • Easy to analyze
  • Easy to reuse
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Say, we have a situation in which we have a unit of code that has 25 lines. We have the opportunity to split this up into three units of code. However this increases the total lines of the file since new methods need to be created. Should we do this?

A

Yes!

Although there are also guidelines saying that we shouldn’t add unncecessary lines of code, the maximum of 15 lines for each units rule always trumps this.

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

What counts as a unit of code?

A

Everything between opening and closing curly braces of the method.

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

Let’s say I have a unit of 15 lines. I can split this up into three methods. These methods ofcourse all have their own headers so the lines of code in the entire file will increase. Should I do this?

A

Yes. The advantages of short units far outweigh the increase in overall volume.

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