CN106980495A - A kind of function reusability metrics method based on program slice - Google Patents

A kind of function reusability metrics method based on program slice Download PDF

Info

Publication number
CN106980495A
CN106980495A CN201611019438.XA CN201611019438A CN106980495A CN 106980495 A CN106980495 A CN 106980495A CN 201611019438 A CN201611019438 A CN 201611019438A CN 106980495 A CN106980495 A CN 106980495A
Authority
CN
China
Prior art keywords
rfm
functional module
reusability
degree
represent
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.)
Granted
Application number
CN201611019438.XA
Other languages
Chinese (zh)
Other versions
CN106980495B (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

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

Abstract

The present invention proposes a kind of function reusability metrics method based on program slice, and this method comprises the following steps:To source program constructor dependency graph, section result is calculated with the code behavior slice criterion where functional interface, each section result is the sentence of association corresponding function module.Based on the Measure Indexes of section result constructing function module, including:The clustering degree of functional module, cohesion degree, cyclomatic complexity, public method number, the maximum nested number of plies and degree of coupling average.According to Measure Indexes constructing function module reusability metrics value calculation formula, the reusability relative value of functional module is obtained, so as to filter out the higher functional module of reusability.

Description

A kind of function reusability metrics method based on program slice
Technical field
It is especially a kind of to be based on program slice the present invention relates to the function reusability metrics field in Software Evolution field Function reusability metrics method.
Background technology
Development of Modular has become core concept important in software development process, and the purpose is in extensive, business The degree of coupling between module can be effectively reduced in the complicated software product of logic, is easy to software later maintenance, while also can Enough it is easy to the extraction of functional module, efficient multiplexing reaches reduction development cost and shorten the construction cycle in other software Purpose, has very real meaning to improving software reliability and development quality.To correlative code reusability in software Measurement generally includes two steps, is the code for extracting or navigating to multiplexing first, followed by from dependence complexity etc. in many ways Measured in face.
Existing code reuse deficiency in the presence of actual application is:
(1) multiplexing object granularity is larger.The object measured to durability is component mostly, is not refine to a certain in component The individual function of specifying, multiplexing risk is improved while adding multiplexing object scale.
(2) the association code precision of multiplexing object is relatively low.By the uml diagram of foundation will be multiplexed object and correlation function or Component is associated, it is impossible to be accurately positioned specific sentence, so as to easily cause the redundancy and gaps and omissions of multiplexing code size;
(3) the multiplexing complexity contrast of all multiplexing objects is lacked.Multiplexing difficulty or ease journey to being multiplexed object in source program Degree lacks the consideration of global angle, does not have striking contrast with other multiplexing objects in source program.
The content of the invention
Goal of the invention:In order to solve the above technical problems, the present invention provides a kind of function reusability based on program slice Measure.The present invention can realize the fine granularity extraction and accurate calculation and the extraction of code dependence to being multiplexed object, And the reusability of all functional modules in source program is contrasted, so as to filter out the relatively low functional module of multiplexing difficulty.
Technical scheme:To realize above-mentioned technique effect, technical scheme proposed by the present invention is:
A kind of reusability metrics method based on program slice, this method comprises the following steps:
Step 1:Constructing system dependency graph, and system dependence graph is stored in dependency graph knowledge base;The system dependence graph bag The dependence between the dependence and variable between sentence is included, the dependence includes control and relied on and data dependence;
Step 2:Source program is traveled through, the functional interface code of all functional modules in source program is extracted;By function Interface code and regard the file path and line number where each start statement as two as the start statement of corresponding function module In tuple deposit interface knowledge base;
Step 3:Calculated the functional interface code extracted in step 2 as the slice criterion for extracting each functional module The section result of source program, and by the slice criterion deposit section knowledge base corresponding with section result;Each section result Correspondence One function module, section result includes sentence associated with slice criterion in corresponding function module;
Step 4:Section result according to being obtained in the functional interface code and step 3 extracted in step 2 is built respectively For evaluating the Measure Indexes of each functional module reusability, and calculate metric of each functional module on Measure Indexes;It is right In any one functional module, its Measure Indexes is the clustering degree of the module, cohesion degree, cyclomatic complexity, public method number, maximum The nested number of plies and the degree of coupling average, the degree of coupling average is that the degree of coupling of the functional module and other functional modules is averaged Value;
Step 5:The Measure Indexes constructed according to step 4, calculate each single item Measure Indexes metric summation be:
In formula, ValueijRepresent metrics of the functional module i in Measure Indexes j;
Step 6:Constructing function module reusability metrics value calculation formula is:
RelativeValue (i)=Clustering (i)per+Cohesion(i)per-Complexity(i)per
-SumMethod(i)per-MaxNextingLayer(i)per-Coupling(i)per
In formula, RelativgValue (i) represents functional module i reusability metrics value, Clustering (i)perTable Show that functional module i clustering degree accounts for the percentage of clustering degree summation, Cohesion (i)perRepresent that functional module i cohesion degree is accounted for The percentage of cohesion degree summation, Complexity (i)perRepresent that functional module i cyclomatic complexity accounts for the percentage of cyclomatic complexity summation Than SumMethod (i)perRepresent that functional module i public method number accounts for the percentage of public method number summation, MaxNextingLayer(i)perRepresent that the functional module i nested number of plies of maximum accounts for the percentage of maximum nested number of plies summation, Coupling(i)perRepresent that functional module i degree of coupling average accounts for the percentage of degree of coupling average summation;
Step 7:Functional module is chosen according to functional module reusability metrics value, multiplexing value is bigger, represent corresponding function The reusability of module is higher.
Further, the computational methods of the clustering degree are:
In formula, clustering (RFMi) represent functional module i clustering degree;RFMiRepresent the corresponding sections of functional module i As a result, i ∈ [1, n], n represents the sum of functional module;K represents RFMiThe number of middle aggregation block, the aggregation block is RFMiIn Sentence divided block, defines RFMiIn any one aggregation block be CBk, CBkMeet:
From RFMiIn mark off the method for an aggregation block and be:
To RFMiIn sentence be numbered, define RFMiIn belong to file S a articles statement number be Sa;Judge RFMi In belong to file S any two sentence Sa、SbWhether following condition is met simultaneously:
Sa-1(da-1)≠Sa(da)-1
Sb(db)=Sa(da)+b-a
In formula, da-1、daAnd dbSentence S is represented respectivelya-1、Sa、SbLine number in source program;
If file S a~b articles sentence is divided into an aggregation block by judged result to meet.
Further, the computational methods of the cohesion degree are:
In formula, Cohesion (RFMi) functional module i cohesion degree is represented, M represents RFMiIn the sum of method that includes;x Represent RFMiIn x-th of method, the set of all variables in v (x) method for expressing x, | Slice (x, v (x)) |methodRepresent Calculation step:Section result by slice criterion of the variable in v (x) to functional module i carries out second of section, and statistics is all Side operator sum in secondary section result.
Further, the computational methods of the cyclomatic complexity are:
Complexity(RFMi)=p+1
In formula, Complexity (RFMi) functional module i cyclomatic complexity is represented, p represents RFMiOf middle predicate node Number;The predicate node includes sentence:for、foreach、if、while、do...while、switch.
Further, the computational methods of the public method number are:
SumMethod(RFMi)=∪ mq
In formula, SumMethod (RFMi) public method number in functional module i is represented, ∪ represents to seek joint transporting something containerized operator Number, mqRepresent with RFMiIn variable in q-th of public method calculated and wrapped in second obtained section result by slice criterion The public method number sum contained.
Further, the computational methods of the maximum nested number of plies are:
MaxNextingLayer(RFMi)=MAX (NL (mq))
In formula, MaxNextingLayer (RFMi) represent the nested number of plies of maximum in functional module i, NL (mq) represent to take public affairs Common method mqThe nested number of plies, MAX () represent take maximum.
Further, the computational methods of the degree of coupling average are:
In formula, Coupling (RFMi) functional module i and the average of the degree of coupling of other functional modules in source program are represented, |RFMi∩RFMt| represent RFMiAnd RFMtIn identical sentence number, | RFMi∪RFMt| represent RFMiAnd RFMiMiddle institute There is the sum of sentence.
Further, when only including 1 method in result of cutting into slices, its cohesion degree is 1.
Further, before step 1 is performed, in addition to step:
Source program is pre-processed, the null and comment line in identification source program code are simultaneously deleted, by institute's source code It is processed as all valid code rows.
Further, the method for constructing system dependency graph is in the step 1:
Source program is traveled through, extract source program abstract syntax tree, according to abstract syntax tree set up controlling stream graph and Inheritance tree, then relied on based on the data dependence between controlling stream graph and inheritance tree computing statement between variable and thread, finally Dependence is integrated into system dependence graph.
Beneficial effect:The present invention by program slicing technique be applied to functional module measurement, compared with prior art, with Lower advantage:
(1) present invention realizes the analysis to fine granularity object, can be specific to a certain sentence even variable, therefore be applicable to The reusability metrics of different grain size object;
(2) the association sentence of the invention based on program slicing technique computing function module, by between sentence and variable Traversal is relied on, the sentence of association extracted for multiplexing object has higher accuracy, so that measurement results are with more can By property;
(3) realize that mass is measured, the measurement of reusability, reduction are carried out to all functional module automation mass Operating Complexity, the average measuring period of raising.
(4) all functional module reusabilities are compared, by reusability relative value, filtered out in source program The of a relatively high functional module of reusability, improves multiplexing efficiency.
Brief description of the drawings
Fig. 1 is the principle flow chart of the embodiment of the present invention;
Fig. 2 is the construction flow chart of embodiment Program dependency graph.
Embodiment
The present invention is further described below in conjunction with the accompanying drawings.
The principle process of the present invention is as shown in figure 1, comprise the steps of:
S1:Source program is traveled through, invalid code row is deleted, such as null, comment line.By pretreatment, realize The compactedness of valid code row arrangement, reduces the error produced in metrics process;
S2:Source program is parsed, constructor dependency graph.Dependence and the change between sentence are included in dependency graph Dependence between amount, dependence mainly includes control dependences, data dependence etc., by between sentence directly relying on The sentence set related to specified sentence or variable operation result can be obtained by indirectly relying on;
S3:Source program is parsed, using total interface as functional module start statement, and by where all sentences File path and line number as two tuples be stored in interface knowledge base in;
S4:Using the functional interface set got in the program dependency graph and step 3 in S2, by functional interface set Total interface code as criterion, calculate its section, obtain association sentence collection and merge in deposit section knowledge base;
S5:Sentence set is associated with it with the functional module interface got in S4 using S3, is calculated as below:
(1) clustering degree Clustering:Pass through the quantity of the aggregation block that original adjacent sentence is constituted in result of cutting into slices Measurement section sentence context tightness degree in source program.
RFMiThe sentence that functional module i section result is included is represented, i ∈ [1, n], n is represented in the sum of section, i.e. S3 Interface sum set.H is the scale of section, that is, the bar number of sentence, h=in cutting into slices | RFMi|。
CBkIt is RFMiA code divided block, be designated as aggregation block.From RFMiIn mark off the method for an aggregation block and be:
To RFMiIn sentence be numbered, define RFMiIn belong to file S a articles statement number be Sa;Judge RFMi In belong to file S any two sentence Sa、SbWhether following condition is met simultaneously:
Sa-1(da-1)≠Sa(da)-1
Sb(db)=Sa(da)+b-a
In formula, da-1、daAnd dbSentence S is represented respectivelya-1、Sa、SbLine number in source program;If judged result is meets, File S a~b articles sentence is then divided into an aggregation block, that is, had | CBk|=b-a+1.K is RFMiOf middle aggregation block Number, and
The calculation formula of clustering degree is:
(2) complexity Complexity:Be expressed as specific a certain functional interface section obtain corresponding cyclomatic complexity, it is public Side operator with and the maximum nested number of plies.
(a) cyclomatic complexity:
The number that p is predicate node is defined, predicate node includes for, foreach, if, while, do...while, Switch sentences.
The calculation formula of cyclomatic complexity is:
Complexity(RFMi)=p+1
(b) public method number:Method sum in result of being cut into slices by metric function module, illustrates to be multiplexed the functional module Involved public method quantity.
R represents the public method sum in functional module i, mqRepresent with RFMiIn variable in q-th of public method to cut Piece criterion calculates the public method number sum included in second obtained of section result, and q ∈ [0, r], ∪ represents to seek joint Set operation symbol.
The calculation formula of public method number is:
SumMethod(RFMi)=∪ mq
(c) maximum nested number of plies MaxNestingLayer:Show the logic of functional module by measuring the maximum nested number of plies Complexity.
Nested mode in method includes all for, foreach, if, while, do...while, switch sentences.
NL(mq) represent to take public method mqThe nested number of plies, MAX () represent take maximum.
The calculation formula of the maximum nesting number of plies is:
MaxNextingLayer(RFMi)=MAX (NL (mq))
(3) degree of coupling Coupling:Pass through the degree of coupling between coincidence degree computing module of cutting into slices.
RFMi∩RFMtFor RFMiAnd RFMtIn, the set of identical sentence;|RFMi∩RFMt| represent RFMiAnd RFMt In identical sentence number;
RFMi∪RFMtFor RFMiAnd RFMtIn all sentences set, | RFMi∪RFMt| represent RFMiAnd RFMiIn own The sum of sentence.
The calculation formula of the degree of coupling between functional module i and functional module t is:
(4) cohesion degree Cohesion:
The tightness degree between method in functional module is represented, cohesion degree scope is [0,1], and cohesion degree is better closer to 1.
M represents RFMiIn method sum, x represents RFMiIn x-th of method, all variables in v (x) method for expressing x Set, | Slice (x, v (x)) |methodRepresent calculation step:By slice criterion of the variable in v (x) to functional module i's Result of cutting into slices carries out second and cut into slices, and counts the side operator sum in all secondary section results.
S6:Count and reusability relative value of the computing function module in current source code, be calculated as below:
(1) all Measure Indexes summations are counted
Measure Indexes in order to weigh functional module count all Measure Indexes in the size relative to other functional modules Summation.sumValuejIt is Measure Indexes j metric summation, ValueijRepresent degree of the functional module i in Measure Indexes j Value.
Measure Indexes summation sumValuejMeasure formulas be:
(2) computing function module reusability relative value
The Measure Indexes for counting each functional module account for the percentage of this Measure Indexes summation, so as to illustrate the work(specified The relative value of energy module reusability in project entirety.
RelativeValue (i) represents functional module i reusability metrics value, Clustering (i)perRepresent function Module i clustering degree accounts for the percentage of clustering degree summation, Cohesion (i)perRepresent that functional module i cohesion degree accounts for cohesion degree The percentage of summation, Complexity (i)perRepresent that functional module i cyclomatic complexity accounts for the percentage of cyclomatic complexity summation, SumMethod(i)perRepresent that functional module i public method number accounts for the percentage of public method number summation, MaxNextingLayer(i)perRepresent that the functional module i nested number of plies of maximum accounts for the percentage of maximum nested number of plies summation, Coupling(i)perRepresent that functional module i degree of coupling average accounts for the percentage of degree of coupling average summation.
In six Measure Indexes more than, clustering degree and cohesion degree and reusability are positive correlation, and cyclomatic complexity, public affairs Side operator and the maximum nested number of plies and reusability are negatively correlated altogether.
The measure formulas 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 program is further illustrated with embodiment below in conjunction with the accompanying drawings.Describe for convenience, we with The technical program is described in detail exemplified by One function modules A section result.It is located in source program, with file The 26th line statement in TryVisitor.java is cut into slices for slice criterion, obtains functional module A section result such as table 1 It is shown:
Table 1
As seen from the above table, comprising 9 sentences in functional module A section result, this 9 sentences are belonging respectively to two texts Part:TryVisitor.java and CompileUnit.java;9 sentences are divided into two groups according to affiliated file, and to each group Sentence is numbered.
Follow the steps below functional module A reusability metrics:
Step 1:Source program is pre-processed, to reduce the null and note in the error of measurement results, identification source code Release row and delete, institute's source code is processed as all valid code rows;
Step 2:Source program is traveled through, the abstract syntax tree of extraction procedure sets up controlling stream according to abstract syntax tree Figure and inheritance tree, then relied on based on the data dependence between information above computing statement between variable and thread, finally will be according to Set of relations is relied to turn into system dependence graph and be stored in dependency graph knowledge base, specific handling process is as shown in Figure 2;
Step 3:Source program is traveled through, according to the start statement of source program keyword arbitration functions module, by right The traversal of source program, abstraction function module;The essential information of writing function interface, the file path and line number where;
Step 4:Using the functional interface extracted in step 2 as the slice criterion for extracting each functional module, calculate each The corresponding section result of slice criterion, each section result association One function module;The section result of One function module is Associate the set of the necessary sentence of the function;By in slice criterion deposit section knowledge base corresponding with section result;
Step 5:Reusability to functional module is measured, by taking functional module A as an example, carries out following calculate:
(1) clustering degree:Pass through the quality metric section language of the aggregation block that original adjacent sentence is constituted in result of cutting into slices Sentence context tightness degree in source program.
RFMARepresent functional module A section result, RFMAComprising 9 sentences, i.e., TryVisitor.java in upper table 26,28-30 rows and 32 rows, CompileUnit.java 11-12 rows and 17-18 rows.RFMAIn section scale h be 9, category In file TryVisitor.java 5 sentences, S2, S42nd article and the 4th article of sentence, and meet 1≤2≤h, 1≤4 respectively ≤ h, corresponds to S (28) and S (30), i.e. 28 in source code file and 30 rows respectively.S2-1(26)≠S2(28) -1 and S4(30)= S2(28)+(4-2), therefore S2~S4For an aggregation block.According to above-mentioned principle, RFMAIn include 5 aggregation blocks, i.e. K=5.
Clustering degree according to the measure formulas computing function modules A of clustering degree:
(2) complexity:Metric function module is in itself and the complexity with other module relations, main to include three sides Face:Cyclomatic complexity, public method the number number of plies nested with maximum.
(a) cyclomatic complexity:By measuring cyclomatic complexity, illustrate the complexity and independent linearity path bar of decision structure Number.
In RFMAIn, p is 1.Measure formulas according to cyclomatic complexity is calculated:
Complexity(RFMA)=p+1=2
(b) public method sum:By measure sum, illustrate to be multiplexed the method rule involved by the functional module Mould.
In 4 sentences of CompileUnit.java files are belonged to, mq=2, belonging to TryVisitor.java files 5 sentences in, mq=1;Therefore, the measure formulas according to public method number is calculated:
SunMethod(RFMA)=∪ mq=3
(3) the maximum nested number of plies:By measuring the complexity that the maximum nested number of plies shows the logic of functional module.
NL methods represent to take the nested number of plies of method, and MAX methods represent to take the maximum of the nested number of plies in method.
Measure formulas according to maximum nested number of plies MaxNestingLayer is calculated:
MaxNextingLayer(RFMA)=MAX (NL (mq))=1
(c) degree of coupling:Pass through the degree of coupling between coincidence degree computing module of cutting into slices.Because the degree of coupling is two moulds of measurement Correlation degree between block, therefore following table is by taking the functional module B in source program as an example, computing function module B and functional module A The degree of coupling.Calculated with the 10th behavior slice criterion of file TryVisitor.java in source program and obtain functional module B correspondences Section result, as shown in table 2.
Table 2
Comprising 14 sentences in table 2, this 14 sentences are belonging respectively to three files:TryVisitor.java、 CompileUnit.java and ASTFileASTRequestor.java, this 14 sentences are grouped according to affiliated file, And the sentence in each packet is numbered, the result of numbering is as shown in table 2.
RFMBThe sentence set that functional module B is included is represented, 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 } > }
Measure formulas according to degree of coupling average is calculated:
(4) cohesion degree:The tightness degree between method in functional module is represented, cohesion degree scope is [0,1], and cohesion degree more connects It is bordering on 1 better.
M represents functional module RFMAIn method sum, as 3, x represents x-th of method, and x takes 2, v (2) to represent herein Variable filePath in variables collection in method 2, i.e. getFilePath methods, is carried out by slice criterion of filePath Section, then the side operator included in section is counted, it is designated as | Slice (x, v (x)) |method.Method sum is 3 under this criterion, according to Calculated according to the measure formulas of cohesion degree:
Step 6:Total evaluation is carried out to the reusability of functional module according to measurement results.To illustrate total evaluation stream The measurement results of functional module A and functional module B reusability metrics index, such as table 3 are listed in journey, following two forms It is shown.
Table 3
(1) the metric sum of all Measure Indexes is counted
In order to weigh a certain index of functional module in the size relative to other functional modules, statistics items Measure Indexes Summation.By statistics, the summation of every Measure Indexes is as shown in table 4:
Table 4
(2) computing function module reusability relative value, calculates reusability relative value by taking modules A as an example.
Measure formulas according to reusability relative value is calculated:
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
According to the measure formulas computing function modules A and B reusability relative value of reusability relative value, as a result such as table Shown in 5:
Table 5
Functional module is numbered Reusability relative value
FuncModuleA -1.1698
FuncModuleB -0.8302
According to the descending arrangement of reusability relative value, functional module B reusability relative value > functional modules A's Reusability relative value.Therefore, functional module B reusability is high, is easily re-used, by contrast functional module A reusables Property it is low, multiplexing difficulty it is larger.
Described above is only the preferred embodiment of the present invention, it should be pointed out that:For the ordinary skill people of the art For member, under the premise without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications also should It is considered as protection scope of the present invention.

