Lecture 12 Flashcards

1
Q

Which two types of quality are there?

A

internal quality and external quality

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

What is external quality?

A

The user experience, quality from the perspective of the user

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

Which two things influence external quality the most?

A

No crashes, good performance

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

What is internal quality

A

The quality from the developer perspective

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

Which three things influence internal quality the most?

A

How understandable the code is, if the code is easy to change and whether the code is testable.

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

What are 6 basic rules for having high quality code?

A
  1. LOC per method rule
  2. Duplicated code rule
  3. CC rule
  4. Rule of parameter list length
  5. Code Style rule
  6. Testing rule
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the LOC per method rule?

A

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)

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

What is the duplicated code rule?

A

Never duplicate code, if you need code twice, put it in a method that you can call from multiple places.

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

What does CC in the CC rule stand for?

A

Cyclomatic Complexity

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

How do you calculate the CC of a piece of code?

A

Counting all conditions and adding 1 (conditions: if, while, for et.c).

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

What is the CC rule

A

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.

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

What is the rule of parameter list length

A

The rule that a method should in general not have more parameters than 4.

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

What is the code style rule?

A

The code style rule states that you should follow code conventions

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

What are the 4 conventions of the code style rule?

A

indentation, whitespace, naming, documentation

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

What is the test rule?

A

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.

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

How do you call the things that split tokens in a inputStream / string

A

delimiters

17
Q

What is autoboxing?

A

Autoboxing is when a primitive data type is changed into a reference data type, because this is necessary for e.g. generics.

18
Q

What are generics?

A

Generics are things that the Java compiler sees as “objects” and for which instances of multiple classes can be used.

19
Q

What are wrapper classes? Give an example of a wrapper class

A

Wrapper classes are classes that function like the primitive types, but are reference data types. e.g. Integer, Character

20
Q

Why would you use generics?

A

To create methods or classes that work with different types of objects (e.g. a NumberList with methods that work both for integers and floating-point number)

21
Q

How can we use generics?

A

By using (less-than-bracket) and (greater-than-bracket) in either a class signature or a method signature to specify that we are using generics.

22
Q

Can we specify generics? How?

A

Yes, we can specify generics so that only instances of certain classes, and not all classes are excepted. We can do this by adding extends InsertHere to the generic in the signature.