CN106980495B - Function reusability measurement method based on program slice - Google Patents

Function reusability measurement method based on program slice Download PDF

Info

Publication number
CN106980495B
CN106980495B CN201611019438.XA CN201611019438A CN106980495B CN 106980495 B CN106980495 B CN 106980495B CN 201611019438 A CN201611019438 A CN 201611019438A CN 106980495 B CN106980495 B CN 106980495B
Authority
CN
China
Prior art keywords
rfm
functional module
reusability
slicing
degree
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611019438.XA
Other languages
Chinese (zh)
Other versions
CN106980495A (en
Inventor
李必信
王桐
万晨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Southeast University
Original Assignee
Southeast University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Southeast University filed Critical Southeast University
Priority to CN201611019438.XA priority Critical patent/CN106980495B/en
Publication of CN106980495A publication Critical patent/CN106980495A/en
Application granted granted Critical
Publication of CN106980495B publication Critical patent/CN106980495B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a program slice-based function reusability measurement method, which comprises the following steps: and constructing a program dependency graph for the source program, and calculating slicing results according to the code behavior slicing rule of the functional interface, wherein each slicing result is a statement related to the corresponding functional module. Constructing a metric index of the functional module based on the slicing result, comprising: the clustering degree, the cohesion degree, the circle complexity degree, the number of common methods, the maximum nesting layer number and the coupling degree mean value of the functional modules. And constructing a calculation formula of the reusability metric value of the functional module according to the metric index, and acquiring the reusability relative value of the functional module, thereby screening out the functional module with higher reusability.

Description

Function reusability measurement method based on program slice
Technical Field
The invention relates to the field of function reusability measurement in the field of software evolution, in particular to a function reusability measurement method based on program slicing.
Background
The modularized development becomes an important core idea in the software development process, and the aim is to effectively reduce the coupling degree between modules in a large-scale software product with complex business logic, facilitate later maintenance of software, facilitate extraction of functional modules, effectively multiplex the functional modules in other software, achieve the aims of reducing development cost and shortening development period, and have very practical significance for improving software reliability and development quality. The measurement of reusability of related codes in software generally comprises two steps, namely firstly, extracting or positioning to multiplexed codes, and then measuring from multiple aspects such as dependency complexity and the like.
The existing code reusability has the following defects in the practical application process:
(1) the multiplex object granularity is larger. The object of the reusability measurement is mostly a component, and a certain specified function in the component is not detailed, so that the multiplexing risk is improved while the multiplexing object scale is increased.
(2) The associated code of the multiplexed object is less accurate. The multiplexing object is associated with related functions or components through the built UML diagram, and specific statements cannot be accurately positioned, so that redundancy and omission of the multiplexing code scale are easily caused;
(3) the difficulty level contrast of the multiplexing of the whole multiplexing objects is lacked. The difficulty of multiplexing the multiplexed object in the source program is not considered from a global perspective, and is not in sharp contrast with other multiplexed objects in the source program.
Disclosure of Invention
The purpose of the invention is as follows: in order to solve the technical problem, the invention provides a function reusability measurement method based on program slicing. The method and the device can realize fine-grained extraction of the multiplexed object and accurate calculation and extraction of the code dependency relationship, and compare reusability of all functional modules in the source program, thereby screening out the functional modules with low multiplexing difficulty.
The technical scheme is as follows: in order to achieve the technical effects, the technical scheme provided by the invention is as follows:
a method for program slice based reusability measurement, the method comprising the steps of:
step 1: constructing a system dependency graph and storing the system dependency graph into a dependency graph knowledge base; the system dependency graph comprises dependency relations between statements and between variables, wherein the dependency relations comprise control dependencies and data dependencies;
step 2: traversing the source program, and extracting functional interface codes of all functional modules in the source program; taking the functional interface code as an initial statement of a corresponding functional module, and storing a file path and a line number of each initial statement as a binary group in an interface knowledge base;
and step 3: taking the functional interface codes extracted in the step 2 as slicing criteria for extracting each functional module to calculate the slicing result of the source program, and storing the slicing criteria and the slicing results into a slicing knowledge base correspondingly; each slicing result corresponds to one functional module, and each slicing result comprises statements related to the slicing criterion in the corresponding functional module;
and 4, step 4: respectively constructing a measurement index for evaluating the reusability of each functional module according to the functional interface codes extracted in the step 2 and the slicing result obtained in the step 3, and calculating the measurement value of each functional module on the measurement index; for any functional module, the measurement indexes are the clustering degree, the cohesion degree, the circle complexity degree, the number of common methods, the maximum nesting layer number and the coupling degree mean value of the module, and the coupling degree mean value is the coupling degree mean value of the functional module and other functional modules;
and 5: according to the measurement indexes constructed in the step 4, the sum of the measurement values of each measurement index is calculated as follows:
Figure GDA0002379200960000021
in the formula, ValueijRepresenting the measurement value of the functional module i in the measurement index j;
step 6: the calculation formula for the reusability metric value of the function module is constructed as follows:
RelativeValue(i)=Clustering(i)per+Cohesion(i)per-Complexity(i)per
-SumMethod(i)per-MaxNextingLayer(i)per-Coupling(i)per
wherein RelativeValue (i) represents a reusability metric of the functional module i, Clusting (i)perRepresents the percentage of the degree of clustering of the functional module i in the sum of the degrees of clustering, Cohesion (i)perRepresents the percentage of the cohesion of the functional Module i in the total of the cohesion, complete (i)perRepresents the percentage of the circle complexity of the functional module i to the sum of the circle complexities, SumMethod (i)perRepresenting the percentage of the number of common methods of the functional module i to the sum of the number of common methods, MaxExtingLayer (i)perRepresents the percentage of the maximum nesting layer number of the functional module i to the sum of the maximum nesting layer numbers, coupling (i)perRepresenting the percentage of the coupling mean value of the functional module i to the total coupling mean value;
and 7: and selecting the functional module according to the reusability metric value of the functional module, wherein the larger the multiplexing value is, the higher the reusability of the corresponding functional module is.
Further, the method for calculating the degree of clustering comprises the following steps:
Figure GDA0002379200960000031
in the formula, clustering (RFM)i) Representing the clustering degree of the functional module i; RFMiRepresents the slicing result corresponding to the functional module i, i belongs to [1, n ∈]N represents the total number of functional modules; k denotes RFMiThe number of the aggregation blocks is RFMiThe statement in (1) is divided into blocks, and RFM is definediAny one of the aggregation blocks is CBk,CBkSatisfies the following conditions:
Figure GDA0002379200960000032
slave RFMiThe method for dividing the aggregation block comprises the following steps:
for RFMiThe statements in (1) are numbered to define the RFMiThe a-th statement in the document S is numbered Sa(ii) a Determining RFMiAny two sentences S in the document Sa、SbWhether the following conditions are simultaneously satisfied:
Sa-1(da-1)≠Sa(da)-1
Sb(db)=Sa(da)+b-a
in the formula (d)a-1、daAnd dbRespectively represent a sentence Sa-1、Sa、SbThe line number in the source program;
and if the judgment result is satisfied, dividing the statements a to b of the file S into an aggregation block.
Further, the calculation method of the cohesion degree comprises the following steps:
Figure GDA0002379200960000033
in the formula, Cohesion (RFM)i) Denotes the degree of cohesion of the functional Module i, M denotes RFMiThe total number of methods contained in (a); x represents RFMiThe xth method in (1), v (x) represents a set of all variables in method x, | Slice (x, v (x)), | white cellsmethodThe expression calculation step: the second slicing is performed on the slicing result of the functional module i by using the variable in v (x) as the slicing criterion,and counting the sum of the method numbers in all secondary slicing results.
Further, the calculation method of the circle complexity degree comprises the following steps:
Complexity(RFMi)=p+1
in the formula, complete (RFM)i) Denotes the degree of circle complexity of the functional module i, p denotes RFMiThe number of the middle judgment nodes; the decision node comprises a statement: for, foreach, if, while, do … while, switch.
Further, the calculation method of the number of the common methods is as follows:
SumMethod(RFMi)=∪mq
in the formula, SumMethod (RFM)i) Representing the number of common methods in functional module i, ∪ representing the symbol of the operation of solving the union set, mqExpressed in RFMiThe variable in the q-th common method is the sum of the number of common methods included in the second slicing result calculated by the slicing criterion.
Further, the method for calculating the maximum number of nested layers is as follows:
MaxNextingLayer(RFMi)=MAX(NL(mq))
wherein, MaxExtingLayer (RFM)i) Represents the maximum number of nesting layers, NL (m), in a functional module iq) Representing common method mqMAX () denotes taking the maximum value.
Further, the calculation method of the coupling degree mean value comprises the following steps:
Figure GDA0002379200960000041
in the formula, Coupling (RFM)i) Mean value representing the degree of coupling of functional module i with other functional modules in the source program, | RFMi∩RFMtI denotes RFMiAnd RFMtNumber of identical sentences, | RFMi∪RFMtI denotes RFMiAnd RFMtThe total number of all statements in (c).
Further, when only 1 method is included in the slicing result, the degree of the implantations thereof is 1.
Further, before step 1, the method further comprises the steps of:
and preprocessing the source program, identifying and deleting empty lines and comment lines in the source program code, and processing all the source codes into all effective code lines.
Further, the method for constructing the system dependency graph in step 1 comprises:
traversing a source program, extracting an abstract syntax tree of the source program, establishing a control flow graph and an inheritance tree according to the abstract syntax tree, calculating data dependence and thread dependence between statements and variables based on the control flow graph and the inheritance tree, and finally integrating the dependence relationship into a system dependence graph.
Has the advantages that: the invention applies the program slicing technology to the measurement of the functional module, and compared with the prior art, the invention has the following advantages:
(1) the invention realizes the analysis of fine-grained objects, can be embodied to a certain statement or even a variable, and is suitable for the reusability measurement of the objects with different granularities;
(2) the invention calculates the associated sentences of the functional module based on the program slicing technology, and has higher accuracy aiming at the associated sentences extracted from the multiplexing objects through the dependency traversal between the sentences and the variables, so that the measurement result has higher reliability;
(3) the method realizes batch measurement, measures reusability of all functional modules in automatic batch, reduces operation complexity and improves average measurement time.
(4) And comparing the reusability of all the functional modules, and screening out the functional modules with relatively high reusability in the source program according to the relative value of the reusability, thereby improving the multiplexing efficiency.
Drawings
FIG. 1 is a schematic flow chart diagram of an embodiment of the present invention;
FIG. 2 is a flow chart of the construction of a program dependency graph in the embodiment.
Detailed Description
The present invention will be further described with reference to the accompanying drawings.
The principle flow of the invention is shown in fig. 1, and comprises the following steps:
s1: the source program is traversed and invalid lines of code, such as empty lines, comment lines, etc., are deleted. By preprocessing, the compactness of the arrangement of effective code lines is realized, and errors generated in the measurement process are reduced;
s2: and analyzing the source program to construct a program dependency graph. The dependency graph comprises dependency relationships among statements and dependency relationships among variables, the dependency relationships mainly comprise control dependencies, data dependencies and the like, and a statement set related to the operation result of a specified statement or variable can be obtained through direct dependencies and indirect dependencies among the statements;
s3: analyzing the source program, taking all interfaces as initial sentences of the functional module, and storing file paths and line numbers of all the sentences as binary groups into an interface knowledge base;
s4: calculating the slice by using the program dependency graph in the S2 and the functional interface set acquired in the step 3 and taking the codes of all interfaces in the functional interface set as a criterion, acquiring an associated statement set and storing the associated statement set in a slice knowledge base;
s5: using the function module interfaces and the associated statement sets thereof acquired in S3 and S4, the following calculation is performed:
(1) clustering degree Clustering: the degree of context closeness of a sliced statement in the source program is measured by the number of aggregated blocks that the original contiguous statements in the sliced result make up.
RFMiStatement contained in a slicing result representing a functional module i, i ∈ [1, n ∈ ]]And n denotes the total number of slices, i.e., the total number of interfaces set in S3. h is the size of the slice, i.e. the number of sentences in the slice, h ═ RFMi|。
CBkIs RFMiIs divided into blocks, denoted as aggregate blocks. Slave RFMiThe method for dividing the aggregation block comprises the following steps:
for RFMiThe statements in (1) are numbered to define the RFMiThe a-th statement in the document S is numbered Sa(ii) a Determining RFMiAny two sentences S in the document Sa、SbWhether the following conditions are simultaneously satisfied:
Sa-1(da-1)≠Sa(da)-1
Sb(db)=Sa(da)+b-a
in the formula (d)a-1、daAnd dbRespectively represent a sentence Sa-1、Sa、SbThe line number in the source program; if the judgment result is satisfied, dividing the statements a to b of the file S into an aggregation block, namely, having | CBkB-a + 1. K is RFMiThe number of the aggregation blocks, and
Figure GDA0002379200960000061
the calculation formula of the clustering degree is as follows:
Figure GDA0002379200960000062
(2) complexity: and showing that the corresponding circle complexity, the number of common methods and the maximum nesting layer number are obtained for a specific certain functional interface slice.
(a) Circle complexity degree:
defining p as the number of decision nodes, the decision nodes include for, foreach, if, while, do … while, switch statement.
The calculation formula of the circle complexity is as follows:
Complexity(RFMi)=p+1
(b) number of common methods: the number of common methods involved in multiplexing the functional module is illustrated by measuring the total number of methods in the functional module slicing result.
r denotes the total number of common methods in the functional module i, mgExpressed in RFMiThe variable in the q-th common method is the sum of the number of common methods contained in the second slicing result obtained by the slicing criterion calculation, and q is equal to [0, r]And ∪ denotes a symbol for solving a joint set operation.
The calculation formula of the public method number is as follows:
SumMethod(RFMi)=∪mg
(c) maximum nesting layer number MaxNestingLayer: the degree of complexity of the logic of the functional module is indicated by measuring the maximum number of nested layers.
The nesting in the method includes all for, foreach, if, while, do … while, switch statements.
NL(mq) Representing common method mqMAX () denotes taking the maximum value.
The maximum nesting layer number is calculated according to the formula:
MaxNextingLayer(RFMi)=MAX(NL(mq))
(3) coupling degree Coupling: and calculating the coupling degree between the modules according to the slice overlapping degree.
RFMi∩RFMtIs RFMiAnd RFMtA set of identical sentences; | RFMi∩RFMtI denotes RFMiAnd RFMtThe number of the identical sentences in the sentence;
RFMi∪RFMtis RFMiAnd RFMtSet of all statements in, | RFMi∪RFMtI denotes RFMiAnd RFMtThe total number of all statements in (c).
The calculation formula of the coupling degree between the functional module i and the functional module t is as follows:
Figure GDA0002379200960000071
(4) cohesion degree Cohesion:
the degree of closeness between the processes within the functional module is shown, the cohesion degree is in the range of [0, 1], and the closer to 1 the cohesion degree is, the better.
Figure GDA0002379200960000072
M represents RFMiTotal number of methods in (1), x denotes RFMiThe xth method in (1), v (x) represents a set of all variables in method x, | Slice (x, v (x)), | white cellsmethodThe expression calculation step: and taking the variable in v (x) as a slicing criterion to carry out secondary slicing on the slicing result of the functional module i, and counting the sum of the method numbers in all secondary slicing results.
S6: counting and calculating the reusability relative value of the functional module in the current source code, and calculating as follows:
(1) the sum of all measurement indexes is counted
In order to measure the size of the metric of the functional module relative to the size of other functional modules, the sum of all the metrics is counted. sumValuejIs the sum of the measurement values of the measurement index j, ValueijRepresenting the metric value of the functional module i in the metric index j.
SumValue as the sum of metricsjThe measurement formula of (2) is:
Figure GDA0002379200960000081
(2) calculating a relative value of reusability of a functional module
And counting the percentage of the measurement indexes of each functional module in the total measurement indexes so as to show the relative value of the reusability of the specified functional module in the whole project.
RelativeValue (i) a reusability metric value representing functional Module i, Clustering (i)perRepresents the percentage of the degree of clustering of the functional module i in the sum of the degrees of clustering, Cohesion (i)perRepresents the percentage of the cohesion of the functional Module i in the total of the cohesion, complete (i)perRepresents the percentage of the circle complexity of the functional module i to the sum of the circle complexities, SumMethod (i)perRepresenting the percentage of the number of common methods of the functional module i to the sum of the number of common methods, MaxExtingLayer (i)perRepresents the percentage of the maximum nesting layer number of the functional module i to the sum of the maximum nesting layer numbers, coupling (i)perRepresents the percentage of the mean value of the coupling of the functional module i to the sum of the mean values of the coupling.
In the above six metrics, the degree of clustering and the degree of cohesion are positively correlated with reusability, and the degree of circle complexity, the number of common methods, and the maximum number of nested layers are negatively correlated with reusability.
The formula for the measure of the relative value of reusability is:
RelativeValue(i)=Clustering(i)per+Cohesion(i)per-Complexity(i)per
-SunMethod(i)per-MaxNextingLayer(i)per-Coupling(i)per
the technical solution is further explained with reference to the drawings and the detailed description. For convenience of description, the technical solution will be described in detail by taking a function module a slicing result as an example. The slicing result obtained by slicing the sentence in line 26 of the file tryvisitor. java as the slicing criterion in the source program is shown in table 1:
TABLE 1
Figure GDA0002379200960000091
As can be seen from the above table, the slicing result of the functional module a includes 9 statements, and the 9 statements belong to two files: tryvisitor. java and compileunit. java; and dividing the 9 sentences into two groups according to the files to which the 9 sentences belong, and numbering each group of sentences.
The reusability measurement of the functional module A is carried out according to the following steps:
step 1: preprocessing a source program, identifying and deleting empty lines and annotation lines in a source code in order to reduce errors of a measurement result, and processing all the source codes into effective code lines;
step 2: traversing a source program, extracting an abstract syntax tree of the program, establishing a control flow graph and an inheritance tree according to the abstract syntax tree, calculating data dependence and thread dependence between statements and variables based on the information, integrating the dependence relationship into a system dependence graph and storing the system dependence graph into a dependence graph knowledge base, wherein the specific processing flow is shown in FIG. 2;
and step 3: traversing the source program, judging an initial statement of the functional module according to the keywords of the source program, and extracting the functional module through traversing the source program; recording basic information of the functional interface, such as a located file path, a line number and the like;
and 4, step 4: taking the functional interface extracted in the step 2 as a slicing criterion for extracting each functional module, and calculating slicing results corresponding to each slicing criterion, wherein each slicing result is associated with one functional module; the slicing result of a function module is a set of necessary sentences related to the function; correspondingly storing the slicing criterion and the slicing result into a slicing knowledge base;
and 5: and measuring the reusability of the functional module, taking the functional module A as an example, and calculating the following steps:
(1) degree of clustering: the degree of context closeness of a sliced statement in the source program is measured by the number of aggregated blocks that the original contiguous statements in the sliced result make up.
RFMAShowing the slicing result, RFM, of functional Block AAContains 9 statements, namely lines 26, 28-30 and 32 of tryvisitor. java in the table above, lines 11-12 and lines 17-18 of compileunit. java. RFMAThe slice size h in (1) is 9, and in 5 sentences belonging to file tryvisitor2,S4The 2 nd statement and the 4 th statement respectively correspond to S (28) and S (30), namely 28 and 30 lines in the source code file, and satisfy 1 is not less than 2 and not more than h, and 1 is not less than 4 and not more than h. S2-1(26)≠S2(28) -1 and S4(30)=S2(28) + (4-2), thus S2~S4Is an aggregated block. RFM according to the above principleAContains 5 aggregation blocks, i.e., K-5.
Calculating the clustering degree of the functional module A according to a measurement formula of the clustering degree:
Figure GDA0002379200960000101
(2) complexity: measuring the complexity of the functional module itself and the associated complexity with other modules mainly includes three aspects: circle complexity, number of common methods, and maximum number of nested layers.
(a) Circle complexity degree: and by measuring the complexity of the circle, the complexity of the judgment structure and the number of independent linear paths are illustrated.
In RFMAIn the formula, p is 1. Calculating according to a measurement formula of circle complexity:
Complexity(RFMA)=p+1=2
(b) total number of common methods: the scale of the method involved in multiplexing the functional module is illustrated by measuring the total number of methods.
Java file belonging to compileunit.mqJava file, m is 2 out of 5 sentences belonging to tryvisitorq1 is ═ 1; therefore, the metric formula according to the common method number calculates:
SunMethod(RFMA)=∪mq=3
(3) maximum number of nested layers: the degree of complexity of the logic of the functional module is indicated by measuring the maximum number of nested layers.
The NL method represents the number of nesting layers in the fetch method, and the MAX method represents the maximum number of nesting layers in the fetch method.
Calculating according to a measurement formula of the maximum nesting layer number MaxNestinLayer:
MaxNextingLayer(RFMA)=MAX(NL(mq))=1
(c) coupling degree: and calculating the coupling degree between the modules according to the slice overlapping degree. Since the coupling degree is a measure of the degree of association between the two modules, the following table takes the functional module B in the source program as an example, and calculates the coupling degree between the functional module B and the functional module a. And calculating to obtain a slicing result corresponding to the functional module B according to the 10 th behavior slicing criterion of the file TryVisitor.
TABLE 2
Figure GDA0002379200960000111
Table 2 contains 14 sentences, and the 14 sentences belong to three files: tryvisitor. java, compileunit. java and astmembrane astrequestor. java, grouping the 14 sentences according to the files to which they belong, and numbering the sentences in each group, with the result of numbering as shown in table 2.
RFMBRepresenting the statement set contained in the functional module B, then:
RFMA={<TryVisitor,{26,28,29,30,32}>,<CompileUnit,{11,12,17,18}>}
RFMB={<TryVisitor,{10,11,12,13,14,17,19,20}>,<CompileUnit,{17,18}>,<ASTFileASTRequestor,{13,14,24,25}>}
RFMB∪RFMA={<TryVisitor,{10,11,12,13,14,17,19,20,26,28,29,30,32}>,<CompileUnit,{11,12,17,18}>,<ASTFileASTRequestor,{13,14,24,25}>}
RFMB∩RFMA={<CompileUnit,{17,18}>}
calculating according to a measurement formula of the coupling degree mean value:
Figure GDA0002379200960000121
(4) degree of cohesion: the degree of closeness between the processes within the functional module is shown, the cohesion degree is in the range of [0, 1], and the closer to 1 the cohesion degree is, the better.
M denotes a function module RFMAThe total number of the methods in (1) is 3, x represents the x-th method, where x is 2, v (2) represents the variable set in method 2, i.e. the variable filePath in the getFilePath method, slicing is performed by using the filePath as the slicing criterion, and then the number of the methods contained in the Slice is counted and is marked as | Slice (x, v (x)), (x)))method. The total number of the methods under the criterion is 3, and the calculation is carried out according to a measurement formula of the cohesion degree:
Figure GDA0002379200960000122
step 6: and integrally evaluating the reusability of the functional module according to the measurement result. To illustrate the overall evaluation process, the measurement results of the reusability metrics of function module a and function module B are listed in the following two tables, as shown in table 3.
TABLE 3
Figure GDA0002379200960000123
(1) Counting the sum of the metric values of all the metrics
In order to measure the size of a certain index of a functional module relative to other functional modules, the sum of various measurement indexes is counted. Through statistics, the sum of the various metrics is shown in table 4:
TABLE 4
Figure GDA0002379200960000124
Figure GDA0002379200960000131
(2) And calculating the reusability relative value of the functional module, taking the module A as an example to calculate the reusability relative value.
Calculating according to a measurement formula of the reusability relative value:
RelativeValue(A)=Clustering(A)per+Cohesion(A)per-Complexity(A)per
-SumMethod(A)per-MaxNextingLayer(A)per-Coupling(A)per
=0.4550+0.3752-0.3333-0.5000-0.6667-0.5000=-1.1698
the reusability relative values of the functional modules a and B were calculated according to the measurement formula of the reusability relative value, and the results are shown in table 5:
TABLE 5
Function module numbering Relative value of reusability
FuncModuleA -1.1698
FuncModuleB -0.8302
And arranging the reusability relative values from large to small, wherein the reusability relative value of the functional module B is greater than that of the functional module A. Therefore, the functional module B has high reusability and is easily multiplexed, compared with the functional module a which has low reusability and high multiplexing difficulty.
The above description is only of the preferred embodiments of the present invention, and it should be noted that: it will be apparent to those skilled in the art that various modifications and adaptations can be made without departing from the principles of the invention and these are intended to be within the scope of the invention.

