3 § Knowing what is inside your source code is the first step in assessing the quality of the software product. § Knowing the quantity of work performed in generating the source code is the first step in determining the productivity of your software team. Software Metrics
7 Metrics Size LOC eLOC lLOC Understandability Comments Whitespaces Complexity Average, Max, Min LOC Interface Complexity Cyclomatic Complexity Software Metrics
8 § LOC – Lines of Code Metric. Including lines of a single brace or parenthesis § LOC are used to create time and cost estimates. § LOC are a tracking tool to measure the degree of progress on a module or project. § An experienced developer can gage a LOC estimate based upon knowledge of past productivity on projects. Size Metrics
9 § eLOC – effective Lines of Code Metric. Only code statements § An effective line of code or eLOC is the measurement of all lines that are not comments, blanks or standalone braces or parenthesis. These can inflate LOC metrics by 20 to 40 percent. § This metric more closely represents the quantity of work performed. Size Metrics
10 § lLOC – logical Lines of Code Metric. § These statements are terminated with a semi-colon. § The control line for the "for" loop contain two semi-colons but accounts for only one semi colon. Size Metrics
13 § Cyclomatic Complexity. It is a quantitative measure of the number of linearly independent paths. § Paths occur when "while,” "for,” "if,” "case," and "goto" keywords appear within the function. § If the source code contained no control flow statements (conditionals or decision points), the complexity would be 1 § If the code had one single-condition IF statement, there would be two paths through the code: one where the IF statement evaluates to TRUE and another one where it is considered to be FALSE. § Two nested single-condition IFs, or one block with two conditions, would produce a complexity of 3. Function Metrics
16 Complexity Number Meaning 1-10 Structured and well written code High Testability Cost and Effort is less 10-20 Complex Code Medium Testability Cost and effort is Medium 20-40 Very complex Code Low Testability Cost and Effort are high >40 Not at all testable Very high Cost and Effort Cyclomatic Complexity
34 Step 4 Write a paragraph about what you think of the metrics. What do the metrics state about the code? – explain with your own words (good, bad, unknown) https://github.com/javiergs/TowerOfHanoi
36 Step 5 repeat several times { move disk 1 from Poll 1 to Poll 3. move disk 1 from Poll 3 back to Poll 1 } // Notice how each time the disk is drawn // upper and upper like floating in the poll // Why?
38 Step 5 How many files need to be edited? How many lines are to be added? How many lines are to be modified or removed? Elaborate an explanation (either way)
Winter 2024 Copyright. These slides can only be used as study material for the class CSC308 at Cal Poly. They cannot be distributed or used for another purpose.