logoalt Hacker News

aDyslecticCrowtoday at 3:14 PM1 replyview on HN

> 6-deep nested if/else blocks

We found a 4000 Loc single-file single-function c program running a functional safety domain. With nesting so deep that you need to change the font-size or get a wider monitor. We're not allowed to touch or replace it because it's pre-certified.


Replies

SoftTalkertoday at 3:35 PM

Deeply nested if/else blocks are logically the same if you split them up into classes or functions that perform the same logic. They are harder to understand, harder to re-use, harder to work with in an editor... but should not be harder to test (you need to test all the possible use cases either way).