Software Visualization and Code Comprehension

Kayvan Kaseb
Software Development
10 min readSep 27, 2021
The picture is provided by Unsplash

As a matter of fact, software is typically complex and intangible. The major of software visualization investigates approaches and techniques for static and dynamic graphical representations of algorithms, programs, and processed data. The main objective is to improve our understanding of intangible software, and to reduce the complexity of systems as well. Moreover, the main challenge is to find efficient mappings from various software aspects to graphical representations using visual metaphors. This article aims to discuss some software visualization techniques and examples that are used mainly in static visualization of source code.

Introduction and Overview

Basically, software is usually complex and intangible. Software quickly becomes very complex when its size increases, which plays an essential role on development phase. Besides, the maintenance process is considered as the most time-consuming and expensive phase of the software life cycle. It is mentioned that graphical visualization can convey information better and even faster than numerical data. One of the efficient methods to simplify the understanding of the source code is displaying it through appropriate abstractions and metaphors. The major of software visualization (SV) investigates approaches and techniques for static and dynamic graphical representations of algorithms, programs (code), and processed data. SV is concerned mainly with the analysis of programs and their development. The objective is to enhance our understanding of inherently invisible and intangible software, specially when dealing with large information spaces that characterize domains such as software maintenance, reverse engineering, and collaborative development. Therefore, the main challenge is to find effective mappings from various software aspects to graphical representations using visual metaphors. Studies have shown that utilizing visualization techniques in a software development project raises the chance of succeeding.

There are some significant questions when SV is used. What can be visualized? How? For what reasons? The effectiveness of SV is also a primary question. Initially, software visualization can be able to deal with three different aspects of software: static, dynamic, and evolution. The visualization of the static aspects of software focuses on visualizing software as it is coded, and using information that is valid for all possible executions of the software as well. In contrast, the visualization of the dynamic aspects of software supports information about a particular run of the software and helps comprehend program behavior. Ultimately, the visualization of the evolution of the static aspects of software adds the time dimension to the visualization of the static aspect of software.

In fact, software visualization is an area as old as computer science, but it emerged as an independent major around the middle of the 1980s. In these early times, software visualization development was mostly oriented towards the visualization of an algorithm’s dynamic behavior. Then, its scope was widened to tackle other aspects of the programs. Static and dynamic visualizations of source code or the demonstration of quantitative information about parallel executions are both topics that came later. Eventually, software visualization is considered as a discipline of commercial interest since the mid 1990s only.

Researchers have proposed a number of software visualization techniques over the past years. The following sections will discuss some software visualization techniques and examples, which are used mainly in static visualization of source code.

1. Using source-code-based visualization

SeeSoft is a well-known source-code-based visualization technique by Eick and colleagues. This visualization method is a miniaturized representation of the code lines of the software. A line of code is represented by a colored line with a height of one pixel and a length proportional to the length of the code line. Indentation of the code is retained. As a result, the structure of the source code remains visible even when a large volume of code is showed. To fill the window and to demonstrate large quantities of source code at the same time properly, a line of code can be represented by a single colored square. This square representation diminishes the visualization of the source code to a minimum. In addition, it allows the visualization of distinct source code files at a time by positioning their representations side-by-side. Consequently, it provides quick access to the source code of the whole software in a single view. Marcus et al. designed their visualization technique based on SeeSoft, and added a third dimension to develop the sv3D visualization technique. This visualization technique is extremely meaningful due to the large number of visual parameters available to show information such as height, depth, shape, x-position, y position, and color above and below the Z axis. The sv3D visualization method announced in 2003. So, it was the last visualization of the static aspects of software to directly map source code lines to a visual representation. To be more specific, the recent visualizations mostly focus on higher level representations.

.(a) SeeSoft and (b) sv3D, the picture is provided by the IEEE TRANSACTIONS article

2. Using class-based visualization

The most important idea in this method is understanding the functioning of a single class helps find out the way in which larger components of the entire system work. The class blueprint is a lightweight visualization technique that demonstrates the whole structure of a class, the control flow among the methods of the class, and how methods access attributes. In general, the class blueprint is categorized into five layers as follows: initialization, interface, implementation, accessors, and attributes.

The picture is provided by the IEEE TRANSACTIONS article

Additionally, it uses metrics to represent information that are related to methods and attributes. For instance, the metrics mapped to nodes corresponding to attributes are the number of external accesses (width) and number of internal accesses (height). Most of these metrics are connected to the coupling among modules in the software, and help place modules that need the highest maintenance effort. Thus, by using this technique, visual patterns can be quickly identified, which enhances the understanding of the class.

3. Visualizing the architecture of software

Undoubtedly, architecture visualization is one of the most significant topics in the field of software visualization. As we know, object-oriented software is typically structured hierarchically with packages (including sub-packages), recursively, and with classes structured by methods and attributes. Therefore, the architecture visualization contains visualizing the hierarchy and the relationships among software components. There are three different aspects of the software architecture. Firstly, the software global architecture, containing code source organization for observing how packages, classes, and methods are organized. Secondly, relationships among components based on inheritance or call graphs can be investigated in this method. Finally, to visualize the quality of the software, metric-centered visualizations can be recommended.

The classic node-link diagram is inappropriate way for representing a tree because it quickly becomes too large and it makes difficult to use the available display space. To address this issue, lots of tree layout algorithms have been designed and implemented to optimize the visual representation of the tree. These visualizations are mostly 2D representations; however, they can be extended to 3D representations. Also, most of them use tree representations that are not specific to software visualization, but are applied to software indeed.

Treemap visualization

The Treemap visualization was introduced by Johnson and Shneiderman. It supports an overall view of the whole software hierarchy by using the display area effectively. This visualization is built by recursively slicing a box into smaller boxes for each level of the hierarchy by utilizing horizontal and vertical slicing. The resulting visualization shows all the elements of the hierarchy, while the paths to these elements are implicitly encoded by the Treemap nesting.

