Source code measurement

"You can't manage what you can't control, and
you can't control what you don't measure."
(Tom DeMarco)

Software measurement is an essential element of management; there is little chance of controlling what we cannot measure. Software metrics are measures of some property of a piece of software, its source code or its specification. There are several aspects of measuring software attributes:

A software metric is a measure of some property of a piece of software or its specification. Tom DeMarco stated, “You can’t control what you can't measure.” Measuring metrics is the first step to get to know to a product’s quality.
Read more >> || Source code metrics for C/C++(PDF), C#(PDF), Java(PDF)
  • Specification related measures (e.g. function point metrics)
  • Process metrics (e.g. average time spent for fixing a bug)
  • Product metrics (e.g. source code complexity)

Although the fundamental assumption of software quality assurance states that the quality of a software is in strict correlation with the quality of the processes which were used during the development phase, product metrics have their reason of existence because of the followings:

  • It is often the case that a version of the system already exists when a process based quality assurance is introduced (nothing is known about the quality of the already existing system).
  • Product metrics validate process metrics.
  • A prototype product is already available at early stages of the development, therefore poduct metrics and other product related attributes can be calculated.

Therefore, a well constructed software quality assurance methodology has to utilize both process and product related metrics to complement each other.

The what and why of software measurement

Software metrics help to avoid pitfalls:

  • Cost overruns: Most projects fail to separate design and coding costs. Doing so helps identifying where problems exist.
  • Clarify goals: Project goals are often fuzzy, and so it is difficult to quantify how well they have been achieved.

Metrics can help in answering certain questions:

  • How productive is the staff?
  • How good is the code being developed?
  • How can the code under development be improved?

Metrics can also be used for:

  • Cost and effort estimation.
  • Productivity estimation.
  • Consistent data collection approach for all the projects - possibility of comparing attributes of different projects.
  • Estimating quality of the software - bad code is not worth much, even if lots of it is written quickly.

Software metrics play a crucial role in the continuous refactoring approach of software maintenance.

What to measure?

Besides the well-known source code metrics (e.g. cyclomatic complexity, coupling, cohesion), the FrontEndART SourceAudit tool is capable of measuring several other measurable aspects of code, like the amount of:

  • Coding rule violations
    Best practices provide guidelines for writing good, fast, maintainable, secure code. FrontEndART's products are capable of checking whether these best practices are being adhered to or not by developers. Besides these best practices, the tools can detect serious programming errors, which are either caused by unawareness or inadvertence of the developers. Read more >>

    The amount of coding problems from a particular rule violation category also represents a metric for each source code item.

  • Bad code smells
    In computer programming, bad code smell is a symptom in the source code that possibly indicates a deeper problem, which can lead to a malfunctioning software.
    Read more >> || Description of bad smells (PDF)

    The amount of bad code smells also represents a metric for each source code item.

  • Code duplications
    It is a common practice to reuse source code by simply copying and pasting its parts. Although this approach can reduce software development time, the price in the long-term must be paid in the form of increased maintainability costs. One of the primary concerns is that if the original code segment needs to be corrected, all the copied parts need to be checked and changed accordingly as well.
    Read more >> || Description of code duplications (PDF)

    Several metrics exist to measure the code duplication (copy & paste) intensity across the code base.