IP Library › Granted Patent US 11,055,201
Granted Patent B2
US 11,055,201 · App. 16/546,468 · Granted Jul 6, 2021

Method and apparatus for evaluating code in hierarchical architecture software, and storage medium

Inventors: Liang Gao (Beijing, CN); Jie Han (Beijing, CN); Fei Peng (Beijing, CN); Wen Ke Ren (Beijing, CN)
Assignee: SIEMENS AKTIENGESELLSCHAFT
G06F11/3616G06F8/42G06F11/36G06F11/3604
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,055,201
App. No.
16/546,468
Granted
Jul 6, 2021
Kind
B2
Abstract

Embodiments include a method and apparatus for evaluating code in hierarchical architecture software, and a storage medium. The method includes acquiring layer definition information, of hierarchical architecture software to be tested, including layer information and intra-layer component information; scanning code of the hierarchical architecture software to be tested, to acquire basic information of the code including component information, intra-component file information and intra-file code metric information; mapping the basic information with the layer definition information, to obtain file information of each component in each layer of the hierarchical architecture software to be tested and intra-file code metric information; and calculating a code evaluation parameter of the hierarchical architecture software to be tested, based upon the file information of each component in each layer and the intra-file code metric information. The technical solution in embodiments can acquire metric information, relating to layers, of hierarchical architecture software.

Claims (56)

1. A method for evaluating code in hierarchical architecture software, comprising:

acquiring layer definition information of hierarchical architecture software to be tested, the layer definition information including hierarchy information of the hierarchical architecture software to be tested and information of a component included in each layer;

scanning code of the hierarchical architecture software to be tested, to acquire basic information of the code, (A) the basic information including component information, intra-component file information relating the component information to file information, and intra-file code metric information and (B) the intra-file code metric information including a cyclomatic complexity, a dependence number, and at least one of a number of lines of the code and a number of functions of the code;

mapping the basic information with the layer definition information, to obtain file information of each component in each layer of the hierarchical architecture software to be tested and the intra-file code metric information;

calculating a code evaluation parameter of the hierarchical architecture software to be tested, based upon the file information of each component in each layer and the intra-file code metric information, the code evaluation parameter including a degree of coupling of a component and at least one of a layer thickness characterizing a layer software scale and a component thickness characterizing a software scale of each component in each layer;

comparing a thickness of each component with a set component thickness threshold;

taking, upon a component exceeding the set component thickness threshold, the component exceeding the set component thickness threshold as a component to be reconstructed, and acquiring from the basic information the cyclomatic complexity and dependence number of each file in the component to be reconstructed; and

using the cyclomatic complexity and dependence number of each file in the component to be reconstructed to characterize the degree of coupling of the component to be reconstructed;

comparing the cyclomatic complexity of each file in the component to be reconstructed with a cyclomatic complexity threshold;

comparing the dependence number of each file in the component to be reconstructed with a dependence number threshold; and

adaptively presenting the one or more files of the component to be reconstructed as files to be reconstructed based on if the respective file has a cyclomatic complexity greater than the cyclomatic complexity threshold or a dependence number is greater than the dependence number threshold.

2. The method of claim 1 , wherein the code evaluation parameter further includes at least one of a layer complexity and a component complexity, and the method further comprises at least one of:

determining the layer complexity of the hierarchical architecture software to be tested based upon the layer thickness and a set layer thickness threshold; and

determining a complexity of each component in each layer of the hierarchical architecture software to be tested based upon the thickness of each component in each layer and the set component thickness threshold.

3. The method of claim 2 , wherein the scanning of the code of the hierarchical architecture software to be tested, to acquire basic information of the code, comprises:

instructing, based upon a storage type of the hierarchical architecture software to be tested, a scanner of a corresponding type to scan code of the hierarchical architecture software to be tested, to acquire the basic information of the code obtained by scanning by the scanner.

4. The method of claim 2 , further comprising:

presenting, based upon at least one of the layer thickness and a thickness of each component in each layer, at least one of all of the layers of the hierarchical architecture software to be tested and all of the components in each layer via a graph that is directly proportional to the layer thickness and the thickness of each component in each layer.

5. The method of claim 1 , wherein the scanning of the code of the hierarchical architecture software to be tested, to acquire basic information of the code, comprises:

instructing, based upon a storage type of the hierarchical architecture software to be tested, a scanner of a corresponding type to scan code of the hierarchical architecture software to be tested, to acquire the basic information of code obtained by scanning by the scanner.

6. The method of claim 5 , wherein the instructing of the scanner of the corresponding type to the scan code of the hierarchical architecture software to be tested, based upon a storage type of the hierarchical architecture software to be tested, comprises:

instructing, upon the storage type of the hierarchical architecture software to be tested being a file type, a file scanner to the scan code of the hierarchical architecture software to be tested; and

instructing, upon the storage type of the hierarchical architecture software to be tested being a version control system (VCS) type, a VCS scanner to the scan code of the hierarchical architecture software to be tested.

7. The method of claim 6 , further comprising:

presenting, based upon at least one of the layer thickness and the thickness of each component in each layer, at least one of all of the layers of the hierarchical architecture software to be tested and all of the components in each layer via a graph that is directly proportional to the layer thickness and the thickness of each component in each layer.