Claims (10)

1. A method for measuring reusability based on program slices, comprising the steps of:
step 1: constructing a system dependency graph and storing the system dependency graph into a dependency graph knowledge base; the system dependency graph comprises dependency relations between statements and between variables, wherein the dependency relations comprise control dependencies and data dependencies;
step 2: traversing the source program, and extracting functional interface codes of all functional modules in the source program; taking the functional interface code as an initial statement of a corresponding functional module, and storing a file path and a line number of each initial statement as a binary group in an interface knowledge base;
and step 3: taking the functional interface codes extracted in the step 2 as slicing results of slicing criterion calculation source programs for extracting each functional module, and correspondingly storing the slicing criteria and the slicing results into a slicing knowledge base; each slicing result corresponds to one functional module, and each slicing result comprises statements related to the slicing criterion in the corresponding functional module;
and 4, step 4: respectively constructing a measurement index for evaluating the reusability of each functional module according to the functional interface codes extracted in the step 2 and the slicing result obtained in the step 3, and calculating the measurement value of each functional module on the measurement index; for any functional module, the measurement indexes are the clustering degree, the cohesion degree, the circle complexity degree, the number of common methods, the maximum nesting layer number and the coupling degree mean value of the module, and the coupling degree mean value is the coupling degree mean value of the functional module and other functional modules;
and 5: according to the measurement indexes constructed in the step 4, the sum of the measurement values of each measurement index is calculated as follows:
Figure FDA0002379200950000011
in the formula, ValueijThe value of the measurement of the functional module i in the measurement index j is shown, and n represents the total number of the functional modules;
step 6: the calculation formula for the reusability metric value of the function module is constructed as follows:
RelativeValue(i)=Clustering(i)per+Cohesion(i)per-Complexity(i)per-SumMethod(i)per-MaxNextingLayer(i)per-Coupling(i)per
wherein RelativeValue (i) represents a reusability metric of the functional module i, Clusting (i)perRepresents the percentage of the degree of clustering of the functional module i in the sum of the degrees of clustering, Cohesion (i)perRepresents the percentage of the cohesion of the functional Module i in the total of the cohesion, complete (i)perRepresents the percentage of the circle complexity of the functional module i to the sum of the circle complexities, SumMethod (i)perRepresenting the percentage of the number of common methods of the functional module i to the sum of the number of common methods, MaxExtingLayer (i)perRepresents the percentage of the maximum nesting layer number of the functional module i to the sum of the maximum nesting layer numbers, coupling (i)perMean value of degree of coupling representing functional module iPercentage of the sum of the coupling means;
and 7: and selecting the functional module according to the reusability metric value of the functional module, wherein the larger the multiplexing value is, the higher the reusability of the corresponding functional module is.
2. The program slice-based reusability measurement method according to claim 1,
the method for calculating the clustering degree comprises the following steps:
Figure FDA0002379200950000021
in the formula, clustering (RFM)i) Representing the clustering degree of the functional module i; RFMiRepresents the slicing result corresponding to the functional module i, i belongs to [1, n ∈](ii) a K denotes RFMiThe number of the aggregation blocks is RFMiThe statement in (1) is divided into blocks, and RFM is definediAny one of the aggregation blocks is CBk,CBkSatisfies the following conditions:
Figure FDA0002379200950000022
slave RFMiThe method for dividing the aggregation block comprises the following steps:
for RFMiThe statements in (1) are numbered to define the RFMiThe a-th statement in the document S is numbered SaThe b-th sentence is numbered Sb(ii) a Determining RFMiAny two sentences S in the document Sa、SbWhether the following conditions are simultaneously satisfied:
Sa-1(da-1)≠Sa(da)-1
Sb(db)=Sa(da)+b-a
in the formula (d)a-1、daAnd dbRespectively represent a sentence Sa-1、Sa、SbThe line number in the source program;
and if the judgment result is satisfied, dividing the statements a to b of the file S into an aggregation block.
3. The program slice-based reusability measurement method according to claim 2,
the calculation method of the cohesion degree comprises the following steps:
Figure FDA0002379200950000023
in the formula, Cohesion (RFM)i) Denotes the degree of cohesion of the functional Module i, M denotes RFMiThe total number of methods contained in (a); x represents RFMiThe xth method in (1), v (x) represents a set of all variables in method x, | Slice (x, v (x)), | white cellsmethodThe expression calculation step: and taking the variable in v (x) as a slicing criterion to carry out secondary slicing on the slicing result of the functional module i, and counting the sum of the method numbers in all secondary slicing results.
4. The program slice-based reusability measurement method according to claim 3,
the calculation method of the circle complexity degree comprises the following steps:
Complexity(RFMi)=p+1
in the formula, complete (RFM)i) Denotes the degree of circle complexity of the functional module i, p denotes RFMiThe number of the middle judgment nodes; the decision node comprises a statement: for, foreach, if, while, do … while, switch.
5. The program slice-based reusability measurement method according to claim 4, wherein the common method number is calculated by:
SumMethod(RFMi)=∪mq
in the formula, SumMethod (RFM)i) Representing the number of common methods in functional module i, ∪ representing the symbol of the operation of solving the union set, mqExpressed in RFMiThe variable in the q-th common method is included in the second slicing result calculated by the slicing criterionThe sum of the numbers of the public methods involved.
6. The program slice-based reusability measurement method according to claim 5, wherein the maximum number of nested layers is calculated by:
MaxNextingLayer(RFMi)=MAX(NL(mg))
wherein, MaxExtingLayer (RFM)i) Represents the maximum number of nesting layers, NL (m), in a functional module iq) Representing common method mqMAX () denotes taking the maximum value.
7. The program slice-based reusability measurement method according to claim 6, wherein the average coupling value is calculated by:
Figure FDA0002379200950000031
in the formula, Coupling (RFM)i) Mean value representing the degree of coupling of functional module i with other functional modules in the source program, | RFMi∩RFMtI denotes RFMiAnd RFMtNumber of identical sentences, | RFMi∪RFMtI denotes RFMiAnd RFMtThe total number of all statements in (c).
8. The method of claim 7, wherein the degree of inlieration is 1 when only 1 method is included in the slicing result.
9. The program slice-based reusability measurement method according to claim 8, further comprising, before performing step 1, the steps of:
and preprocessing the source program, identifying and deleting empty lines and comment lines in the source program code, and processing all the source codes into all effective code lines.
10. The method for measuring reusability based on program slices according to claim 9, wherein the method for constructing the system dependency graph in step 1 is:
traversing a source program, extracting an abstract syntax tree of the source program, establishing a control flow graph and an inheritance tree according to the abstract syntax tree, calculating data dependence and thread dependence between statements and variables based on the control flow graph and the inheritance tree, and finally integrating the dependence relationship into a system dependence graph.
CN201611019438.XA 2016-11-18 2016-11-18 Function reusability measurement method based on program slice Active CN106980495B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611019438.XA CN106980495B (en) 2016-11-18 2016-11-18 Function reusability measurement method based on program slice

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611019438.XA CN106980495B (en) 2016-11-18 2016-11-18 Function reusability measurement method based on program slice

