Live data from Hacker News

Measuring Software Complexity: What Metrics to Use?

thevaluable.dev

81–87 of 87 posts

Re: Measuring Software Complexity: What Metrics to Use?

#81
post #7

Ugh, no. I’ve worked in a codebase where CI would reject changes that had too much ‘code complexity’. You’d constantly have to find clever ways to split up your code, when doing so did not make sense, to appease the complexity checker. Oh yeah, and if you ever make a one-liner change, you might end up being forced to do a full refactor because that one line pushed the complexity threshold over the edge. The results:…

Cyclomatic complexity (which I think is the most common one used) also doesn't really map to what people understand as complex. A giant switch statement with one return per case isn't nearly as complicated as two large nested if/else blocks. Nesting almost inevitably means more contexts you need to keep track of when reading code, particularly nester conditionals.

Re: Measuring Software Complexity: What Metrics to Use?

#82
post #61
post #2

This talks about code complexity a lot. This, however, is not the chief source of complexity in many code bases. The number of tools needed to build things is the bane of the modern software developer. Also, the use of microservices where none are needed results in and enormous increase in complexity. Code complexity is relatively easy to fix compared to all of this.

I have seen a team be forced to use microservices for things still running on the same machine years later, with absolutely no benefit other than the powerpoint architecture slides looking fancier.

> I have seen a team be forced to use microservices for things still running on the same machine years later, with absolutely no benefit other than the powerpoint architecture slides looking fancier.

The main driving force for microservices is not technical but organizational. Therefore, there are plenty of non-technical issues, such as for example budget to grow and split a team, that make or break the adoption of this style of architecture.

Re: Measuring Software Complexity: What Metrics to Use?

#83
> Our work, as developers, pushes us to take many decisions, from the architectural design to the code implementation. How do we make these decisions? Most of the time, we follow what “feel right”, that is, we rely on our intuition.

So no engineering best practices. That explains very good the quality of SW.

Re: Measuring Software Complexity: What Metrics to Use?

#84
post #7

Ugh, no. I’ve worked in a codebase where CI would reject changes that had too much ‘code complexity’. You’d constantly have to find clever ways to split up your code, when doing so did not make sense, to appease the complexity checker. Oh yeah, and if you ever make a one-liner change, you might end up being forced to do a full refactor because that one line pushed the complexity threshold over the edge. The results:…

I always had good experiences with it. I found abstractions that really did make sense, instead of treating it like a chore.

Re: Measuring Software Complexity: What Metrics to Use?

#85
post #82
post #61

Earlier quoted context omitted.

I have seen a team be forced to use microservices for things still running on the same machine years later, with absolutely no benefit other than the powerpoint architecture slides looking fancier.

> I have seen a team be forced to use microservices for things still running on the same machine years later, with absolutely no benefit other than the powerpoint architecture slides looking fancier. The main driving force for microservices is not technical but organizational. Therefore, there are plenty of non-technical issues, such as for example budget to grow and split a team, that make or break the adoption of t…

Maybe. These particular ones were never properly decoupled.

Re: Measuring Software Complexity: What Metrics to Use?

#86
post #53
post #16

Earlier quoted context omitted.

Couldnt yout just raise the threshold by tweaking the config with your PR instead? I do this all the time with other automated checkers (linters, etc.). I don't see why this should be different. If another human agrees it shouldnt be a problem.

Because if you change that config file, people responsible for it will be added to review, and will beat you with a stick for touching it without consulting change with them?

That sounds like a people problem that will manifest in all sorts of terrible ways and not really an indictment of code complexity metrics.

Re: Measuring Software Complexity: What Metrics to Use?

#87
post #30
post #7

Ugh, no. I’ve worked in a codebase where CI would reject changes that had too much ‘code complexity’. You’d constantly have to find clever ways to split up your code, when doing so did not make sense, to appease the complexity checker. Oh yeah, and if you ever make a one-liner change, you might end up being forced to do a full refactor because that one line pushed the complexity threshold over the edge. The results:…

I was removing unused functionality, work became held up as the code complexity was too high (never mind I'd just reduced it). I don't know what tool they were using, and they didn't share the output. I asked them to document what they found, got a mouthful on this not being their responsibility.

Sounds like a group that didn't understand the tool and just put it in place. Metrics and tools make good servants but poor managers.
Post reply on HN