HW: Spaghetti Code

Learning objective: practical experience in computing and understanding the differences between MCC, SDD, and SF on a small example.

(As with previous homework assignments, cite your sources.)

9-1. Find a software tool or tools to compute metrics for this question and use it/them on the Project 2 student function starting code (i.e., the function you're given as a starting point before you've made any changes). If your tools don't support all the metrics indicate which ones you computed by hand. In many cases the only metric you'll have to compute by hand is the Spaghetti Factor (SF) metric. If you have trouble finding a tool it is OK to ask your friends for suggestions of what to look for, but you MUST actually run the tool yourself. Report:

9-2. Give one or two-sentence answers to the following questions. Make sure you have access to these answers in recitation in case you are called upon to discuss them.

Hint: SF (as well as MCC and SCC) are computed on a single module. In C/C++ this is a piece of code callable from another piece of code at the programmer level. A module=subroutine=procedure=function=method. It is *not* an entire .c file (unless you have only one function in that .c file). It is not a piece of a function. It is an entire function that starts with a procedure interface (e.g., foo(void)) and ends with the last closing "}" for that procedure.

Hint: some students have trouble finding an SCC tool. The tools are out there... try a search on:
free cyclomatic complexity tool
If you have spent 30 minutes without finding a tool you can compute SCC by hand. In the writeup say: "I could not get a complexity tool running with 30 minutes of effort so I computed SCC by hand."

RUBRIC:

Supplemental Material: