Agile Event Session

Refactoring with Cognitive Complexity

This video content is for Agile Alliance members only

If you’re already an active member, please log in now.

To view this content, and gain access to many more valuable resources, conference discounts, and invitations to exclusive networking and learning events, please consider becoming an Agile Alliance member.

Abstract/Description

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.

Additional Resources

Speaker(s) may be willing to present this session at local group meetings and other events.

deliver:Agile 2018
Slides, Video
Practicing

More Agile Event Session Videos

FP vs. OOP: Beyond the Bikeshed
In object-oriented languages like Ruby, people often say that “everything is an object”—but first-class functions have become standard for object-oriented languages too. C# has had them and other related features for years, and even Java is in the ga…
Testing Without Mocks: A Practical Guide
Are your tests slow or brittle? Do you get a sinking feeling when you need to refactor? Do you worry your unit tests aren't actually testing anything important? If so, you could benefit from exploring a mock-free approach to TDD. This session is a c…
Building Your Team to Last
Hiring and on-boarding new team members is an expensive and risky process. It's crucial to hire people who mesh well with the existing team and get them up to speed in a timely manner. Balancing this while minimizing the initial impact on productivit…
FP vs. OOP: Beyond the Bikeshed
In object-oriented languages like Ruby, people often say that “everything is an object”—but first-class functions have become standard for object-oriented languages too. C# has had them and other related features for years, and even Java is in the ga…
Testing Without Mocks: A Practical Guide
Are your tests slow or brittle? Do you get a sinking feeling when you need to refactor? Do you worry your unit tests aren't actually testing anything important? If so, you could benefit from exploring a mock-free approach to TDD. This session is a c…
Building Your Team to Last
Hiring and on-boarding new team members is an expensive and risky process. It's crucial to hire people who mesh well with the existing team and get them up to speed in a timely manner. Balancing this while minimizing the initial impact on productivit…

Have a comment? Join the conversation

Discover the many benefits of membership

Your membership enables Agile Alliance to offer a wealth of first-rate resources, present renowned international events, support global community groups, and more — all geared toward helping Agile practitioners reach their full potential and deliver innovative, Agile solutions.

IMPORTANT: We have transitioned to a new membership platform. If you have not already done so, you will need to set up an account on the new platform to establish your user profile.

When you see the login screen, choose “Set up Account” and follow the prompts to create your new account. You can choose to log in using your social credentials for either Google or Linkedin (recommended), or you can set up your account using an email address.

Not yet a member? Sign up now