Cognitive Complexity: the New Guide to Refactoring for Maintainable Code

Опубликовано: 02 Апрель 2026
на канале: Chadev
4,690
41

Description:
Until now, there's been no good way to measure the understandability of a method. Cyclomatic Complexity was supposed to do that, but doesn't quite get it right. With the help of my colleagues at SonarSource (the company behind SonarQube) I've drafted Cognitive Complexity, which gives more accurate measures of control flow understandability.

In this talk, I'll explain the Cognitive Complexity methodology, show you how it applies to a number of code samples, and demonstrate how to use a method's Cognitive Complexity score as a guide to refactoring for simpler, more maintainable code.

Bio:
G. Ann Campbell is a Product Manager at SonarSource SA, the company behind SonarQube, SonarLint, the Sonar Code Analyzers, and SonarQube.com. 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 a result, she is passionate about helping developers write better code.