Topics in
Information Visualization
and Visual Analytics
10. Software Visualization
1. Introduction
2. Static SoftVis
3. Dynamic SoftVis
4. Languages & Domains
10.1 Introduction
Software Visualization
(SoftVis) Definition:
•
“Software visualization is the use of computer graphics and
animation to help illustrate and present computer
programs, processes, and algorithms.”
[J. T. Stasko] Application areas
• Teaching and education
• Program development (especially Software Engineering)
• Designing complex systems
10.1.1 Classification
Software
Visualization
[B. Price, R. Baecker, I. Small: A Principled Taxonomy of Software Visualization, In Journal of Visual Languages and Computing, Vol. 4, No. 3, S. 211-266, 1993.] Algorithm Animation Static Algorithm Visualization
Algorithm Visualization Program Visualization
Static Code Visualization Static Data Visualization Data Animation Code Animation VP PbD
10.1.1 Classification
Algorithm Visualization
Definition:
• Visualization of high-level abstractions that describe software
We distinguish:
• Static Algorithm Visualization
Static visualization of algorithms E.g.: flow charts, ...
• Algorithm Animation
Dynamic visualization of algorithms
10.1.1 Classification
Program Visualization
Definition:
• Visualization of concrete program code or data structures (static/dynamic)
We distinguish
• Static code visualization
E.g.: PrettyPrinter, program cards, ...
• Static data visualization
E.g.: box-arrow diagrams of chained lists, ...
• Code animation
E.g.: code view, ...
• Data animation
10.2 Static SoftVis
Software
Algorithm Animation Static Algorithm VisualizationAlgorithm Visualization Program Visualization
Static Code Visualization Static Data Visualization Data Animation Code Animation VP PbD
10.2.1 Algorithms
Static algorithm visualization
Flowcharts [http:// www.rff. c o m/or d e r_ p ro c e s s in g _ o p p o rtu n ity _ flo wc h a rt. h tm] [http:// www.rff. c o m/flowc h a rt_ s a mp les .h tm]
10.2.2 Programs
10.2.2 Programs
Static code visualization (cont.)
10.2.2 Programs
Static code visualization (cont.)
10.2.2 Programs
[Murphy-Hill et al., An Interactive Ambient Visualization for Code Smells, SoftVis 2010]
10.2.2 Programs
Smell Name Short Description
DATA CLUMPS A group of data objects that is duplicated across code.
FEATURE ENVY A method is more interested in some other class than in its own class.
MESSAGE CHAIN A series of method calls to “drill down” to a desired object.
SWITCH STATEMENT A switch statement, typically duplicated across code
TYPECAST The program makes frequent use of the typecast operation.
10.2.2 Programs
Smell Name Short Description
LONG METHOD A method is too long to be easily understood. PRIMITIVE
OBSESSION
The program uses primitive values like int and built-in classes like String instead of domain-specific objects like Range and
TelephoneNumber.
MAGIC NUMBER A literal value is used directly, rather than through a named constant.
COMMENTS Thickly commented code is often bad code.
Refactor the code, and the comments may well become superfluous.
DUPLICATED CODE
The same code structure appears in more than one place.
10.2.2 Programs
Static data visualization (data structure visualization)
Chained lists p q
h
10.2 Dynamic SoftVis
Software
Visualization
Algorithm Animation Static Algorithm VisualizationAlgorithm Visualization Program Visualization
Static Code Visualization Static Data Visualization Data Animation Code Animation VP PbD
10.3.1 Algorithm Animation
Definition:
• Is the process of abstracting a program’s data, operations, and semantics, and creating dynamic graphical views of these
abstractions. [Stasko]
Why is algorithm animation important?
• Better understanding of the algorithm
• Design, troubleshooting, optimization
Problems to handle
• Find the suitable graphical abstraction for algorithm states (data and operations) and the transition between states
10.3.1 Algorithm Animation
History
• The first algorithm animation: Video “Sorting Out Sorting”, SIGGRAPH ’81
Georgia Institute of Technology: Stasko
• XTango/Tango (1990) • Polka + Samba (Frontend) • Polka3D (1992)
MIT later DEC-SRC: Brown (and Najork)
• Balsa (1985), Balsa II (1988) • Zeus (1992)
• Anim3D, Zeus3D (1993) • CAT (WWW, 1996)
10.3.1 Algorithm Animation
XTANGO, 1990
[http://www.cc.gatech.edu/gvu/softviz/algoanim/xtango.html]
Graphical primitives: nodes, edges, boxes, text
Graphical operations on a higher abstraction level: predefined views
Granularity: state sequences transition animations
Realization of the
path-transition paradigm
Annotation of the algorithm with
Interesting event
(IEs)10.3.1 Algorithm Animation
XTango-Animations Search trees Lists 8-queens problem Bin packing http://www.cc.gatech.edu/gvu/softviz/algoanim/xtango.html10.3.1 Algorithm Animation
XTango-Animations (cont.)
Heap sort
Quick sort Bubble sort
10.3.1 Algorithm Animation
XTango-Animations (cont.)
Convex hulls Topological sorting
10.3.1 Algorithm Animation
Specification methods:
(1) Event-driven animation (IEs)
(2) State-driven animation
(3) Visual programming (PbD)
(4) Pseudocode-languages/libraries
10.3.1 Algorithm Animation
(1) Event-driven Animation
• Specification through Interesting Events (IEs)
• For the first time realized in 1984 with BALSA
• Used in many systems (e.g., POLKA or GANIMAL)
• Animation takes place in so-called views
Realization of the design pattern
MVC (model-view-controller)
• Approach:
1. Conceptual design of the animation
2. Identification of the IEs
10.3.1 Algorithm Animation
(1) Event-driven Animation
• Example system: GANIMAL, 2002
Code and data animation
Visualization of GANILA programs
• Swapping of two variable values in Heapsort:
s
10.3.1 Algorithm Animation
Tree View Bar View Array View Event View IE ControlUser
[S. Diehl and A. Kerren. Reification of Program Points for Visual Execution. In Proceedings of the First IEEE International Workshop on Visualizing Software for Understanding and Analysis, pages 100-109, 2002. IEEE Computing Society Press.]
[https://w ww .ad s .tuw ien. ac .at/peop le/ker ren/SV/]
10.3.1 Algorithm Animation
(2) State-driven Animation
• Declarative animation paradigm
• Realized for the first time in 1992 with the PAVANE system
[G.-C. Roman, K.C. Cox, D. Wilcox and J.Y. Plun. Pavane: a system for
declarative visualization of concurrent computations. J. Visual Languages Comput., 3(2): 161--193, 1992]
• Mapping of program states to visualization states
• Approach:
1. Creation of an initial mapping from data structures to graphical interpretations
10.3.1 Algorithm Animation
(2) State-driven Animation
• Example system:
Presented in 1999
Code and data animation Visualization of C programs Smooth animations
Logic-based visualization language Alpha
10.3.1 Algorithm Animation
executable programLinker
C - Preprocessor
C - Compiler
Alpha - Compiler
source code object-file compile timeVirtual
Machine
Control
Inference
Module
Visualizer
runtime10.3.1 Algorithm Animation
Procedural Approach
Knowledge-based Approach
Program
drawingcommandsVisualizer
Inference
Module
Visualizer
requests
10.3.1 Algorithm Animation
10.3.1 Algorithm Animation
(5) Automatic Animation
• For many developers this is the “silver bullet”
• Extremely difficult to realize
• Outstandingly suitable for error search because it is non-invasive and quick
• Early system was UWPI, 1990
Try to discover abstract data types
Expert system chooses the visualization
• Newer systems: e.g., JELIOT 3, 2003
Semi-automatic paradigm based on a user-defined visual semantics of program structures
10.3.1 Algorithm Animation
JELIOT 3 [http:// www.cs.joensuu .fi/jeliot/] [http://cs.joensuu.fi/jeliot/description.php]10.3.1 Algorithm Animation
Summary of specification methods in SoftVis
• Event-driven Animation:
Flexible, powerful, intuitive Overhead
• State-driven Animation
Quick, less code Limited by the system
• Visual Programming (PbD)
Eventually animation for free Complex VP system
• Pseudocode-Language/Libraries
Eventually animation for free Often domain-dependent
• Automatic Animation
10.3.2 Code/Data Animation
Definition: Code and data animation is dynamic program visualization
In principle, this part covers nearly all systems presented in this chapter
Concrete programs -> many factors play an important role:
• Programming language used
• Application domain
10.3.2 Code/Data Animation
There are a lot of general techniques/approaches known from the pure InfoVis field.
Specific techniques for specific problems:
• Base techniques of visualization [Brown,Hershberger:98]
• Color [Brown,Hershberger:98]
• 3D animations
• Distributed visualization (WWW)
10.3.2 Code/Data Animation
Base techniques
• Use of several views
Detailed view of an algorithm
Visualization of several algorithms at the same time
• Representation of the states
Present dynamic behavior
• Chronological process of the algorithm (History)
Focus on the key events
• Floating discrete transitions
• Choice of the input data
Small instances: details
10.3.2 Code/Data Animation
Color
• Coding of the state of data structures
Color represents an additional dimension Global pattern are easier to recognize
• Identical color for the same data structure in different views
• Highlighting of important activities
Temporary emphasis
Should maintain the integrity of the emphasized information
• Clarification of recurring patterns
• History
10.3.2 Code/Data Animation
3D animations
• Aesthetics and functionality
Assumption: People are familiar with three dimensions
• Data structures or algorithms are inherently 3D
Brownian motion Polyhedrons
…
• 3D allows to add additional information to a normal 2D representation
• Several views can be aggregated to one object
10.3.2 Code/Data Animation
3D animations (cont.)
• Example system: ANIM3D, 1993
• Reason for 3D: 3D allows to add additional information to a normal 2D representation
• Input problem: Single Source Shortest Path (Dijkstra)
The graph lies in the xy-plane
Z-axis shows the costs for each node Source has costs = 0
Shortest path = increasing path with lowest height Final results: shortest-path tree
10.3.2 Code/Data Animation
3D animations (cont.)
[Marc Brown and Marc Najork. Algorithm Animation Using 3D Interactive Graphics. ACM Symposium on User Interface Software and Technology (November 1993), pages 93-100.]
10.3.2 Code/Data Animation
Distributed visualization (WWW)
• With rising popularity of the WWW, many distributed animation systems were developed
• Vision of the
Electronic Classroom
• Example system: JCAT (Successor of CAT), 1996
Java platform independent
Views similar to Zeus: window + logic, coupled using IEs
Views are distributed among several computers with separate interactive control of the clients
10.3.2 Code/Data Animation
JCAT [http:// www-cg-hci.inf ormatik. uni-oldenb ur g. de/~da/iva/bae r/html/kap itel4. html]10.3.2 Code/Data Animation
Sound/Audio (Auralization)
• Supports visual perception ( 4D)
• Clarifies recurring patterns
• Signalizes exceptions and important events
• Recursion depth
• Program and data auralization
10.3.2 Code/Data Animation
Sound/Audio (cont.)
• Example system:
First introduced: 1996 Simple preprocessor
Adds calls to functions of a library Application to Turbo Pascal programs
Use of a hierarchical guiding theme design Output using MIDI-interface
Help to search errors in programs
[www.aur a lisa tio n .o rg ]
10.3.2 Code/Data Animation
tio n .o rg ] PROGRAM demob8 ; VAR a : Boolean ; BEGIN a := True ; IF a THENWriteln ('Condition true') ; END. PROGRAM demob9 ; VAR a : Boolean ; BEGIN a := False ; IF a THEN
Writeln ('Condition true') ; END.
10.4 Languages & Domains
Language paradigms
• Imperative programming languages
• Functional programming languages
• Object-oriented programming languages
• Logic programming languages
Domain-specific animations • Algorithmic geometry • Concurrent programs • Real-time animations • Computational models • Animations of proofs [A. Kerren and J. T. Stasko . Algorithm Animation -C ha p te r Introd u c tio n . In Software Visualiza tio n , volume 226 9 o f L N C S Sta te- of- the-Ar t Su rv e y , pag e s 1-15 . Spring e r, 200 2 .]
10.4.1 Concurrency
Parallel/distributed programs
: run on several processors (cores)and/or computers to increase performance
Two kinds of communication:
• message passing
• shared memory
Concurrency of parallel programs (e.g., communication) cannot really be shown textually
Many problems in parallel programming are inherently visual (e.g., deadlocks)
Non-determinism
makes debugging more difficult and needs avery good understanding of the program
r1
r2
p1
10.4.1 Concurrency
Classification
• Visualization of the
performance
(often used)• Visualization of the
Semantics
(rarely used, discussed here)•
online
Advantage: visualization during execution
•
post-mortem
Advantage: lower influence of the program; more flexible visualization
10.4.1 Concurrency
Example system: PARADE, 1995
[Stasko, John T., “The PARADE Environment for Visualizing Parallel Program Executions: A Progress Report,” Graphics, Visualization, and Usability Center, Georgia Institute of
Technology, Atlanta, GA, Technical Report GIT-GVU-95-03, January 1995.]
Flexible framework
• Supports standard solutions and application-specific visualizations
Supports both semantic and performance visualizations
10.4.1 Concurrency
Thread-Visualization
10.4.2 Computational Models
Automata
• Finite automata (transition diagrams)
• Push-down automata • Cellular automata • … Turing machines Statecharts Abstract machines Petri nets Quantum computers
10.4.2 Computational Models
Example system: GANIFA, 2002
[S. Diehl and A. Kerren. Generierung interaktiver Animationen von Berechnungsmodellen. Informatik - Forschung und Entwicklung, 17(1):12-20, 2002. Springer]
Realized with GANIMAL-framework
Generation of finite automata from regular expressions
Simulation of the general finite automata based on the input of arbitrary words
Supports new forms of learning
[http:// rw4.cs .u ni-s b. de/~gan imal/GA N IFA /]
[A. Kerren. Generation as Method for Explorative Learning in Computer Science Education. In Proceedings of ITiCSE ‘04, pages 77-81, Leeds, UK, 2004. ACM.]
10.4.2 Computational Models
Generation of a NFA from a RE
(a|b)*
10.5 Software Engineering
Construction tools
• Requirements and design
• Visual programming
• Graph layouts for general aims
• …
Analysis tools
• Program visualization (e.g., for debugging, test runs, evolution)
• Re-engineering
• Reverse-engineering
• …
10.5 Software Engineering
In many cases, good graph layout tools are important
• Huge need of graph visualization
Statecharts
Structure diagrams Class diagrams
Unified Modeling Language (UML) …
• There are many layout algorithms
• There are many different (industrial) tools
10.5.1 UML
[Gutwenger et al., A New Approach for Visualizing UML Class Diagrams, ACM SoftVis, 2003]
Industry Layout GoVisual
10.5.2 Test Cases
Visualization of test information
• Example system: TARANTULA, 2001
Input: Source-Code & Test-Suite
• Visualization
Coloring to show the contribution of statements to the test result Users can identify potential wrong statements
Discrete approach: [Take n from a lecture by J. Stasko ]
10.5.2 Test Cases
3,3,5 1,2,3 3,2,1 5,5,5 5,3,4 2,1,3 Pass Status: P P P P P F Test cases mid() { int x,y,z,m; 1: read(“Enter 3 numbers:”,x,y,z); 2: m = z; 3: if (y<z) 4: if (x<y) 5: m = y; 6: else if (x<z) 7: m = y; 8: else 9: if (x>y) 10: m = y; 11: else if (x>z) 12: m = x;13: print(“Middle number is:”, m); }