Home > Articles > Programming > C/C++

  • Print
  • + Share This
Like this article? We recommend

Summary: Metrics-Driven Coding Improves Quality

Though modern coding is becoming increasingly difficult, programmers need not despair. Instead, with a subtle change in mindset, we can view the plethora of languages as just a set of tools, which are intended to be used. With metrics as your guide, you can add value to the main coding effort as well as to the review process. Indeed, proper use of the metrics suite will help you to avoid some of the most common and dangerous code defects.

For example, correctly de-allocating resources—memory, file handles, and instantiated objects that use such resources—is a crucial skill. These resources are borrowed from the host system by your code. If you don’t return the allocated resources, your code can cause serious difficulties.

Another major source of error is concurrency design problems. A typical use case is a program that works fine on a single-core target, but fails when run re-entrantly on a multi-core target. Closer metrics-driven examination indicates that such systems have generally been written with inadequate abstraction and weak exception-handling capabilities.

A metrics-driven approach works well in the context of C code and Java code. While writing Five Steps to Better Multi-language Programming Using Metrics: Simplicity in Multi-language Coding: C/C++, Java, Bash, and Python, I found it interesting that metrics can be applied equally well to Bash scripting, Python, Java, C++, and so on. In other words, the metrics techniques are pretty much language-agnostic. An important part of metrics use is acquiring the ability (and inclination) to read, understand, safely modify, and test code written by others.

  • + Share This
  • 🔖 Save To Your Account