Claims (10)

1. a kind of reusability metrics method based on program slice, it is characterised in that this method comprises the following steps:
Step 1:Constructing system dependency graph, and system dependence graph is stored in dependency graph knowledge base;The system dependence graph includes language The dependence between dependence and variable between sentence, the dependence includes control and relied on and data dependence;
Step 2:Source program is traveled through, the functional interface code of all functional modules in source program is extracted;By functional interface Code and regard the file path and line number where each start statement as two tuples as the start statement of corresponding function module It is stored in interface knowledge base;
Step 3:Source journey is calculated using the functional interface code extracted in step 2 as the slice criterion for extracting each functional module The section result of sequence, and by the slice criterion deposit section knowledge base corresponding with section result;Each section result correspondence One function module, section result includes sentence associated with slice criterion in corresponding function module;
Step 4:Section result according to being obtained in the functional interface code and step 3 extracted in step 2 is built respectively to be used for The Measure Indexes of each functional module reusability are evaluated, and calculate metric of each functional module on Measure Indexes;For appointing Meaning One function module, its Measure Indexes is the clustering degree of the module, cohesion degree, cyclomatic complexity, public method number, maximum nesting The number of plies and degree of coupling average, the degree of coupling average are the degree of coupling average value of the functional module and other functional modules;
Step 5:The Measure Indexes constructed according to step 4, calculate each single item Measure Indexes metric summation be:
In formula, ValueijRepresent metrics of the functional module i in Measure Indexes j;
Step 6:Constructing function module reusability metrics value calculation formula is:
RelativeValue (i)=Clustering (i)per+Cohesion(i)per-Complexity(i)per-SumMethod (i)per-MaxNextingLayer(i)per-Coupling(i)per
In formula, RelativeValue (i) represents functional module i reusability metrics value, Clustering (i)perRepresent work( Energy module i clustering degree accounts for the percentage of clustering degree summation, Cohesion (i)perRepresent that functional module i cohesion degree accounts for cohesion Spend the percentage of summation, Complexity (i)perRepresent that functional module i cyclomatic complexity accounts for the percentage of cyclomatic complexity summation, SumMethod(i)perRepresent that functional module i public method number accounts for the percentage of public method number summation, MaxNextingLayer(i)perRepresent that the functional module i nested number of plies of maximum accounts for the percentage of maximum nested number of plies summation, Coupling(i)perRepresent that functional module i degree of coupling average accounts for the percentage of degree of coupling average summation;
Step 7:Functional module is chosen according to functional module reusability metrics value, multiplexing value is bigger, represent corresponding function module Reusability it is higher.
2. a kind of reusability metrics method based on program slice according to claim 1, it is characterised in that
The computational methods of the clustering degree are:
In formula, clustering (RFMi) represent functional module i clustering degree;RFMiRepresent the corresponding section knots of functional module i Really, i ∈ [1, n], n represents the sum of functional module;K represents RFMiThe number of middle aggregation block, the aggregation block is RFMiIn language Sentence divided block, defines RFMiIn any one aggregation block be CBk, CBkMeet:
From RFMiIn mark off the method for an aggregation block and be:
To RFMiIn sentence be numbered, define RFMiIn belong to file S a articles statement number be Sa;Judge RFMiMiddle category In file S any two sentence Sa、SbWhether following condition is met simultaneously:
Sa-1(da-1)≠Sa(da)-1
Sb(db)=Sa(da)+b-a
In formula, da-1、daAnd dbSentence S is represented respectivelya-1、Sa、SbLine number in source program;
If file S a~b articles sentence is divided into an aggregation block by judged result to meet.
3. a kind of reusability metrics method based on program slice according to claim 2, it is characterised in that
The computational methods of the cohesion degree are:
In formula, Cohesion (RFMi) functional module i cohesion degree is represented, M represents RFMiIn the sum of method that includes;X tables Show RFMiIn x-th of method, the set of all variables in v (x) method for expressing x, | Slice (x, v (x)) |methodRepresent fortune Calculate step:Section result by slice criterion of the variable in v (x) to functional module i carries out second of section, statistics all two Side operator sum in secondary section result.
4. a kind of reusability metrics method based on program slice according to claim 3, it is characterised in that
The computational methods of the cyclomatic complexity are:
Complexity(RFMi)=p+1
In formula, Complexity (RFMi) functional module i cyclomatic complexity is represented, p represents RFMiThe number of middle predicate node;Institute Stating predicate node includes sentence:for、foreach、if、while、do…while、switch.
5. a kind of reusability metrics method based on program slice according to claim 4, it is characterised in that the public affairs The computational methods of side operator are altogether:
SumMethod(RFMi)=∪ mq
In formula, SumMethod (RFMi) public method number in functional module i is represented, ∪ represents to ask joint set operation symbol, mq Represent with RFMiIn variable in q-th of public method calculated for slice criterion included in second obtained section result Public method number sum.
6. a kind of reusability metrics method based on program slice according to claim 5, it is characterised in that it is described most The computational methods of the big nesting number of plies are:
MaxNextingLayer(RFMi)=MAX (NL (mq))
In formula, MaxNextingLayer (RFMi) represent the nested number of plies of maximum in functional module i, NL (mq) represent to take public side Method mqThe nested number of plies, MAX () represent take maximum.
7. a kind of reusability metrics method based on program slice according to claim 6, it is characterised in that the coupling The computational methods of right average are:
In formula, Coupling (RFMi) functional module i and the average of the degree of coupling of other functional modules in source program are represented, | RFMi∩RFMt| represent RFMiAnd RFMtIn identical sentence number, | RFMi∪RFMt| represent RFMiAnd RFMtIn own The sum of sentence.
8. a kind of reusability metrics method based on program slice according to claim 7, it is characterised in that work as section When only including 1 method in as a result, its cohesion degree is 1.
9. a kind of reusability metrics method based on program slice according to claim 8, it is characterised in that performing Before step 1, in addition to step:
Source program is pre-processed, the null and comment line in identification source program code are simultaneously deleted, and institute's source code is handled For all valid code rows.
10. a kind of reusability metrics method based on program slice according to claim 9, it is characterised in that described The method of constructing system dependency graph is in step 1:
Source program is traveled through, the abstract syntax tree of source program is extracted, controlling stream graph and succession is set up according to abstract syntax tree Tree, then relied on based on the data dependence between controlling stream graph and inheritance tree computing statement between variable and thread, finally will be according to Set of relations is relied to turn into 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 true CN106980495A (en) 2017-07-25
CN106980495B 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)

