Software Engineering & Architecture 11. QUALITY METRICS AND VISUALIZATION Martin Kropp University of Applied Sciences Northwestern Switzerland Institute for Mobile and Distributed Systems
References Some of the visualization stuff has been taken from H. Gall et al. Software Analysis Visualization, 28th International Conference on Software Engineering, Shanghai 2006 And S. Demeyer. SReengMaster. http://www.lore.ua.ac.be/teaching/sreengmaster/ 2
Learning Targets You Stimulate discussion and to pose hypotheses about the quality of code and software design using software quality metrics and visualization tools. can analyze quality attributes of code and software design can apply quality metrics for evaluation of code and design quality can apply software visualization as a method for evaluation of code and design quality can apply software visualization for gaining initial software understanding of legacy systems can collect information as a base re-engineering decisions 3
Content Motivation Quality Metrics Software Visualization Tools Summary 4
Why To Analyze Software Engineering Control quality of new work Legacy Code Determine quality of given work Where are the decay? 5
What to Analyze Code Design Architecture 6
Analysis Means Metrics Provide concrete figures about software quality Visualization Provide graphical view on the software quality 7
Metrics (Recap) Metric: a measurement scale and method to determine the value of an indicator of a certain software product. Indicator: Indicators are internal characteristics that can be related to an external characteristic Example: External characteristic: Analyzability Indicator: Complexity of functions/methods Metric: McCabe s cyclomatic number 8
Some Typical Metrics Size Metrics Lines of Code (LoC), Number of Classes, Number of Methods of Class, Halstead-Metric Logical Structure Metrics Cyclomatic Complexity McCabe Data Structure Metrics Number of Variables, Duration Style Metrics Naming Convention, Nesting Metrics for Cohesion and Coupling Fan-In, Fan-Out, Lack-of-Cohesion, Number of called Methods and many more 9
Evaluation of Metrics metrics for packages 10
Exercise 1: Pro s and Con s of Metrics Pro s Con s 11
Nonetheless You can't manage what you can't control, and you can't control what you don't measure But Don t make yourself a slave of the numbers! 12
Analysis Visualization From H. Gall, Software Analysis Visualization, 28th International Conference on Software Engineering, Shanghai 2006 13
Conceptual Problem Software is intangible, having no physical shape or size. [Thomas Ball] Software visualization tools use graphical techniques to make software visible by displaying programs, program artifacts and program behavior. 14
Visualization Approaches Euclidean cones Pros: More info than 2D Cons: Lack of depth Navigation Hyperbolic trees Pros: Good focus Dynamic Cons: Copyright Hierarchical Views 15
Visualization Approaches (contd) Bottom UP Approach All program entities and relations Filter 16
Goal of Visualization Engineering Get easy to read quality measures On various levels Scalable Reengineering Get easily a good understanding of the software On various levels Scalable Reduce Complexity 17
A Lightweight Approach The Polymetric View A combination of metrics and software visualization Visualize software using colored rectangles for the entities and edges for the relationships Render up to five metrics on one node: Size (1+2) Color (3) Position (4+5) Y coordinate Entities X coordinate color metric width metric Relationships height metric 18
Quiz: Where would you start looking? and why? 19
Polymetric View Example 1 System Complexity View Nodes: Edges: Width: Height: Color: Classes Inheritance Relationships Number of attributes Number of methods Number of lines of code 20
Polymetric View Example 2 Method Assessment LOC Nodes: Methods Edges: - Size: Number of method parameters Position X: Lines of code Position Y: Number of statements NOS 21
Polymetric View More Samples Inheritance Classification View Data Storage Class Detection View For more details see the paper from Michele Lanza, Stephane Ducasse. Polymetric Views - A Lightweight Visual Approach to Reverse Engineering, IEEE Transactions on Software Engineering, Volume 29, Issue 9, Sept. 2003 Page(s):782-795 22
Evaluation Polymetric View Benefits Views are customizable (context ) and easily modifiable Simple approach, yet powerful Scalability Fits very well for coarse-grained view Limits Visual language must be learned What s inside the classes and their structure? 23
Tools (just a view OSS) Metrics Metrics (for Eclipse) Checkstyle Emma CMT Many more Visualization CodeCrawler Evolizer Moose http://moose.unibe.ch/too ls Creole / Shrimp Rigi Jinsight Many more 24
Summary To ensure software quality you have to analyze the software Analysis can be numerical and graphical - or both Metrics are easy to use but have their limitations Software Visualization is very useful when used correctly An integrated approach is needed, just having nice pictures is not enough 25
Tasks Now apply metrics and visualization in a concrete project. http://wiki.hsr.ch/mastermodulsea/wiki.cgi?ex11_ 09 26
Retrospective Give your feedback on http://wiki.hsr.ch/mastermodulsea/wiki.cgi?lesso n11retrospective 27