Programming complexity (or software complexity) is a term that includes software properties that affect internal interactions. Several commentators distinguish between the terms "complex" and "complicated". Complicated implies being difficult to understand, but ultimately knowable. Complex, by contrast, describes the interactions between entities. As the number of entities increases, the number of interactions between them increases exponentially, making it impossible to know and understand them all. Similarly, higher levels of complexity in software increase the risk of unintentionally interfering with interactions, thus increasing the risk of introducing defects when changing the software. In more extreme cases, it can make modifying the software virtually impossible.

The idea of linking software complexity to software maintainability has been explored extensively by Professor Manny Lehman, who developed his Laws of Software Evolution. He and his co-author Les Belady explored numerous software metrics that could be used to measure the state of software, eventually concluding that the only practical solution is to use deterministic complexity models.[1]

Types

edit

The complexity of an existing program determines the complexity of changing the program. Problem complexity can be divided into two categories:[2]

  1. Accidental complexity relates to difficulties a programmer faces due to the software engineering tools. Selecting a better tool set or a higher-level programming language may reduce it. Accidental complexity often results from not using the domain to frame the form of the solution.[citation needed] Domain-driven design can help minimize accidental complexity.
  2. Essential complexity is caused by the characteristics of the problem to be solved and cannot be reduced.

Measures

edit

Several measures of software complexity have been proposed. Many of these, although yielding a good representation of complexity, do not lend themselves to easy measurement. Some of the more commonly used metrics are

  • McCabe's cyclomatic complexity metric
  • Halstead's software science metrics
  • Henry and Kafura introduced "Software Structure Metrics Based on Information Flow" in 1981,[3] which measures complexity as a function of "fan-in" and "fan-out". They define fan-in of a procedure as the number of local flows into that procedure plus the number of data structures from which that procedure retrieves information. Fan-out is defined as the number of local flows out of that procedure plus the number of data structures that the procedure updates. Local flows relate to data passed to, and from procedures that call or are called by, the procedure in question. Henry and Kafura's complexity value is defined as "the procedure length multiplied by the square of fan-in multiplied by fan-out" (Length ×(fan-in × fan-out)²).
  • Chidamber and Kemerer introduced "A Metrics Suite for Object-Oriented Design" in 1994,[4] focusing on metrics for object-oriented code. They introduce six OO complexity metrics: (1) weighted methods per class; (2) coupling between object classes; (3) response for a class; (4) number of children; (5) depth of inheritance tree; and (6) lack of cohesion of methods.

Several other metrics can be used to measure programming complexity:

  • Branching complexity (Sneed Metric)
  • Data access complexity (Card Metric)
  • Data complexity (Chapin Metric)
  • Data flow complexity (Elshof Metric)
  • Decisional complexity (McClure Metric)
  • Path Complexity (Bang Metric)

Tesler's Law is an adage in human–computer interaction stating that every application has an inherent amount of complexity that cannot be removed or hidden.

Chidamber and Kemerer Metrics

edit

Chidamber and Kemerer[4] proposed a set of programming complexity metrics widely used in measurements and academic articles: weighted methods per class, coupling between object classes, response for a class, number of children, depth of inheritance tree, and lack of cohesion of methods, described below:

  • Weighted methods per class ("WMC")
    • n is the number of methods on the class
    • is the complexity of the method
  • Coupling between object classes ("CBO")
    • number of other class which is coupled (using or being used)
  • Response for a class ("RFC")
    • where
    • is set of methods called by method i
    • is the set of methods in the class
  • Number of children ("NOC")
    • sum of all classes that inherit this class or a descendant of it
  • Depth of inheritance tree ("DIT")
    • maximum depth of the inheritance tree for this class
  • Lack of cohesion of methods ("LCOM")
    • Measures the intersection of the attributes used in common by the class methods
    • Where
    • And
    • With is the set of attributes (instance variables) accessed (read from or written to) by the -th method of the class

See also

edit

References

edit
  1. ^ MM Lehmam LA Belady; Program Evolution - Processes of Software Change 1985
  2. ^ In software engineering, a problem can be divided into its accidental and essential complexity [1].
  3. ^ Henry, S.; Kafura, D. IEEE Transactions on Software Engineering Volume SE-7, Issue 5, Sept. 1981 Page(s): 510 - 518
  4. ^ a b Chidamber, S.R.; Kemerer, C.F. IEEE Transactions on Software Engineering Volume 20, Issue 6, Jun 1994 Page(s):476 - 493

📚 Artikel Terkait di Wikipedia

Cyclomatic complexity

Cyclomatic complexity is a software metric used to indicate the complexity of a program. It is a quantitative measure of the number of linearly independent

Kolmogorov complexity

Kolmogorov complexity of an object, such as a piece of text, is the length of a shortest computer program (in a predetermined programming language) that

Complexity

Complexity characterizes the behavior of a system or model whose components interact in multiple ways and follow local rules, leading to non-linearity

Static program analysis

Analysis (SA) and Implicit Computational Complexity (ICC). SA is algorithmic in nature: it focuses on a broad programming language of choice, and seeks to determine

Implicit computational complexity

computational resources unlike conventional complexity theory. The central goal of ICC is to identify programming formalisms — such as restricted formal languages

Decomposition (computer science)

of composition, and is often used in object-oriented programming (OOP), structured programming, and structured analysis. A decomposition paradigm in

Datalog

Datalog, answer set programming, DatalogZ, and constraint logic programming. When evaluated as an answer set program, a Datalog program yields a single answer

No Silver Bullet

significant improvement in the area of accidental complexity was the invention of high-level programming languages, such as Ada. Brooks advocates "growing"