deliver:Agile 2018 has ended
Back To Schedule
Tuesday, May 1 • 11:15 - 12:00
Refactoring with Cognitive Complexity (G. Ann Campbell)

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

For 40 years, cyclomatic complexity has been the de facto standard for measuring testability and maintainability. 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 metric suite. You’ll see how it applies to a number of code samples from open-source projects on SonarCloud.io. And you’ll learn how to use a method's cognitive complexity score as a guide to designing better code and refactoring existing code to be simpler and more maintainable. Because there's no "cost of entry" with Cognitive Complexity, a high cognitive complexity at the class level is a reliable indicator that a class contains a lot of logic, not just a lot of methods. That is, you can use cognitive complexity to sift POJOs from the logic-intense classes that impose a higher maintenance burden. Cognitive Complexity is available in most of the SonarQube ecosystem, but is an open standard, implementable by all.

Learning Outcomes:
  • Learn what Cognitive Complexity is (and why it's needed in addition to Cyclomatic Complexity)
  • Understand how Cognitive Complexity is assessed
  • See how Cognitive Complexity can be used as a guide to refactoring for simpler, more maintainable code


avatar for G. Ann Campbell

G. Ann Campbell

Product Manager, SonarSource SA
G. Ann Campbell is a Product Manager at SonarSource SA, the company behind SonarQube, SonarLint, and SonarCloud. She has coded in Perl, C, and Java as well as the usual assortment of web development technologies. In the process, Ann has seen some good code and a lot of bad code. As... Read More →

Tuesday May 1, 2018 11:15 - 12:00 CDT
Lone Star F/G