Lecture Software engineering: Lecture 15 - Ivan Marsic

Lecture 15: Software complexity metrics. The topics discussed in this chapter are: Measuring software complexity, desirable properties of complexity metrics, cyclomatic complexity, converting code to graph, unit testing: path coverage,. | Ivan Marsic Rutgers University LECTURE 15: Software Complexity Metrics Topics Measuring Software Complexity Cyclomatic Complexity Measuring Software Complexity Software complexity is difficult to operationalize complexity so that it can be measured Computational complexity measure big O (or big Oh), O(n) Measures software complexity from the machine’s viewpoint in terms of how the size of the input data affects an algorithm’s usage of computational resources (usually running time or memory) Complexity measure in software engineering should measure complexity from the viewpoint of human developers Computer time is cheap; human time is expensive Desirable Properties of Complexity Metrics Monotonicity: adding responsibilities to a module cannot decrease its complexity If a responsibility is added to a module, the modified module will exhibit a complexity value that is the same as or higher than the complexity value of the original module Ordering (“representation condition” . | Ivan Marsic Rutgers University LECTURE 15: Software Complexity Metrics Topics Measuring Software Complexity Cyclomatic Complexity Measuring Software Complexity Software complexity is difficult to operationalize complexity so that it can be measured Computational complexity measure big O (or big Oh), O(n) Measures software complexity from the machine’s viewpoint in terms of how the size of the input data affects an algorithm’s usage of computational resources (usually running time or memory) Complexity measure in software engineering should measure complexity from the viewpoint of human developers Computer time is cheap; human time is expensive Desirable Properties of Complexity Metrics Monotonicity: adding responsibilities to a module cannot decrease its complexity If a responsibility is added to a module, the modified module will exhibit a complexity value that is the same as or higher than the complexity value of the original module Ordering (“representation condition” of measurement theory): Metric produces the same ordering of values as intuition would Cognitively more difficult should be measured as greater complexity Discriminative power (sensitivity): modifying responsibilities should change the complexity Discriminability is expected to increase as: 1) the number of distinct complexity values increases and 2) the number of classes with equal complexity values decreases Normalization: allows for easy comparison of the complexity of different classes Cyclomatic Complexity Invented by Thomas McCabe (1974) to measure the complexity of a program’s conditional logic Counts the number of decisions in the program, under the assumption that decisions are difficult for people Makes assumptions about decision-counting rules and linear dependence of the total count to complexity Cyclomatic complexity of graph G equals #edges - #nodes + 2 V(G) = e – n + 2 Also corresponds to the number of linearly independent paths in a program (described later) .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.