1

I know when we reduce cyclomatic complexity, it makes our code easier to read and maintain.

But are there any other documented, tangible benefits, specifically around improving build time?

It seems to me that, at least with the Microsoft CLR, that as C# or VB are being compiled, that lower cyclomatic complexity could potentially improve the build time, especially for really large, monolithic projects.

Kevin McDowell
  • 532
  • 6
  • 20
  • The main advantage for lowering the complexity would be the readability and testability of the code. Don't know if it affects build time though. – Paul Sinnema Dec 08 '20 at 20:33

1 Answers1

1

If you consider the time to run the tests during the build, the answer is yes.

Source: https://en.wikipedia.org/wiki/Cyclomatic_complexity

Moises Marques
  • 171
  • 1
  • 5
  • 1
    That's if only if you map a unit test for every single path through a function. Reducing cyclomatic complexity often means creating new functions as you pull code out of massive function into smaller pieces. You may still end up with the same number of tests. What I'm really curious about is if the actual build, not the test run, is impacted by high cyclomatic complexity (and conversely if reducing it, can improve build time). – Kevin McDowell Dec 09 '20 at 01:05