Lecture 12 Flashcards
Which two types of quality are there?
internal quality and external quality
What is external quality?
The user experience, quality from the perspective of the user
Which two things influence external quality the most?
No crashes, good performance
What is internal quality
The quality from the developer perspective
Which three things influence internal quality the most?
How understandable the code is, if the code is easy to change and whether the code is testable.
What are 6 basic rules for having high quality code?
- LOC per method rule
- Duplicated code rule
- CC rule
- Rule of parameter list length
- Code Style rule
- Testing rule
What is the LOC per method rule?
The LOC per method rule is that a method should never have more than 40 lines of code, and that if a code has more than 20 lines of code you should review it and consider to change the method. (THESE NUMBERS ARE JAVA)
What is the duplicated code rule?
Never duplicate code, if you need code twice, put it in a method that you can call from multiple places.
What does CC in the CC rule stand for?
Cyclomatic Complexity
How do you calculate the CC of a piece of code?
Counting all conditions and adding 1 (conditions: if, while, for et.c).
What is the CC rule
the rule that a method should not have a Cyclomatic complexity higher than 10, if it is above 5 you should review the method and consider changing it / splitting it up.
What is the rule of parameter list length
The rule that a method should in general not have more parameters than 4.
What is the code style rule?
The code style rule states that you should follow code conventions
What are the 4 conventions of the code style rule?
indentation, whitespace, naming, documentation
What is the test rule?
The test rule states that the amount of unit tests you have for a method should be greater than or equal to the CC of the method.