Cited By (1)

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

Citations (4)

* 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
US20160202968A1 (en) * 2014-02-24 2016-07-14 Tibco Software Inc. Modularized xml namespaces
CN105787369A (en) * 2016-02-29 2016-07-20 南京邮电大学 Android software security analysis method based on slice measurement

Patent Citations (4)

* 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
US20160202968A1 (en) * 2014-02-24 2016-07-14 Tibco Software Inc. Modularized xml namespaces
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
李必信: ""程序切片技术及其在面向对象软件度量和软件测试中的应用"", 《中国博士学位论文全文数据库信息科技辑》 *

Cited By (2)

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

Also Published As

Publication number Publication date
CN106980495B (en) 2020-04-14

Similar Documents

Publication Publication Date Title
CN104252445B (en) Approximate repetitive file detection method and device
CN105930523A (en) Dynamic configurable rule-based data cleaning framework under big data background
CN103699523B (en) Product classification method and apparatus
CN102841946B (en) Commodity data retrieval ordering and Method of Commodity Recommendation and system
CN104462604B (en) Data processing method and system
CN107066791A (en) A kind of aided disease diagnosis method based on patient's assay
CN106708966A (en) Similarity calculation-based junk comment detection method
CN101340326B (en) Reliability predicting method of communication equipment
Spiliopoulou et al. Higher order mining: Modelling and mining the results of knowledge discovery
CN104484380A (en) Personalized search method and personalized search device
CN103227734A (en) Method for detecting abnormity of OpenStack cloud platform
CN105512195B (en) A kind of product F MECA report analysis decision assistant method
CN108986907A (en) A kind of tele-medicine based on KNN algorithm divides the method for examining automatically
CN106897285A (en) Data Elements extract analysis system and Data Elements extract analysis method
CN110533316A (en) A kind of LCA (Life Cycle Analysis) method, system and storage medium based on big data
CN103744838B (en) A kind of Chinese emotion digest system and method for measuring main flow emotion information
CN105488212A (en) Data quality detection method and device of duplicated data
CN107194570A (en) Screening technique and its system for individual enterprise's key decision point
CN106980495A (en) A kind of function reusability metrics method based on program slice
CN106445907A (en) Domain lexicon generation method and apparatus
CN106815209A (en) A kind of Uighur agricultural technology term recognition methods
CN108470035A (en) A kind of entity-quotation correlation sorting technique based on differentiation mixed model
CN106844765A (en) Notable information detecting method and device based on convolutional neural networks
CN108268462A (en) A kind of data quality checking system of relation integraity
CN103870590B (en) Webpage identification method and device with error-reported characteristic

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