Publications (2)

Publication Number Publication Date
CN106980495A CN106980495A (en) 2017-07-25
CN106980495B true CN106980495B (en) 2020-04-14

Family

ID=59340461

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611019438.XA Active CN106980495B (en) 2016-11-18 2016-11-18 Function reusability measurement method based on program slice

Country Status (1)

Country Link
CN (1) CN106980495B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110515823B (en) * 2018-05-21 2023-04-07 百度在线网络技术(北京)有限公司 Program code complexity evaluation method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622556A (en) * 2011-12-22 2012-08-01 南京邮电大学 Web service security analysis method based on program slicing technique
CN103970845A (en) * 2014-04-28 2014-08-06 南京邮电大学 Webpage filtering method based on program slicing technology
CN105787369A (en) * 2016-02-29 2016-07-20 南京邮电大学 Android software security analysis method based on slice measurement

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9323501B1 (en) * 2014-02-24 2016-04-26 Tibco Software Inc. Modularized XML namespaces

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622556A (en) * 2011-12-22 2012-08-01 南京邮电大学 Web service security analysis method based on program slicing technique
CN103970845A (en) * 2014-04-28 2014-08-06 南京邮电大学 Webpage filtering method based on program slicing technology
CN105787369A (en) * 2016-02-29 2016-07-20 南京邮电大学 Android software security analysis method based on slice measurement

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"程序切片技术及其在面向对象软件度量和软件测试中的应用";李必信;《中国博士学位论文全文数据库信息科技辑》;20050831(第8期);I138-8 *

