Home

Functions should end with RETURN statements

Description

    The PowerBuilder code rule that states "Functions should end with RETURN statements" means that all functions should include a RETURN statement as the last line of code. This statement is used to indicate the end of the function and to return a value to the calling program. By using RETURN statements, code can be written in a more organized and efficient manner, as well as making it easier for other developers to understand and debug the code.

Key Benefits

  • Clarity: Using return statements makes the code more readable and easier to understand.
  • Efficiency: Return statements make the code more efficient as the code is not unnecessarily executed.
  • Error Handling: Return statements make it easier to handle errors and debug the code.

 

Non-compliant Code Example

function string TestFunctionCall1 (string cnt)

return cnt;

cnt = 1  //Non compliant code (As function is having some statements after return statement)

end function

Compliant Code Example

function string TestFunctionCall1 (string cnt)

return cnt;  //Compliant code

end function
function int TestFunctionCall2()

int @count = 1 

if aa_value1 < aa_value2 then
	return @count   //Compliant code
elseif aa_value1 = aa_value2 then
	return @count   //Compliant code
else
	return @count   //Compliant code
end if

end function
Visual Expert 2024
 VEPBRULE32