System and method for visualizing software programs

A system and a method for visualizing a software program are provided. The system is configured to store the software program and its change logs. The system is further configured to generate a visualization structure of the software program according to at least one of Data Clumps information, Divergence Change information and Shotgun Surgery information, and display the software program according to the visualization structure. The method is applied to the system to implement the operations.

PRIORITY

This application claims priority to Taiwan Patent Application No. 103134342 filed on Oct. 2, 2014, which is hereby incorporated by reference in its entirety.

FIELD

The present invention relates to a system and a method for processing software programs. More particularly, the present invention relates to a system and a method for visualizing software programs.

BACKGROUND

Software programs have become an essential technology for computer science and technology industries. To determine whether a software program can operate normally, various analysis and debugging operations have to be made. To facilitate the analysis and debugging of software programs, software visualization technologies have attracted much attention.

As the computational load and computational complexity increases, the scale of software programs have become increasingly larger. Correspondingly, it will be more difficult to analyze large-scale software programs. For example, problems such as insufficient program comments, lack of test codes or the like are often encountered during the analysis of large-scale software programs. In addition, a large-scale software program usually must be processed by a number of persons so that problems such as maintaining the integrity of joined codes and the habit of compiling codes or the like become great concern. Because of different habits of compiling programs, coupling and cohesion tend to arise in large-scale software programs. The term “coupling” generally refers to the relevance between a plurality of program modules in a software program, and the term “cohesion” generally refers to cohesion of a plurality of program codes in a single program module of a software program. However, conventional software visualization technologies are unable to effectively highlight regions where the coupling and cohesion occur in a large-scale software program.

Accordingly, it is important to provide an effective software visualization technology for large-scale software programs in the art.

SUMMARY

An objective of the present invention includes providing an effective software visualization technology for large-scale software programs.

To achieve the objective, certain embodiments of the present invention include a system for visualizing a software program. The system comprises a storage device, a processing device and a display device. The storage device is configured to store the software program and change logs thereof. The software program comprises a plurality of class codes. Each of the class codes comprises a plurality of method codes, and each of the method codes comprises a plurality of parameters. The processing device is configured to create a visualization structure of the software program according to at least one of Data Clumps information, Divergence Change information and Shotgun Surgery information. The processing device calculates correlations between attributes of the class codes to detect Data Clumps of the software program and obtain the Data Clumps information therefrom. The processing device calculates correlations between the method codes according to the change logs to detect Divergence Change of the software program and obtain the Divergence Change information therefrom. The processing device calculates correlations between the class codes according to the change logs to detect Shotgun Surgery of the software program and obtain the Shotgun Surgery information therefrom. The display device is configured to display the software program according to the visualization structure.

To achieve the objective, certain embodiments of the present invention include a method for visualizing a software program. The method comprises the following steps:

(a) enabling a storage device to store the software program and change logs thereof, wherein the software program comprises a plurality of class codes, each of the class codes comprises a plurality of method codes, and each of the method codes comprises a plurality of parameters;

(b) enabling a processing device to create a visualization structure of the software program according to at least one of Data Clumps information, Divergence Change information and Shotgun Surgery information, wherein the processing device calculates correlations between attributes of the class codes to detect Data Clumps of the software program and obtain the Data Clumps information therefrom, calculates correlations between the method codes according to the change logs to detect Divergence Change of the software program and obtain the Divergence Change information therefrom, and calculates correlations between the class codes according to the change logs to detect Shotgun Surgery of the software program and obtain the Shotgun Surgery information therefrom; and

(c) enabling a display device to display the software program according to the visualization structure.

According to the above descriptions, the present invention provides a system and a method for visualizing a software program. The system and the method according to the present invention can create a visualization structure of a software program according to at least one of Data Clumps information, Divergence Change information and Shotgun Surgery information, and display the software program according to the visualization structure. Because Divergence Change is a main reason why cohesion occurs in a software program, regions where the cohesion occurs in the software program can be effectively highlighted in the visualization structure created by the present invention according to the Divergence Change information. Additionally, because Data Clumps and Shotgun Surgery are main reasons why coupling occurs in a software program, regions where the coupling occurs in the software program can be effectively highlighted in the visualization structure created by the present invention according to the Data Clumps information and the Shotgun Surgery information. Accordingly, the present invention can provide an effective software visualization technology for large-scale software programs.

The detailed technology and preferred embodiments implemented for the present invention are described in the following paragraphs accompanying the appended drawings for persons skilled in the art to well appreciate the features of the claimed invention.

