When you ask ChatGPT to invent a new software metric.

ChatGPT has gained popularity in recent times. As a team with years of experience in the field of code quality, we decided to experiment with ChatGPT and asked it to create a new software metric. Before executing the query, we had doubts about whether we would get a good result, or any result at all. We were concerned that the response might be along the lines of:

“Creating a new software metric requires extensive testing in real projects to demonstrate its reliability as an indicator for improving code quality.”

However, to our surprise, we received a metric 🙂

But is this metric truly reliable as an indicator for maintainability?

Let’s analyze the formula: `lowCyclomaticComplexity + HighCohesion`

Our thought process behind this formula is as follows:

– Maintainability depends on the complexity of the methods.

– Maintainability also depends on the cohesion of the types.

– There’s no direct correlation between cyclomatic complexity and cohesion, which is why we used the `+` operator in the formula.

– To obtain a reliable result, it’s better to use a ratio that takes code size into account.

At first glance, this formula seems promising. However, in real projects, there’s a significant issue with this formula, particularly regarding the statement:

“There’s no direct correlation between cyclomatic complexity and cohesion.”

In such cases, we need to check if these two metrics are closely related or if one metric consistently exceeds the other. If one metric consistently dominates the other, it may render the metric irrelevant. In our case, the `lowComplexity` metric could be much higher compared to the cohesion metric, potentially overshadowing it and making the overall metric less meaningful.

To improve this metric, we can introduce additional operators like natural logarithms, multiplication, division, or other mathematical functions to refine the formula and achieve a more reliable result, much like what’s done with the Maintainability Index:

`Maintainability Index = 171 – 5.2 * ln(Halstead Volume) – 0.23 * (Cyclomatic Complexity) – 16.2 * ln(Lines of Code)`

How do we refine software metric formulas?

There’s no magic involved; it requires extensive testing in real projects and working with these metrics over months or even years to identify the factors or operators that lead to a reliable metric.


It’s essential to remember that ChatGPT and AI, in general, are valuable tools but won’t replace human expertise any time soon. Human validation and oversight are critical in all fields. So, don’t worry; AI won’t take your job; it will assist you in doing it better.

The Must-Have Solution for C, C++, and Java Developers

CppDepend for C/C++ and JArchitect for Java are powerful software tools that offer a wide range of features to help C, C++, and Java developers create high-quality code.

Don’t wait – take advantage of these valuable tools and start improving your code base today!

Continue reading “The Must-Have Solution for C, C++, and Java Developers”

Exploring C++ Coding Standards: Cert, Misra, Autosar, and CWE.

C++ coding standards are essential for any software engineer to ensure the software being developed is high quality, secure, and robust. They provide guidelines for software development, so it’s crucial to be familiar with them. In this blog post, we’ll explore four major C++ coding standards supported by CppDepend.

Continue reading “Exploring C++ Coding Standards: Cert, Misra, Autosar, and CWE.”

Are C++ and Java similar?

C++ and Java are two of the most popular programming languages in the world. Both are widely used for developing a variety of applications, ranging from desktop software to mobile applications, and from enterprise systems to gaming engines. Due to their popularity, many developers often wonder if C++ and Java are similar. In this blog post, we’ll take a closer look at these two languages and compare their similarities and differences.

Continue reading “Are C++ and Java similar?”

Code Complexity Analysis with CppDepend Tool

CppDepend is a powerful and versatile tool for analyzing code dependencies in C++. It is designed to help developers, architects, and project managers get a better understanding of the structure of their code and how different components depend on each other. With CppDepend, it is possible to visualize the relationships between different classes, methods, and other components, as well as to identify potential problems, such as tight coupling, circular dependencies, and other issues that can lead to code fragility and reduced maintainability.

Continue reading “Code Complexity Analysis with CppDepend Tool”

Discover CPPDepend 2023.1: New Features & Enhancements

CppDepend, the leading code analysis tool for C/C++ developers, announces the release of its latest version 2023.1, with exciting new features aimed at improving code quality and maintenance.

The latest version includes a Maintainability Index, which helps developers assess the maintainability of their code. The index is calculated using various metrics, including code complexity and design, and provides a single, easy-to-understand score that gives developers a quick understanding of the state of their codebase.

Continue reading “Discover CPPDepend 2023.1: New Features & Enhancements”

10 Essential Best Practices for Writing High-Quality C++ Source Code

Writing high-quality code is critical to the success of any software project, as it affects the reliability, performance, and maintainability of the code. In this blog post, we will discuss 10 essential best practices included in CppDepend for writing clean and efficient C++ source code. These best practices cover various aspects of coding, such as naming conventions, error handling, memory management, and more. Whether you are a beginner or an experienced programmer, following these best practices will help you write better C++ code and make your projects more successful.

Continue reading “10 Essential Best Practices for Writing High-Quality C++ Source Code”

GRASP Principles: Exploring Irrlicht 3D Engine

A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. Patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system.

“Gang of Four” patterns are maybe the most popular ones. However, there are some basic design principles not well-known by developers, it’s the General Responsibility Assignment Software Principles, abbreviated GRASP. Continue reading “GRASP Principles: Exploring Irrlicht 3D Engine”

Explore a flexible C/C++ SonarQube plugin based on CppDepend.

Both CppDepend and SonarQube are static analyzers that offer a rule-based system to detect problems in C/C++ code. However, the CppDepend default Rules-Set has very few overlaps with the SonarQube rules

Basically, the SonarQube rules are good at analyzing what is happening inside a method, the code flow while the CppDepend code model, on which the CppDepend rules are based, is optimized for a 360 view of particular higher-scale areas including OOP, dependencies, metrics, breaking changes, mutability, naming…
Continue reading “Explore a flexible C/C++ SonarQube plugin based on CppDepend.”

C++ 17 In Detail Book Review

Since its creation, C++ evolved continuously and it passed many major milestones from the C with classes to the rise of the new standards. From 1991 to 2011 the language evolved slowly and the evolution comes from the libraries like STL and Boost. However, from 2011 many features were added to the standard, thanks to the new standards C++11, C++14, C++17, and the coming C++20. Continue reading “C++ 17 In Detail Book Review”