8. The method of claim 5 , further comprising:

presenting, based upon at least one of the layer thickness and the thickness of each component in each layer, at least one of all of the layers of the hierarchical architecture software to be tested and all of the components in each layer via a graph that is directly proportional to the layer thickness and the thickness of each component in each layer.

9. The method of claim 1 , wherein the scanning of the code of the hierarchical architecture software to be tested, to acquire basic information of the code, comprises:

instructing, based upon a storage type of the hierarchical architecture software to be tested, a scanner of a corresponding type to scan code of the hierarchical architecture software to be tested, to acquire basic information of the code obtained by scanning by the scanner.

10. The method of claim 1 , further comprising:

presenting, based upon at least one of the layer thickness and the thickness of each component in each layer, at least one of all of the layers of the hierarchical architecture software to be tested and all of the components in each layer via a graph that is directly proportional to at least one of the layer thickness and the thickness of each component in each layer.

11. The method of claim 10 , further comprising:

comparing at least one of all of the layer thicknesses and the thickness of each component with a set thickness threshold, and determining whether at least one of a layer and component exceeding the set thickness threshold exists; and

presenting, upon at least one of a layer and component exceeding the thickness threshold, with high brightness a graph corresponding to at least one of the layer and component exceeding the set thickness threshold.

12. The method of claim 11 , further comprising:

determining thickness intervals in which at least one of all of the layer thicknesses and the thicknesses of all of the components in each layer are located, based upon different thickness intervals determined by at least two thickness thresholds of different values; and

presenting at least one of the layers of the hierarchical architecture software to be tested and all of the components in each layer based upon a color corresponding to each thickness interval that is set, via a graph of corresponding colors that are directly proportional to at least one of the layer thicknesses and the thickness of each component in each layer.

13. The method of claim 10 , further comprising:

determining thickness intervals in which at least one of all of the layer thicknesses and the thicknesses of all of the components in each layer are located, based upon different thickness intervals determined by at least two thickness thresholds of different values; and

presenting at least one of the layers of the hierarchical architecture software to be tested and all of the components in each layer based upon a color corresponding to each thickness interval that is set, via a graph of corresponding colors that are directly proportional to at least one of the layer thicknesses and the thickness of each component in each layer.

14. The method of claim 1 , further comprising:

presenting, based upon at least one of the layer thickness and a thickness of each component in each layer, at least one of all of the layers of the hierarchical architecture software to be tested and all of the components in each layer via a graph that is directly proportional to the layer thickness and the thickness of each component in each layer.

15. A non-transitory computer-readable storage medium, storing a computer program, the computer program being executable by a processor to realize the method for evaluating code in the hierarchical architecture software of claim 1 .

16. An apparatus for evaluating code in hierarchical architecture software, comprising:

at least one memory storing a computer program; and

at least one processor, to call the computer program stored in the at least one memory, and to cause the apparatus to perform at least the following:

acquiring layer definition information of hierarchical architecture software to be tested, the layer definition information including hierarchy information of the hierarchical architecture software to be tested and information of a component included in each layer;

scanning code of the hierarchical architecture software to be tested, to acquire basic information of the code, (A) the basic information including component information, intra-component file information relating component information to file information and intra-file code metric information and (B) the intra-file code metric information including a cyclomatic complexity, a dependence number, and at least one of a number of lines of the code and a number of functions of the code;

mapping the basic information with the layer definition information, to obtain file information of each component in each layer of the hierarchical architecture software to be tested and the intra-file code metric information;

calculating a code evaluation parameter of the hierarchical architecture software to be tested, based upon the file information of each component in each layer and the intra-file code metric information, the code evaluation parameter including a degree of coupling of a component and at least one of a layer thickness characterizing a layer software scale and a component thickness characterizing a software scale of each component in each layer;

comparing a thickness of each component with a set component thickness threshold;

taking, upon a component exceeding the set component thickness threshold, the component exceeding the set component thickness threshold as a component to be reconstructed, and acquiring from the basic information the cyclomatic complexity and dependence number of each file in the component to be reconstructed;

using the cyclomatic complexity and dependence number of each file in the component to be reconstructed to characterize the degree of coupling of the component to be reconstructed;

comparing the cyclomatic complexity of each file in the component to be reconstructed with a cyclomatic complexity threshold;

comparing the dependence number of each file in the component to be reconstructed with a dependence number threshold; and

adaptively presenting the one or more files of the component to be reconstructed as files to be reconstructed based on if the respective file has a cyclomatic complexity greater than the cyclomatic complexity threshold or a dependence number is greater than the dependence number threshold.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Oct 31, 2019
From: SIEMENS LTD., CHINA
To: SIEMENS AKTIENGESELLSCHAFT
Reel/Frame 050877/0844 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Oct 29, 2019
From: GAO, LIANG; HAN, JIE; PENG, FEI; REN, WEN KE
To: SIEMENS LTD., CHINA
Reel/Frame 050853/0312 →
Priority Claims (1)
CN 201810968938.0 · Aug 23, 2018 · national
Continuity (1)
Related Publication 20200065227A1 · Feb 27, 2020