Also Published As

Publication number Publication date
CN106980495A (en) 2017-07-25

Similar Documents

Publication Publication Date Title
Carstens et al. How to fail at species delimitation
CN107391353B (en) Method for detecting abnormal behavior of complex software system based on log
Ekanayake et al. Slice, mine and dice: Complexity-aware automated discovery of business process models
Kitazoe et al. Robust time estimation reconciles views of the antiquity of placental mammals
CN107168995B (en) Data processing method and server
CN104756106A (en) Characterizing data sources in a data storage system
CN106528428B (en) A kind of construction method of software mutability prediction model
CN105279397A (en) Method for identifying key proteins in protein-protein interaction network
CN111324781A (en) Data analysis method, device and equipment
CN111859047A (en) Fault solving method and device
CN111446002A (en) Novel coronavirus patient state of illness classification system based on artificial intelligence
CN110335641B (en) Four-body combination genetic relationship identification method and device
CN108920601B (en) Data matching method and device
CN106980495B (en) Function reusability measurement method based on program slice
Anchang et al. CCAST: a model-based gating strategy to isolate homogeneous subpopulations in a heterogeneous population of single cells
CN103902798A (en) Data preprocessing method
CN103136440B (en) Data processing method and device
Lai Fitting power law distributions to data
CN106776704B (en) Statistical information collection method and device
CN104536879A (en) Fuzzy clustering based multi-error positioning method
CN108961071A (en) The method and terminal device of automatic Prediction composite service income
Brazeau et al. Morphological phylogenetic analysis with inapplicable data
CN112907055A (en) Data processing aging test method and device
CN107730021A (en) A kind of operational indicator optimization method and device
Macnair et al. Tree‐ensemble analysis assesses presence of multifurcations in single cell data

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant