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

CSE460 Lecture 33

CSE460 Lecture 33

Software Analysis and Design
Software Quality Metrics II
(202011)

Javier Gonzalez-Sanchez
PRO

August 02, 2020
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. jgs
    CSE 460
    Software Analysis and Design
    Lecture 33: Software Quality Metrics II
    Dr. Javier Gonzalez-Sanchez
    [email protected]
    javiergs.engineering.asu.edu | javiergs.com
    PERALTA 230U
    Office Hours: By appointment

    View Slide

  2. jgs
    Previously

    View Slide

  3. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 3
    jgs
    Size Metrics
    § LOC – Lines of Code Metric. All lines that are not comments. Including lines of a single brace
    or parenthesis.
    § eLOC (effective Lines of Code) Metric. All lines that are not comments, blanks or
    standalone braces or parenthesis.
    § 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.

    View Slide

  4. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 4
    jgs
    Understandability Metrics
    § Comment Percent = Comment Line Count / (LOC) x 100
    § White Space Percentage = #spaces / (#spaces + #characters) * 100

    View Slide

  5. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 5
    jgs
    Function Metrics
    Cyclomatic Complexity = Conditional_Nodes + 1
    // CC = 3 + 1 = 4 (Condition nodes are 1,2 and 3 nodes)
    i = 0; n=4;
    while (ij = i + 1;
    while (jif (A[i]swap(A[i], A[j]);
    }
    i=i+1;
    }

    View Slide

  6. jgs
    Test Yourselves

    View Slide

  7. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 7
    jgs
    Code 1

    View Slide

  8. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 8
    jgs
    Code 2

    View Slide

  9. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 9
    jgs
    Code

    View Slide

  10. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 10
    jgs
    Numbers
    LOC eLOC lLOC Cyclomatic
    Complexity
    m1
    m2
    m3
    m4
    m5
    main
    Total

    View Slide

  11. jgs
    Test Yourselves II

    View Slide

  12. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 13
    jgs
    Example A
    § 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
    § 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

    View Slide

  13. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 14
    jgs
    Example

    View Slide

  14. jgs
    Remember Structural Complexity

    View Slide

  15. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 16
    jgs
    • Instability = Cout
    (Cin + Cout)
    Stable Abstraction Principle (SAP)

    View Slide

  16. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 17
    jgs
    Distance
    § Distance: how far a package is away from
    the Main Sequence
    § D = A + I – 1
    § Values -1 to 1
    § Absolute Distance |D|

    View Slide

  17. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 18
    jgs
    Example
    ITeamA
    = 6 / 0 + 6 = 1
    ATeamA
    = 0
    DTeamA
    = 0 + 1 – 1 = 0
    IJlabel
    = 0 / 4 + 0 = 0
    AJlabel
    = 0
    DJlabel
    = 0 + 0 – 1 = -1
    |Djlabel
    | = 1
    Pain Zone (just an example!)

    View Slide

  18. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 19
    jgs
    Stable Dependency Principle (SDP)
    § Every dependency between modules should terminate on a module whose
    Instability is less than or equal to the depending
    module's Instability.
    § Every dependency between modules should terminate on a module whose
    Abstractness is greater than or equal to the depending
    module's Abstractness.

    View Slide

  19. Javier Gonzalez-Sanchez | CSE460 | Fall 2020 | 20
    jgs
    Example
    MyNewClass
    OtherClass

    View Slide

  20. jgs
    CSE 460 Software Analysis and Design
    Javier Gonzalez-Sanchez
    [email protected]
    Fall 2020
    Disclaimer. These slides can only be used as study material for the class CSE460 at ASU. They cannot be distributed or used for another purpose.

    View Slide