DETAILED DESCRIPTION

The content of the present invention will be explained with reference to example embodiments thereof. However, the following example embodiments are not intended to limit the present invention to any specific embodiments, examples, environment, applications, structures, process flows, or steps as described in these example embodiments. In other words, the description of the following example embodiments is only for the purpose of explaining the present invention rather than to limit the present invention.

In the drawings, elements not directly related to the present invention are all omitted from the depiction. Dimensional relationships among individual elements are illustrated only for ease of description but not to limit the actual scale.

An embodiment of the present invention (briefly called “a first embodiment”) is a system for visualizing a software program.FIG. 1is a schematic structural view of the system. As shown inFIG. 1, the system1may comprise a storage device11, a processing device13and a display device15. The storage device11, the processing device13and the display device15may be electrically connected with each other directly or indirectly and communicate with each other. The system1may be a computer system or a cloud system.

The storage device11is configured to store at least one software program111, which may be generated by various different program compiling tools.FIG. 2is a schematic view illustrating the components of the software program111. As shown inFIG. 2, like common software programs, the software program111may substantially comprise a plurality of class codes20, each of the class codes may substantially comprise a plurality of method codes22, and each of the method codes may substantially comprise a plurality of parameters24. Each of the class codes20may have at least one attribute, and the at least one attribute may correspond to the class code20, the method codes22comprised in the class code20and/or the parameters24comprised in each of the method codes.

The storage device11may be further configured to store change logs113of the software program111. The change logs113are configured to record historical logs of the changes once performed on the class codes20, the method codes22and the parameters24respectively, including the historical logs of modifications, updating, debugging or the like that have once been performed.

Optionally, the storage device11may further comprise a database115. The database115may store at least one open software program corresponding to the software program111. Specifically, the at least one open software program is related to the software program111, and is an open software program (e.g., open codes provided by the Android system, the apache system and the Chrome system) that are generally recognized by experts. These open codes may be open codes of nightly builds or may be open codes released through standard formulation. The at least one open software program stored in the database115may comprise a plurality of class codes20, each of the class codes may substantially comprise a plurality of method codes22, and each of the method codes may substantially comprise a plurality of parameters24. Each of the class codes may have at least one attribute, which may correspond to the class code, the method codes comprised in the class code and/or parameters comprised in each of the method codes. However, the at least one open software program stored in the database115does not comprise the software program111itself.

In a case where the storage device11comprises the database115, the processing device13may preliminarily analyze the software program111according to the at least one open software program stored in the database115. Specifically, the processing device13may calculate the number of columns of each of the class codes, the number of columns of each of the method codes, the number of parameters comprised in each of the method codes and the number of attributes that are identical among different class codes in the at least one open software program stored in the database115. Then, the processing device13may define at least one threshold according to the number of columns of each of the class codes, the number of columns of each of the method codes, the number of parameters comprised in each of the method codes and the number of attributes that are identical among different class codes in the at least one open software program.

For example, the processing device13may calculate a statistical parameter (e.g., an average value and/or a standard deviation) according to the number of columns of each of the class codes, the number of columns of each of the method codes, the number of parameters comprised in each of the method codes and the number of attributes that are identical among different class codes in the at least one open software program respectively. Then, the processing device13may define a threshold according to each of the statistical parameters respectively, or define a common threshold according to these statistical parameters.

After having defined the at least one threshold, the processing device13may determine whether a corresponding portion in the software program111exceeds the at least one threshold. For example, the processing device13may define a threshold according to the number of columns of a certain class code in the at least one open software program, and then determine whether the number of columns of the corresponding class code20in the software program111exceeds the threshold. Similarly, the processing device13may define a threshold according to the number of columns of a certain method code, the number of columns of a certain method code, the number of parameters comprised in a certain method code or the number of attributes that are identical among different class codes in the at least one open software program, and then determine whether the number of columns of the corresponding method code22, the number of parameters24comprised in the corresponding method code22, or the number of attributes that are identical among the corresponding different class codes20exceeds the threshold. Because what stored in the database is an open software program generally recognized by the experts, the possibility that the coupling, cohesion or other problems would occur in the software program111is relatively high if the corresponding portion in the software program111exceeds the threshold defined above.

After having determined that the corresponding portion in the software program111exceeds the at least one threshold, the processing device13may create a visualization structure of the software program111according to at least one of Data Clumps information, Divergence Change information and Shotgun Surgery information. However, in a case where the storage device11does not comprise the database115, the processing device13may also create a visualization structure of the software program111directly according to at least one of the Data Clumps information, the Divergence Change information and the Shotgun Surgery information. After the visualization structure is created by the processing device13, the display device15may be used to display the software program111according to the visualization structure. The display device15may be one of the known display devices, such as an LCD, a diode display, a touch display and etc.

