Home
IF statement conditions should not evaluate unconditionally to TRUE or to FALSE
Description
The IF statement conditions should not evaluate unconditionally to TRUE or to FALSE rule is a guideline for PowerBuilder developers to ensure that their code is properly structured and functioning correctly. This rule states that IF statements should not contain conditions that will always evaluate to either TRUE or FALSE. Instead, the conditions should be dynamic and based on the values of variables or other conditions. This ensures that the IF statement will be executed correctly and that the desired results will be achieved. By following this rule, developers can avoid potential errors and maintain the integrity of their code.
Key Benefits
- Prevents Unconditional Evaluation - IF statement conditions should not evaluate unconditionally to TRUE or to FALSE rule prevents code from being executed without the proper conditions being met.
- Ensures Accuracy - This rule ensures that code is executed only when the proper conditions are met, which helps to ensure accuracy and reduce errors.
- Improves Efficiency - By avoiding the unnecessary execution of code, this rule helps to improve the efficiency of the program.
- Ensures Readability - By avoiding the unnecessary execution of code, this rule helps to make the code more readable and easier to understand.
Non-compliant Code Example
function string TestFunctionaCall (string cnt) if true then //Non compliant code messagebox('true') end if if false then //Non compliant code messagebox('false') end if return cnt end function
Compliant Code Example
function string TestFunctionaCall (string cnt) if cnt == 'true' then //Compliant code messagebox('true') end if if cnt == 'false' then //Compliant code messagebox('false') end if return cnt end function