Skip to content

Commit 90cb2fc

Browse files
committed
docs: Add documentation of cyclomatic complexity #16
The cyclomatic complexity of some methods have been calculated by hand and by using a tool. The results and discussion have been added to the report.
1 parent face670 commit 90cb2fc

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

Report.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,39 @@ there is no need to write much here. If the first project(s) you picked
2121
ended up being unsuitable, you can describe the "onboarding experience"
2222
for each project, along with reason(s) why you changed to a different one.
2323

24-
2524
## Complexity
2625

27-
1. What are your results for ten complex functions?
28-
* Did all methods (tools vs. manual count) get the same result?
29-
* Are the results clear?
30-
2. Are the functions just complex, or also long?
31-
3. What is the purpose of the functions?
32-
4. Are exceptions taken into account in the given measurements?
33-
5. Is the documentation clear w.r.t. all the possible outcomes?
26+
### 1.
27+
28+
#### What are your results for ten complex functions?
29+
30+
| Method | Member 1 | Member 2 | Lizard |
31+
| --------------------------------- | --------------- | --------------- | ------ |
32+
| BinarySearch2dArray::BinarySearch | 10 + 2 - 8 = 4 | 10 + 2 - 8 = 4 | 11 |
33+
| LinkListSort::isSorted | 12 + 2 - 4 = 10 | 12 + 2 - 4 = 10 | 13 |
34+
| FordFulkerson::networkFlow | 10 + 2 - 1 = 11 | 10 + 2 - 1 = 11 | 11 |
35+
| BinaryTree::remove | 16 + 2 - 8 = 10 | 16 + 2 - 8 = 10 | 17 |
36+
| BellmanFord::go | 12 + 2 - 0 = 14 | 11 + 2 - 0 = 13 | 13 |
37+
| LongestCommonSubsequence::getLCS | 10 + 2 - 3 = 9 | 9 + 2 - 3 = 8 | 11 |
38+
| WordBoggle::getNeighbors | 12 + 2 - 1 = 13 | 12 + 2 - 1 = 13 | 13 |
39+
| ClosestPair::closestPair | 12 + 2 - 2 = 12 | 12 + 2 - 2 = 12 | 13 |
40+
41+
The only differences between the two members are the methods “BellmanFord::go” and “LongestCommonSubsequence::getLCS”, which was confirmed by a third member to be VALUE and VALUE respectively.
42+
43+
#### Did all methods (tools vs. manual count) get the same result?
44+
Our tool, Lizard, gave very different results compared to our values calculated by hand. We think that this may be due to the Lizard tool not counting every exit point, and instead only accounts for one exit point.
45+
#### Are the results clear?
46+
They are clear in the sense that the complexity corresponds to the amount of branches and exit points in the methods. However, it is not exactly clear why our results differ from the results from the Lizard tool.
47+
### 2. Are the functions just complex, or also long?
48+
There seems to be a small correlation, with more complex methods having more lines of code. The methods have between 25 and 81 LOC each, with a mean of around 45 LOC. We haven’t worked with large enough codebases to definitively say whether or not this is a lot for these kinds of methods or not.
49+
### 3. What is the purpose of the functions?
50+
The functions are all algorithms, most of which use some form of searching which requires iteration and branching through many loops and conditions, which explains the complexity.
51+
### 4. Are exceptions taken into account in the given measurements?
52+
Yes, the possible exceptions are taken into account by the Lizard complexity measurement tool. This was tested by removing a line that throws an exception, and observing that the measured CC differed from the initially measured value.
53+
54+
If an exception counts as another possible branch, then the CC will increase by one for each exception try-catch block.
55+
### 5. Is the documentation clear w.r.t. all the possible outcomes?
56+
No, not at all. The documentation is very limited, and does not discuss branching.
3457

3558
## Refactoring
3659

0 commit comments

Comments
 (0)