alguidelines/content/docs/NAVPatterns/3-cal-coding-guidelines/design/unreachable-code/index.md
2022-02-24 14:45:35 +01:00

441 B

+++ title = "Unreachable Code" weight = 1310 tags = ["C/AL"] categories = ["Best Practice"] +++ Do not write code that will never be hit.

It affects code readability and can lead to wrong assumptions.

Bad code

IF Type <> Type::FIELD THEN BEGIN
    ...
    ERROR(...);
    RecRef.CLOSE;
END;  

Good code

IF Type <> Type::FIELD THEN BEGIN
    ...
    RecRef.CLOSE;
    ERROR(...);
END;