NPath complexity and cyclomatic complexity explained

Both terms are used to determine the complexity of code. It's always good to keep your code simple and readable as referred in KISS principle.

CyclomaticComplexity
https://phpmd.org/rules/codesize.html

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

NPath complexity

The NPath complexity of a method is the number of acyclic execution paths through that method.

References:

ttps://www.tutorialspoint.com/softwaretestingdictionary/cyclomatic_complexity.htm

https://modess.io/npath-complexity-cyclomatic-complexity-explained/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.