Refactoring with Cognitive Complexity, the new option for measuring understandability

Tools

G. Ann Campbell

For 40 years, Cyclomatic Complexity has been the de facto standard for measuring testability and maintainabiliy. While it’s absolutely accurate for testability, the same can’t be said for maintainability. Cognitive Complexity solves the problem, and returns “fair” relative measurements of control flow complexity.

In this session, you’ll learn what the Cognitive Complexity methodology is and why you should add it to your toolbox alongside Cyclomatic Complexity, see how it applies to a number of code samples from open source projects, and learn how to use a method’s Cognitive Complexity score as a guide to designing simpler, more maintainable code, and refactoring existing code for better understandability.

Cognitive Complexity is already available as a new rule in some Sonar code analyzers, and should be available throughout the SonarQube ecosystem by the end of 2017.