DEV Community

loading...

Discussion on: Clean up your code by removing unneeded indentation ๐Ÿงน

Collapse
ferenczy profile image
Dawid Ferenczy • Edited

What you're describing is a valid point, it's a form of the source code optimization, but you're naming it wrong. The indentation is quite insignificant property of a source code, it's there just for better readability by humans and it's more (e.g. in case of Python) or less just a consequence of the cyclomatic complexity. And the cyclomatic complexity is, in fact, what you're trying to optimize, more specifically it's called optimization by reduction of the cyclomatic complexity.

When you reduce the cyclomatic complexity, the indentation is also reduced as the result or the consequence of such optimization. And such reduction has an impact on several properties of the source code (e.g. testing, clarity, code organization, performance, etc.).

On the other side, when you reduce the indentation, it doesn't have any impact on the cyclomatic complexity, you're just changing the readability of the source code.

Thomas McCabe, who came with the term cyclomatic complexity in 1976, proposed that the cyclomatic complexity of a module should be kept under 10.

I hope it's understandable as I have described it.