Hi!, hope everyone's weekend is going well.
Have you ever heard about Cognitive Complexity and how it can affect your code?
Cognitive complexity is a way to measure or tell how complex or simple people think about a particular thing or issue, but how can this affect your code? Well, there's a huge difference in writing:
Integer gftCpnCod = 12;
Integer giftCuponCode = 12;
That seems to be a little thing but you have to remember that someone will be supporting or maintaining that code, the world goes around a lot, and it's better to make everyone's life a little easier, right?
Using Cognitive complexity to tell us how difficult our code will be to a reader that is trying to understand it, can improve a lot the way you write code making it more robust and easy to maintain in the future.
Knowing how to measure how difficult is your code to be understood by humans can be the difference between minutes and hours of trying to understand any code before start working with it, in the articles below you will find how to understand, measure, and refactor using this concept:
Paper about Cognitive complexity: https://www.sonarsource.com/docs/CognitiveComplexity.pdf
Refactoring using Cognitive Complexity: https://blog.devgenius.io/refactoring-using-cognitive-complexity-7e55197335b6