I am currently writing my Master’s Thesis on maintainability of a web application. I found some methods like the “Maintainability Index” by Coleman et.al. or the “Software Maintainability Index” by Muthanna et.al.
For both of them one needs to calculate the cyclomatic complexity. So my question is:
Is it possible to measure the cyclomatic complexity of a web application?
In my opinion there are three parts to a web application:
- Server code (PHP, C#, Python, Perl, etc.)
- Client code (JavaScript)
- HTML (links and forms as operators, GET-parameters and form fields as operands!?)
What do you think? Is there another point of view on the complexity of web application? Did I miss something?
6
Cyclomatic complexity is one of the multiple measurements of code complexity. For example, in Visual Studio, the maintainability index depends on:
- Cyclomatic complexity,
- Depth of inheritance,
- Class coupling,
- Lines of IL code (IL code being the source code compiled to Intermediary Language which is then JIT-compiled).
Every of those measurements, as well as other complexity measurements, work somehow, but are never the absolute indication that the source code has complexity issues. Some measurements, as LOC, are known to be totally meaningless and misleading; others, like cyclomatic complexity, are slightly better, but still have issues.
This is due to the fact that:
-
It is too complicated for a computer program to know how really complex the source code would be perceived by a developer.
For example, I often noticed a huge drop of maintainability index when refactoring the code from procedural-style to functional-style through LINQ, transforming a block of highly unreadable source code into a single chaining expression which was extremely explicit.
Another example would be the reflection of programming patterns on the metrics. Often, by introducing programming patterns into your code, you will make it less complex for a developer (assuming this developer is familiar with those patterns), but the maintainability index will drop.
-
Source code can have different forms.
Measuring cyclomatic complexity or depth of inheritance or class coupling is very limited for a web application, because, as you said, the existence of HTML/CSS, JavaScript, etc., and, as noted in the comments, the existence of database access.
This limitation doesn’t exist only for web apps. In desktop applications, for example, what about the complexity of the UI layout (XAML code in Windows applications)? What about the generated code? Or database access?
1