Home
Jump statements should not be redundant
Description
The "Jump statements should not be redundant" rule in PowerBuilder code states that jump statements, such as GOTO, EXIT, BREAK, and CONTINUE, should not be used unnecessarily. Unnecessary jump statements can make code harder to read and debug, as well as leading to unexpected behavior. When writing code, it is best to avoid redundant jump statements and use alternative control flow structures, such as loops and conditional statements, whenever possible.
Key Benefits
- Reduced complexity: Jump statements should not be redundant, as this reduces the complexity of the code.
- Increased readability: By avoiding redundant jump statements, the code is easier to read and understand.
- Improved maintainability: By avoiding redundant jump statements, the code is easier to maintain and debug.
- Increased efficiency: By avoiding redundant jump statements, the code can be more efficient and faster.
Non-compliant Code Example
function string TestFunctionCall (string cnt)
integer A = 1, B = 1
DO WHILE A <= 15
A = (A + 1) * B;
CONTINUE; //Non compliant code (Jump statement is redundant)
LOOP
return cnt
end function
Compliant Code Example
function string TestFunctionCall (string cnt) integer A = 1, B = 1 DO WHILE A <= 15 A = (A + 1) * B; LOOP return cnt end function