The Data Clumps information may comprise various information of Data Clumps that occur in the software program111. Data Clumps generally refer to a phenomenon in which the same attribute occurs in different class codes20of the software program111. Data Clumps is also a main reason why coupling occurs in the software program111. To obtain the Data Clumps information, the processing device13may calculate correlations between the attributes of the class codes20of the software program111to detect whether there are Data Clumps in the software program111.

The Divergence Change information comprises various information of Divergence Change that occurs in the software program111. Divergence Change generally refers to a phenomenon in which a plurality of method codes22having the same change occur in a certain class code20of the software program111, and it is also a main reason why cohesion occurs in the software program111. For example, the reason why a plurality of method codes22have a same change in a class code20is probably that the functions, such as calling, referring and so on, usually create some dependency between different method codes22or between the parameters24comprised in different method codes22. To obtain the Divergence Change information, the processing device13may calculate correlations between method codes22comprised in each of the class codes20in the software program111according to the change logs113to detect whether Divergence Change occurs in the software program111. Substantially, various known correlation algorithms may be adopted to calculate the correlations between the method codes22comprised in each of the class codes20.

The Shotgun Surgery information comprises various information of Shotgun Surgery that occurs in the software program111. Shotgun Surgery generally refers to a phenomenon in which different class codes20in the software program111have the same change, and it is also a main reason why coupling occurs in the software program111. For example, the reason why a plurality of class codes20have the same change is probably that the functions, such as calling, referring, and so on, usually create dependency between different class codes20, between the method codes22comprised in different class codes20, and/or between the parameters24comprised in the method codes22of the different class codes20. To obtain the Shotgun Surgery information, the processing device13may calculate correlations between the class codes20comprised in the software program111according to the change logs113to detect whether Shotgun Surgery occurs in the software program111.

Substantially, various known correlation algorithms may be adopted to calculate the correlations between the class codes20.

Optionally, the processing device13may calculate the correlations between the attributes of the class codes20, the correlations between the method codes22and the correlations between the class codes20in the software program111in series or in parallel. When they are calculated in series, the sequence of calculating the three kinds of correlations may be altered as needed.

Optionally, the visualization structure created by the processing device13for the software program111may be a hierarchical structure. The hierarchical structure may comprise a plurality of layers, which are used to represent information corresponding to different layers. For example, the class codes20comprised in the software program111may correspond to a first layer of the hierarchical structure. The method codes22, the parameters24and the related attributes thereof comprised in the software program111may correspond to a second layer of the hierarchical structure.

Optionally, the display device15may display the visualization structure created by the processing device13for the software program111according to different colors, frame lines, connection lines and/or outlines.FIG. 3AandFIG. 3Bwill be taken as an example to describe the visualization structure created by the processing device13for the software program111.FIG. 3Ais a schematic view illustrating a first layer of a visualization structure of the software program111, whileFIG. 3Bis a schematic view illustrating a second layer of a visualization structure of the software program111.

As shown inFIG. 3A, a first layer40of a visualization structure of the software program111comprises a plurality of class codes20a˜201; and each of the class codes20a˜201is shown in a rectangular outline. The correlations between the class codes20a˜201may be represented by connection lines. For example, solid lines represent implementation relations and association relations, while dotted lines represent inheritance relations. The solid lines may be further subdivided according to different endpoint symbols used. For example, arrows represent implementation relations and straight lines represent association relations. Additionally, an end that has an endpoint symbol of each of the solid lines and the dotted lines may represent the reference direction. As shown inFIG. 3A, the class code20gand the class code20chave a connection relation according to the type of the connection line. That is, the class code20cis considered as a reference variable in the class code20g.For example, if the class code20gcorresponds to a phone, then the class code20ccorresponds to buttons on the phone. Additionally, the display device15may use different colors to represent alerting degrees of the class code20b.For example, a green background may be used to represent that it is safe, a yellow background may be used to represent that attention should be paid, and a red background may be used to represent that it is dangerous. The number, positions, presentation manners and connection manners of the class codes20a˜201shown inFIG. 3Aare only described as an exemplary example of this embodiment, but are not intended to limit the present invention.

