Skip to main content
2 of 2
Dressed the naked link.

From Cyclomatic complexity (Wikipedia):

The cyclomatic complexity of a section of source code is the count of the number of linearly independent paths through the source code.

  • I recommend that you keep that number under 10 in a single method. If it gets to 10, then it's time to re-factor.

  • There are tools that can evaluate your code and give you a cyclomatic complexity number.

  • You should strive to integrate these tools into your build pipeline.

  • Don't literally chase a method size, but try to look at its complexity and responsibilities. If it has more than one responsibility, then it's probably a good idea to re-factor. If its cyclomatic complexity increases, then it's probably time to re-factor.

  • I'm fairly certain there are other tools that give you similar feedback, but I didn't have a chance to look into this yet.

CodeART
  • 4.1k
  • 1
  • 22
  • 23