Treemap, the picture is provided by the Treemap History
Circular Treemap, the picture is provided by the Treemap History

In fact, a Circular Treemap is a visualization method based on nested circles where circles consist of subcategories in smaller circles. Displaying the hierarchy using circles instead of rectangles makes it easier to observe groupings and hierarchical organization because all the edges and leaves of the original tree stay visible. Various layouts have been investigated to have circles fill the available space efficiently. Also, some works have provided a Treemap and a circular Treemap in three dimensions by showing the substructure at various levels of elevation in the 3D space.

SHriMP, the picture is provided Chisel website

Storey et al. implemented the Simple Hierarchical Multiperspective (SHriMP) tool. SHriMP combines several graphical high-level visualizations with textual lower level views to simplify navigation within large and complex software. As a matter of fact, SHriMP regroups a set of visualization techniques among which the user can easily switch depending on his or her needs. The most important feature is that each box can demonstrate its corresponding source code. So, this feature makes it possible to have both the source code organization and a miniaturized view of the source code itself in a single visualization. To make easy the browsing source code task, SHriMP has a hypertext browsing technique on object types, attributes, and methods. This means the hyperlinks can be a helpful feature for navigating over the source code by using animated translation and zooming motions over the software visualization. Overall, SHriMP is a suitable visualization tool to consider software structures and browse program source code.

The SHriMP (Simple Hierarchical Multi-Perspective) visualization tool provides a flexible and customizable environment for exploring software programs. It supports the embedding of multiple views, both graphical and textual, within a nested graph display of a program’s software architecture.

Using a real-world metaphor for software visualization

This method includes representing software with a familiar context, by using graphic conventions, that the user immediately understands. In other words, our world, as it is structured, provides a natural way of splitting elements into sub elements. For example, the Earth is divided into countries, countries into cities, cities into districts, and districts contain streets, buildings, gardens, and monuments that themselves consist of buildings and gardens. These various degrees of granularity are used as an analogy for the software hierarchy. For instance, in a possible mapping, the Earth represents the overall system, countries packages, cities files, districts classes, and buildings methods. This type of software visualization supports a large-scale understanding of the overall system more simply.

The city metaphor in SV, the picture is provided by the Springer Journal

Visualizing relationships among main components in the software

Basically, visualizing relationships in the software is a much more difficult task in comparison with visualizing the software hierarchy because components can have a much larger number of relations of many kinds, such as inheritance, method calls, accesses. Furthermore, graphs have all the characteristics required to display relationships among components by exploring software items as nodes and relationships as edges. However, visualizing all software relationships can be equivalent to visualizing a huge graph with a number of different interconnections, particularly for large scale software applications. As a result, the resulting visual representation can be very confusing because of having plenty of edge congestions, overlapping, and occlusions, which makes it almost impossible to consider an individual node. A proper solution for preventing cluttered 2D graphs is 3D representation of the graphs. By utilizing 3D implementation, the user can navigate to find a view without obstruction. However, navigation through a 3D graph is a complicated task. Sometimes, it requires that navigation be started again from the beginning. Some solutions have been recommended, such as restricting the user’s navigation freedom, and generating automatic camera paths through the 3D graph.

Implementing relations among classes of CheckMate via PCVis tool

Using metrics in software visualization

A software metric can be defined as a numeric measure of some property of a piece of software (or its specifications). Software metrics are vital because they provide information about the quality of the software design, and also provide ways to control this quality throughout the software development process. Thus, the software visualization can transform the numerical data provided by metrics into a visual form that enables users to conceptualize and better understand the information. However, the main challenge is to find effective mappings from software metrics to graphical representations.

Software metrics can effectively explain different aspects of complex architectures and systems. Therefore, they are worth combining with UML class diagrams. UML class diagrams provide a representation of the software design, but they display little information. For instance, Termeer et al. proposed the MetricView visualization that displays metric icons on top of UML diagram elements . Bar and pie charts are mapped to metric values, in a configurable way. In addition, a 3D mode of this technique is available just only by turning 2D bars in 3D cuboids.

The goal of MetricView is to give more insight into UML models by visualizing software metrics that have been computed by another tool directly on top of the graphical representation of the UML model. Up to now, these metrics (which are the actual entities that should give you insight into the design) are only available in tabular form, while the UML models have all kinds of neat diagrams. MetricViews goal is to somehow visualize these metrics in the UML model, making it more clear so see what’s right and what’s wrong.

The picture is provided by the MetricView project website

In conclusion

The major of software visualization investigates approaches and methods for static and dynamic graphical representations of algorithms, programs, and processed data. The main objective is to enhance our understanding of intangible software, and to reduce the complexity of systems as well. This essay considered some software visualization techniques and examples that are used mostly in static visualization of source code.

REFERENCES

P Caserta and O Zendra. “Visualization of the static Aspects of Software: A Survey”. IEEE Transaction on Visualization and Computer Graphics. 2011: 913–933.

The city metaphor in software visualization: feelings, emotions, and thinking, Simone Romano and et al., Springer, Multimedia Tools and Applications volume 78, 2019.

Kayvan Kaseb, Mohammad Sayedi, International Journal of Electrical and Computer Engineering (IJECE) Vol. 3, №5, October 2013, pp. 702~707 ISSN: 2088–8708, An Approach for Displaying the Relations among Main Elements of Object-Oriented Programs.

--

--

Kayvan Kaseb
Software Development

Senior Android Developer, Technical Writer, Researcher, Artist, Founder of PURE SOFTWARE YAZILIM LİMİTED ŞİRKETİ https://www.linkedin.com/in/kayvan-kaseb