As shown inFIG. 3B, a second layer42of a visualization structure of the software program111presents the method codes22and the attributes26comprised in a certain class code20shown inFIG. 3A. Each of the method codes22is displayed in a hexagonal outline, and each of the attributes26is displayed in an elliptical outline. The number of parameters comprised in each method code22may be represented by different colors or types of the frame lines. For example, a hexagon enclosed by red frame lines represents that the corresponding method code22comprises a relatively large number of parameters, and a hexagon enclosed by green frame lines represents that the corresponding method code22comprises a relatively small number of parameters. The number, positions, presentation manners and connection manners of the class codes20, the method codes22and the attributes26shown inFIG. 3Bare only described as an exemplary example of this embodiment, but are not intended to limit the present invention.

Optionally, the display device15may continuously display the first layer40of the hierarchical structure and selectively display the second layer42of the hierarchical structure. For example, the display device15may initially present the plurality of class codes20and related information thereof as shown inFIG. 3A; and after a certain class code20shown inFIG. 3Ais clicked by a user, the display device15then unfolds the method codes22, the attributes26and the related information comprised in the class code20that is clicked in a manner as shown inFIG. 3B. If the user clicks the unfolded class code20another time, then the display device15will present the class codes20and the related information thereof again in a manner as shown inFIG. 3A.

In other embodiments, the visualization structure created by the processing device13for the software program111may further comprise a third layer (not shown). Specifically, when the user clicks a certain method code22shown inFIG. 3B, a source code of the method code22may be displayed on the third layer; and if the user clicks the method code22another time, then the display returns to the content displayed by the second layer42.

When coupling and cohesion occur in the software program111, a Data Clumps relevance60shown inFIG. 4A, a Divergence Change relevance62shown inFIG. 4Band a Shotgun Surgery relevance64shown inFIG. 4Cmay be incorporated into the visualization structure created by the processing device13for the software program111to highlight the regions where the coupling and cohesion occur in the software program111. The content shown inFIGS. 4A˜4B is only described as an example of this embodiment, but is not intended to limit the present invention.

For the software program111, the processing device13may create a Data Clumps relevance for attributes that are identical among different class codes20according to the aforesaid data clumps information. For example, as shown inFIG. 4A, assume that the processing device13determines that the same attributes between the class code20band the class code20fare attributes26a,26b,26cand26d.Then, the processing device13determines that there is a Data Clumps phenomenon occurs in the software program111and connects the class code20b, the class code20fand the attributes26a˜26dto create a Data Clumps relevance60. Then, the Data Clumps relevance60will be incorporated into the visualization structure created by the processing device13for the software program111, and the display device15will display the Data Clumps relevance60together when displaying the visualization structure.

For the software program111, the processing device13may create a Divergence Change relevance for a plurality of method codes having the same change in each of the class codes20according to the aforesaid Divergence Change information. For example, as shown inFIG. 4B, assume that the processing device13finds, according to the change logs113, that the method codes22a,22band22chave a same change (e.g., have once been commonly modified, updated, debugged or the like) and the method codes22dand22ehave a same change (e.g., have once been commonly modified, updated, debugged or the like) in the class code20b.Then, the processing device13determines that there is a Divergence Change phenomenon occurring in the software program111, and groups the method codes22a˜22cthat have a same change into a first group, groups the method codes22d˜22ethat have a same change into a second group, and groups the method code22finto a third group to create a Divergence Change relevance62. Method codes22that belong to a same group are disposed adjacent to each other to be separated from other groups. Then, the Divergence Change relevance62will be incorporated into the visualization structure created by the processing device13for the software program111, and the display device15will display the Divergence Change relevance62together when displaying the visualization structure.

For the software program111, the processing device13may create a Shotgun Surgery relevance for a plurality of class codes20having the same change according to the aforesaid Shotgun Surgery information. For example, as shown inFIG. 4C, assume that the processing device13finds, according to the change logs113, that the class codes20a,20b,20cand20dhave a same change (e.g., have once been commonly modified, updated, debugged or the like) and the class codes20eand20fhave a same change (e.g., have once been commonly modified, updated, debugged or the like). Then, the processing device13determines that there is a Shotgun Surgery phenomenon occurring in the software program111, and groups the class codes20a˜20dthat have a same change into a first group and groups the class codes20e˜20fas a second group to create a Shotgun Surgery relevance64. Class codes20that belong to a same group are disposed adjacent to each other to be separated from other groups. Then, the Shotgun Surgery relevance64will be incorporated into the visualization structure created by the processing device13for the software program111, and the display device15will display the Shotgun Surgery relevance64together when displaying the visualization structure.

