Survey paper

464 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
464
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Survey paper

  1. 1. Jun. 30 IJASCSE Vol 1 Issue 1 2012 A LITRERATURE SURVEY ON VARIOUS SOFTWARE COMPLEXITY MEASURES 1 Anurag Bhatnagar, 2Nikhar Tak ,3Shweta ShuklaAbstract - Latin word “complexus”, Keyword – Software complexity, Codewhich signifies "entwined", "twisted based complexity measures, cognitivetogether". This may be interpreted in based complexity measures.the following way - in order to have acomplex we need two or morecomponents, which are joined in such a 1. INTRODUCTION TOway that it is difficult to separate them. COMPLEXITYSimilarly, the Oxford Dictionary defines Complexity is defined by the executionsomething as "complex" if it is "made of time and storage required to perform(usually several) closely connected the computation. When the interactingparts". Software systems change over system is a programmer, complexity istime, so it is very difficult to understand defined by the difficulty of performingand measure the effect of these tasks such as coding, debugging,changes and it is a very complex testing, or modifying the software. Theproblem in most modern software term software complexity is oftensystems that consist of thousands of applied to the interaction between aprogram modules. Thus one of the program and a programmer working oncentral problems in software some programming task. Complexityengineering is its inherited complexity. measures focus on designs and actualThis paper is a survey on different code. They assume there is a directCode based complexity measures such correlation between design complexityas Halsted Complexity Measure and and design errors, and code complexityMAC Cabe’s Cyclomatic Complexity and latent defects. By recognizing theMeasure and Cognitive based properties of each that correlate to theircomplexity measures such as KLCID complexity, we can identify those highComplexity Measure, Cognitive risk applications that either should beFunctional Complexity Measure and revised or subjected to additionalCognitive Information Complexity testing. Those software propertiesMeasure. which correlate to how complex its size, interfaces among modules (usually 1
  2. 2. Jun. 30 IJASCSE Vol 1 Issue 1 2012 "Open Reengineering" provides criterion for metrics selection. Todaymeasured as fan-in, the number of "Open Systems" are so popularmodules invoking a given application, because commercial softwareor fan-out, the number of modules applications is that the user isinvoked by a given application), and guaranteed a certain level ofstructure (the number of paths within a interoperability - the applications workmodule). Complexity metrics help together in a common framework, anddetermine the number and type of tests applications can be ported acrossneeded to cover the design (interfaces hardware platforms with minimalor calls) or coded logic (branches and impact. The open reengineering consiststatements). There are several of the abstract model that state thataccepted methods for measuring software systems must be ascomplexity, most of which can be independent as possible from thecalculated by using automated tools. source code formatting andBasili defines complexity as a measure programming language. The objectiveof the resources expended by a system is to be able to set complexitywhile interacting with a piece of standards and interpret the resultantsoftware to perform a given task [1]. numbers uniformly across projects andSoftware complexity measures are languages. Once we calculate thebased on program code disregarding complexity then that value should becomment and stylistic attributes such as the same whether in Ada, FORTRAN,indentation and naming conventions. or in some other programmingMeasures typically depend on program language. Some of the very basic butsize, control structure, or the nature of important complexity measures are themodule interfaces. number of lines of code also known as LOC (Line of Code), does not meet theSoftware complexity can be measured open reengineering criterion, as it’sby Direct Measures which is also tremendously sensitive to programmingknown as internal attributes and Indirect language, coding style, and textualMeasures which is also known as formatting of the source code. Theexternal attributes. Direct Measures are cyclomatic complexity measure, ismeasured directly such as Cost, effort, example of open engineering as itLOC, speed, memory. Indirect measures the amount of decision logicMeasures can not be measured in a source code function. Cyclomaticdirectly. Example - Functionality, complexity is entirely independent ofquality, complexity, efficiency, reliability, text formatting and is this ismaintainability. independent of programming language 2
  3. 3. Jun. 30 IJASCSE Vol 1 Issue 1 2012 to find the complexity of the procedural programs, it is used to measure asince the same fundamental decision software components complexitystructure are available and uniformly directly from source code withused in all procedural programming prominence on computationallanguages. complexity [3]. Halstead’s measures uses distinct and total number of 2. CODE BASED COMPLEXITY operators and operands means it MEASURES absorbed the operators (that means operations in a programming languageCode based complexity measures, as that may vary or move the operands)its name is indicating are based on the and operands (different variables,code of the program and not on the constants, and addresses on whichcomments and stylistic attributes of it. operation is to be performed) in aCode based measures are typically software component in order todepends upon the program sizes, measure complexity. Halstead makesprogram flow graphs, or module the observation that metrics of theinterfaces such as Halstead’s software software should reflect thescience metrics [3] and the most widely implementation or expression ofknown measure of cyclomatic algorithms in different languages, butcomplexity developed by McCabe [6]. be independent of their execution on aHowever, Halstead’s software metrics specific platform. These metrics arepurely calculates the number of therefore computed statically from theoperators and operands, but it does not code. Thus the Halstead complexityconsider the internal structures of measure uses code of the software inmodules, while McCabe’s cyclomatic order to calculate the complexity so it iscomplexity does not consider I/O’s of a known as code based complexitysystem as it is based on the flow chart measure. The goal of Halsteadof the program. It uses flow chart of the complexity measure was to identifyprogram and on the basis of nodes and measurable properties of software oredges it provides complexity of the code, and the relations between them.program. The main problem with this method or we can say blockage with this is that it 2.1 HALSTEAD COMPLEXITY does not distinguish the differences MEASURE among the same operators and among the same operands in a program.A set of software metrics was Besides, it ignores the nested structuredeveloped by Maurice Halstead in 1977 and fails to analyze the case statement 3
  4. 4. Jun. 30 IJASCSE Vol 1 Issue 1 2012 the physical meanings of the measures are not very clear.when code is not accessible. Some ofthe important parameters used in Table – 2. Derived Measures ofmeasures of Halstead are based on Halstead’s Software Metricsfour scalar numbers of programs. Allthese parameters are show in Table 1. Measure Symbol Formula Program N N = N1 + N2Table – 1. Meta Measures in Halstead Length Complexity measure Program n n = n1 + n2 vocabularyFactor Meta Description Volume V V = N*(Log2n) Measure Difficulty D D= n1 $operators The number (n1*N2)/2*n2 of distinct Effort E E = D*V operators Time T T = E/18 n2 $operands The number Total Bugs B B = E2/3/3000 of distinct operands N1 $operators The total 2.2 MAC CABE’S CYCLOMETRIC number of COMPLEXITY operators N2 $operands The total In 1976, Thomas J.McCabe provides a number of method calculates Cyclomatic operands Complexity by the control flow graph of program. This McCabe method isSix measures can be derived from table based on control flow. McCabes– 1 , as shown in Table 2. Halstead’s complexity measure is a mathematicalsoftware metrics were developed in the technique for calculating the logicalcontext of assembler language complexity of a computer program.programs, and get into too small details Cyclomatic complexity also known asof measurement. The metrics identified conditional complexity, is a softwarethe need for three types of measures metric and is used to indicate thefor software: basic, derived, and complexity of a program. It is a directestimated measures. But, some of the measure so it directly measures themeasures and constants are arguable, number of linearly independent pathse.g. T = E/18, and B = E2/3 / 3000, and through a programs source code. Cyclomatic complexity is computed 4
  5. 5. Jun. 30 IJASCSE Vol 1 Issue 1 2012 expressed as graphs or to be preciseusing the control flow graph of the "program control graphs." Thusprogram: the nodes of the graph mathematical analysis may be appliedcorrespond to indivisible groups of to computer programs in order tocommands of a program, and a calculate complexity. Graph theorydirected edge connects two nodes if the allows for such a graph to yield asecond command might be executed quantitative cyc]omatic complexityimmediately after the first command. number via the formula –Cyclomatic complexity may also be V(F) = E − N + 2applied to individual functions, modules,methods or classes within a program. A F is the flow graph of the code.number representing its logical weight N is the number of vertices/Nodes.can be used to show the complexity of E is the number of edges.a computer program. This quantitativecomplexity number dependent on aprograms decision structure or thenumber of basic paths through aprogram generated but it isindependent of the programs size.Complexity can assume a value of oneto infinity, a reasonable upper limit ofintellectual manageability has beenplaced by McCabe at ten. Softwareshould be tested for the complexityonce they are created but when thecomplexity of the software exceedsthan ten, sub-functions should be giventheir own procedure or the softwareshould be redone. The theoretical basisfor McCabes complexity measure isgraph theory. The following connectionexists between graph theory andcomputer programs. Each node in the Figure – 1. McCabe Cyclomaticgraph corresponds to a block of code in Complexity Example.the program where the flow issequential and the arcs correspond to Here we havebranches taken in the program. Thus, E = No. of Edges = 7all computer programs may be N = No. of Nodes = 5. 5
  6. 6. Jun. 30 IJASCSE Vol 1 Issue 1 2012Cyclomatic Complexity Klemola and Rilling proposed KLCIDV(F) = 7-5+2 = 4 based complexity measure in 2004. It defines the use of the identifiers as 3. COGNITIVE COMPLEXITY programmer defined variables and MEASURES identifiers (ID) when a software is built up.Cognitive complexity measures are thehuman effort needed to perform a task ID = Total no. of identifiers/ LOCor difficulty in understanding the In order to calculate KLCID, we need tosoftware. Cognitive complexity measure find the number of unique lines of codeis an attempt that quantifies the effort or in a module, lines that have same typenotch of difficulty in understanding the and kind of operands with samesoftware based on cognitive informatics arrangements of operators would befoundation. Cognitive complexity of consider equal. I defines KLCID as –software is dependent on three basicfundamental factors. These are inputs, KLCID= No. of Identifier in the set ofoutputs, and internal processing. unique lines/ No. of unique linesCognitive complexity measures containing identifierconsider all these factors affecting the This is a time consuming method wheneffort in twigging the software, e.g. data comparing a line of code with each lineobjects such as inputs, outputs, of the program. KLCID accepts thatvariables, loops and branches internal control structures for differentevaluating complexity but if the factors software’s are identical.are not carefully thought and organizedit may cause trouble in calculating 3.2 COGINITIVE FUNCTIONAL SIZEcomplexity. Some of the factors (CFS)considered in order to calculate thecomplexity of the software and these Cognitive Functional Size (CFS) [1] wasfactors are separately-derived weights. defined by WangThus this process of calculating the As –complexity ignores the relationshipsamong the factors of the modules and CFS = (Ni + No) * Wchas a little importance to human Where Ni = No of inputs.cognitive process when apprehending No = No of outputs.the code of the program. Wc = The total cognitive weight of basic control structures (BCSs). 3.1 KLCID COMPLEXITY METRICS 6
  7. 7. Jun. 30 IJASCSE Vol 1 Issue 1 2012 3.2 COGNITIVE INFORMATION COMPLEXITY MEASUREThese BCS are defined as the totalsum of cognitive weights of its Q linear Cognitive Informatics plays anblocks composed in individual BCSs. important role in understanding theSince each block may consist of m fundamental characteristics of software.layers of nesting BCSs, and each layer Wang [8] defined information as the third essence in modelling the naturalwith n linear BCSs, then – world supplement to matter and energy. Wang [9] also defined software as “Software in cognitive informatics is perceived as formally described design information and implementations Table 2. Cognitive Weights (Wc) of instructions of computing application” BCS’s i.e. Category BCS Wc. Software ≃ Information Sequence Sequence (SEQ) 1 Branch If-Then-Else 2 It represent that, software is equivalent (ITE) to information, So Case(CASE) 3 implies that For-do (Ri) 3 Iteration Repeat-Until (Ri) 3 Difficulty in understanding ≃ While-do (Ro) 3 Difficulty in Embedded Function call 2 software understanding informationComponent (FC) Recursion (REC) 3 Software is a computational informationConcurrency Parallel (PAR) 4 and is a mathematical entity. Or we can Interrupt (INT) 4 say that software is a piece of information that consist of identifiers toCognitive Functional Size interestingly represent the information andstarted the study in software complexity Operators that represent function to bemeasurement based on cognitive performed.informatics foundation [6] and state thatthe complexity of software is dependent Software = fun(Identifiers,on inputs, outputs, and its internal Operators)processing. 7
  8. 8. Jun. 30 IJASCSE Vol 1 Issue 1 2012 on this fact, weighted information countIdentifiers can be variable names, is been introduced as in definition 3.defined constants or other labels insoftware. Thus information can be Definition 3: The Weighteddefined as – Information Count of a line of code (WICL) of a software is a function ofDefinition 1: Information can be identifiers, operands and LOC and isrepresented by LOC. It means different defined as –operators and operand can be used toshow information, Thus in Kth line of WICLk = Ik / [LOCS – k]code the Informationcontained is – Where WICk = Weighted Information Count for the kth line.IKth = (Identifiers + Operands)K Ik = Information contained in a software = (IDK + OPK) IU for the kth line. So the Weighted Information Count of theWhere ID = Total number of identifiers Software (WICS) is defined as (LOCS)in the kth LOC of software. –OP = Total number of operators in thekth LOC of software. LOCSIU = Information Unit represents that WICS = Σ WICLkany identifier or operator has one unit of K=1information in it. The internal control structure of software such as it’s weight must beDefinition 2: Overall Information considered in order to provide completecontained in software and robust complexity measure.(Itotal) is the sum of informationcontained in each line of Definition 4: Sum of the cognitiveCode (LOCS) i.e. weights of basic control structures (SBCS) is defined – LOCS Let W1, W2…..Wn be the cognitive Itotal = Σ Ik weights of the basic control structures K=1 [8] in the software –When have established that software is nready to comprehend the information SBCS = Σ (Wi)units (IU’s), the measure of the i=1complexity of the software should Definition 5: Thus we have Cognitivecontain the above parameters. Based Information Complexity Measure – 8
  9. 9. Jun. 30 IJASCSE Vol 1 Issue 1 2012 Calculation of KLCID complexity (CICM) = WICS * SBCS measure –Thus we have used an approach to Total no. of identifiers in the abovemeasure the amount of information program = 18contained in the software thus enabling Total no. of lines of code = 17us to calculate the coding efficiency ID = 18/17 = 1.05(EI). No. of unique lines containing identifier =9Definition 6: Efficiency of No. of identifiers in the set of uniqueInformation Coding (EI) of a software lines = 11is defined as – KLCID = 11 / 9 = 1.22 EI = Itotal / LOCS. Calculation of CFS –Now to analyse the KLCID, CMS and Number of inputs Ni = 1CICM complexity measures, we have Number of outputs No = 3an algorithm to calculate the average of BCS (sequence) W1 = 1a set of ‘n’ numbers on which we will BCS (while) W2 = 3applied all these methods to calculate Wc = W1 + W2 = 1+3 = 4the complexity. CFS = (Ni + No)* Wc = (1+3)*4 = 16# define n 10Void main( ) Calculation of CICM –{ LOC = 17int total; Total no. of identifiers = 18float sum, avg, num; Total no. of operators = 4sum = 0; BCS(sequence) W1 = 1total = 0; BCS(while) W2 = 3while (total < n) SBCS = W1 + W2 = 1+3 = 4{ WICS = [ 1/16 + 1/13 + 3/12 + 1/11 +scanf(“%f”, &num); 1/10 + 3/9 + 1/7 + 4/6 + 3/5 + 4/3] =sum = sum + num; 3.63total = total + 1; CICM = WICS * SBCS = 3.63 * 4 =} 14.53avg = sum/N; Information Coding Efficiency (EI) ofprintf(“N=%d sum = %f”’, N, sum); the aboveprintf(“average = %f”’, avg); program = 22/17 = 1.29} The cognitive information complexity of the given algorithm is 14.53 CICU (Cognitive Information Complexity unit). 9
  10. 10. Jun. 30 IJASCSE Vol 1 Issue 1 2012 [1] B. Auprasert and Y, Limpiyakorn, 3.3 CONCLUSION "StructuringCognitive Information for Software Complexity Measurement",In this paper we have studied various Accepted for CSIE 2009, LosSoftware complexity measures along Angeles, USA., April 2009.with their appropriate example. All [2] Halstead, M.H., Elements ofCode based complexity measures such Software Science, Elsevier North, Newas Halsted Complexity Measure and York, 1977MAC Cabe’s Cyclomatic Complexity [3] Mc Cabe, T.H., A ComplexityMeasure that we have studied are measure, IEEE Transactions onbased on coding part of the program, Software Engineering, SE-2,6, pp. 308-so it needed time to compute 320, 1976complexity as all these methods can [4] Kushwaha, D.S. and Misra, A.K., Abe applied after the coding phase has Modified Cognitive Informationbeen completed. MAC Cab Cylomatic Complexity Measure of Software, ACMcomplexity measure is based on the SIGSOFT Software Engineering Notes,flow graph of the program by which Vol. 31, No. 1 January 2006.code is generated thus it is also [5] Kushwaha, D.S. and Misra, A.K., Aclassified in code based complexity Complexity Measure based onmeasures. Cognitive based complexity Information Contained in Software,measures such as KLCID Complexity Proceedings of the 5th WSEAS Int.Measure, Cognitive Functional Conf. on Software Engineering, ParallelComplexity Measure and Cognitive and Distributed Systems, Madrid,Information Complexity Measure are Spain, February 15-17, 2006, (pp 187-also based on the coding part of the 195)programs so they also needed code of [6] Tumous Klemola and Juergenthe procedural program on which they Rilling, A Cognitive Complexity Metricare to be applied, in order to compute based on Category Learning, IEEEthe complexity. So we can say that the International Conference on Cognitivetime to measure the complexity for Informatics (ICCI-04)procedural programs by both Code [5] Kushwaha, D.S. and Misra, A.K.,based complexity measures and Cognitive Information ComplexityCognitive based complexity measures Measure: A Metric Based ondepends on the time that is needed to Information Contained in the Software,complete the coding phase. WSEAS Transactions on Computers, 3.4 REFERENCES Issue 3, Vol. 5, March 2006, ISSN: 1109 – 2750 10
  11. 11. Jun. 30 IJASCSE Vol 1 Issue 1 2012[6] Kushwaha, D.S. and Misra, A.K.,Improved Cognitive InformationComplexity Measure: A metric thatestablishes programcomprehensioneffort, ACM SIGSOFT SoftwareEngineering, Page 1, September 2006,Volume 31 Number 5[7]IEEE Computer Society: IEEERecommended Practice for SoftwareRequirement Specifications, New York,1994[8] Wang. Y and Shao,J.,”On Cognitiveinformatics”, 1st IEEE InternationalConference on Cognitive Informatics,pages 34-42,August 2002.[9] Wang ,Y .and Shao,J.,“Measurement of the CognitiveFunctional Complexity of Software”, 3rd IEEE InternationalConference on CognitiveInformatics(ICCI’04). 11

×