Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSE360 Lecture 25

CSE360 Lecture 25

Introduction to Software Engineering
Software Measurement II
(201806)

Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. CSE360
    Introduction to Software Engineering
    Lecture 25:
    Software Metrics II
    Javier Gonzalez-Sanchez
    [email protected]
    javiergs.engineering.asu.edu
    Office Hours: By appointment

    View full-size slide

  2. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 2
    Function Metrics
    • Average LOC per Function Metric. An accepted
    industry standard of 200 LOC per function is desired
    as the average LOC per function
    • Maximum LOC per Function Metric.
    • Minimum LOC per Function Metric. A minimum LOC
    per function of 2 or less can indicate functions that
    may have been prototype but not yet complete..

    View full-size slide

  3. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 3
    Function Metrics
    • Cyclomatic Complexity. It is a quantitative measure of
    the number of linearly independent paths
    • Paths occurs when a "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 2 paths through the code: one where the IF
    statement evaluates to TRUE and another one where it
    evaluates to FALSE
    • Two nested single-condition IFs, or one IF with two
    conditions, would produce a complexity of 3.

    View full-size slide

  4. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 4
    Cyclomatic Complexity
    CC = Edge - Node + 2
    Or
    CC = ConditionalNodes + 1

    View full-size slide

  5. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 5
    Cyclomatic Complexity
    i = 0; n=4;
    while (ij = i + 1;
    while (jif (A[i]swap(A[i], A[j]);
    }
    i=i+1;
    }
    // CC = 9 - 7 + 2 = 4
    // CC = 3 + 1 = 4 (Condition nodes are 1,2 and 3 nodes)
    // A set of possible execution path of a program
    // 1, 7
    // 1, 2, 6, 1, 7
    // 1, 2, 3, 4, 5, 2, 6, 1, 7
    // 1, 2, 3, 5, 2, 6, 1, 7

    View full-size slide

  6. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 6
    Cyclomatic Complexity
    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

    View full-size slide

  7. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 7
    Example A (Week 05)
    • 3 files
    • 24 methods
    • 394 lines
    • 326 LOC
    • 285 eLOC
    • 182 lLOC
    • 20 Lcomments
    • Comments 5.1%
    • Blank lines 12.2%
    • Spaces: 21.0% (79% code)
    • Max CC: 6
    • Average CC: 1.46
    • Total P: 18
    • Max P: 3
    • Average P: 0.75
    • Total R: 25
    • Max R: 2
    • Average R: 1.04

    View full-size slide

  8. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 8
    Example A (Week 05)

    View full-size slide

  9. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 9
    Example B (Week 05)
    • 5 files
    • 21 methods
    • 522 lines
    • 412 LOC
    • 356 eLOC
    • 276 lLOC
    • 72 Lcomments
    • Comments 13.8%
    • Blank lines 7.3%
    • Spaces: 26.7% (73.3% code)
    • Max CC: 7
    • Average CC: 2.24
    • Total P: 34
    • Max P: 7
    • Average P: 1.62
    • Total R: 21
    • Max R: 1
    • Average R: 1

    View full-size slide

  10. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 10
    Example B (Week 05)

    View full-size slide

  11. Javier Gonzalez-Sanchez | CSE360 | Summer 2017 | 11
    Reference
    Chapter 24

    View full-size slide

  12. CSE360 – Introduction to Software Engineering
    Javier G onzalez-Sanchez
    javiergs@ asu.edu
    Sum m er 2017
    Disclaim er. These slides can only be used as study m aterial for the class C SE360 at ASU. They cannot be distributed or used for another purpose.

    View full-size slide