Another embodiment of the present invention (briefly called “a second embodiment”) is a method for visualizing a software program.FIG. 5is a schematic view illustrating the method disclosed in the second embodiment. As shown inFIG. 5, the method disclosed in this embodiment comprises the following steps: a step S21of enabling a storage device to store the software program and change logs thereof, wherein the software program comprises a plurality of class codes, each of the class codes comprises a plurality of method codes, and each of the method codes comprises a plurality of parameters; a step S23of enabling a processing device to create a visualization structure of the software program according to at least one of Data Clumps information, Divergence Change information and Shotgun Surgery information, wherein the processing device calculates correlations between attributes of the class codes to detect Data Clumps of the software program and obtain the Data Clumps information therefrom, calculates correlations between the method codes according to the change logs to detect a divergence change of the software program and obtain the divergence change information therefrom, and calculates correlations between the class codes according to the change logs to detect Shotgun Surgery of the software program and obtain the Shotgun Surgery information therefrom; and a step S25of enabling a display device to display the software program according to the visualization structure.

The storage device, processing device and display device described in the steps S21˜S25may substantially correspond to the storage device11, the processing device13and the display device15of the aforesaid embodiment respectively. Additionally, the order in which the steps S21˜S25are presented is not intended to limit the present invention, and may be adjusted appropriately without departing from the spirits of the present invention.

As an exemplary example of this embodiment, the step S23further comprises the following step: enabling the processing device to create a Data Clumps relevance for attributes that are identical among different class codes according to the Data Clumps information, create a Divergence Change relevance for a plurality of method codes having a same change in a class code according to the Divergence Change information, create a Shotgun Surgery relevance for a plurality of class codes having a same change according to the Shotgun Surgery information, and incorporate at least one of the Data Clumps relevance, the Divergence Change relevance and the Shotgun Surgery relevance into the visualization structure.

As an exemplary example of this embodiment, the storage device comprises a database which stores at least one open software program corresponding to the software program. Additionally, the step S23further comprises the following step: enabling the processing device to further define at least one threshold according to the number of columns of each of the class codes, the number of columns of each of the method codes, the number of parameters comprised in each of the method codes and the number of attributes that are identical among different class codes in the at least one open software program, and only when a corresponding portion of the software program exceeds the at least one threshold, create the visualization structure according to at least one of the Data Clumps information, the Divergence Change information and the Shotgun Surgery information.

As an exemplary example of this embodiment, the processing device calculates the correlations between attributes of the class codes, the correlations between the method codes and the correlations between the class codes in series or in parallel.

As an exemplary example of this embodiment, the visualization structure is a hierarchical structure, the class codes of the software program correspond to a first layer of the hierarchical structure, and the method codes, the parameters and the attributes correspond to a second layer of the hierarchical structure.

As an exemplary example of this embodiment, the visualization structure is a hierarchical structure, the class codes of the software program correspond to a first layer of the hierarchical structure, and the method codes, the parameters and the attributes correspond to a second layer of the hierarchical structure. Additionally, the display device continuously displays the first layer of the hierarchical structure and selectively displays the second layer of the hierarchical structure.

As an exemplary example of this embodiment, the visualization structure is a hierarchical structure, the class codes of the software program correspond to a first layer of the hierarchical structure, and the method codes, the parameters and the attributes correspond to a second layer of the hierarchical structure. Additionally, the display device displays the hierarchical structure according to colors, frame lines, connection lines and outlines.

The method disclosed in the second embodiment substantially comprises the steps corresponding to all the operations of the system1disclosed in the first embodiment. Because the corresponding steps not described in the second embodiment can be readily understood by those of ordinary skill in the art of the present invention according to related disclosures of the aforesaid embodiment, they will not be further described herein.

According to the above descriptions, the present invention provides a system and a method for visualizing a software program. The system and the method according to the present invention can create a visualization structure of a software program according to at least one of Data Clumps information, Divergence Change information and Shotgun Surgery information, and display the software program according to the visualization structure. Because Divergence Change is a main reason why cohesion occurs in a software program, regions where the cohesion occurs in the software program can be effectively highlighted in the visualization structure created by the present invention according to the Divergence Change information. Additionally, because Data Clumps and Shotgun Surgery are main reasons why coupling occurs in a software program, regions where the coupling occurs in the software program can be effectively highlighted in the visualization structure created by the present invention according to the Data Clumps information and the Shotgun Surgery information. Accordingly, the present invention can provide an effective software visualization technology for large-scale software programs.