Home
Comments should not be located at the end of lines of code
Description
This rule states that comments should not be placed at the end of lines of code in PowerBuilder. This is because comments at the end of lines can be misinterpreted as part of the code, leading to potential errors. It is best to place comments on their own line, or at the beginning of the line of code, so that they are clearly separated from the code.
Key Benefits
- Improved readability : Increased readability of code by making it easier to follow the logic.
- Easier debugging : Easier to identify and fix errors due to clear separation between lines of code.
- Better maintainability : Reduced complexity and improved readability makes it easier to maintain code.
Non-compliant Code Example
forward global type te_n_cst_tmanager from t_n_cst_tmanager end type end forward global type te_n_cst_tmanager from t_n_cst_tmanager end type global te_n_cst_tmanager te_n_cst_tmanager on te_n_cst_tmanager.create call super::create end on on te_n_cst_tmanager.destroy call super::destroy end on event t_extendedaction; /*_____________________________________________________________________________ Description : Adds a new action extends Test standard actions. Comment : Arguments : apo_target_object : The target object on which the action must be processed. as_action : string containing the name of the action as_param : string containing parameters of action. Each parameter is separated by comma. Return : integer -1 if the action is failed, 2 if the action is unknown, 1 otherwise. Subject: Test Historique : V1.00 - HC - 07/06/2000 - Initial version. _____________________________________________________________________________ */ // Unknown action //Unknown action integer i_colnum, i String s_modify, s_objecttype datawindow ldw_target string ls_column CHOOSE CASE as_action CASE "disable column" // Extend 'disable column' action //Non compliant code // Verify if the type of the target object is correct for this action IF TypeOf (apo_target_object) = datawindow! THEN // This action can disable a group of columns. Each column is separated by comma. ldw_target = apo_target_object DO WHILE as_param <> "" ls_column = t_f_get_token(as_param,",") // Make the column's background opaque IF ldw_target.Modify (ls_column + ".Background.Mode='1'") <> "" THEN Return -1 END IF LOOP Return 1 ELSE Return -1 END IF CASE "enable column" // Extend 'enable column' action //Non compliant code // Verify if the type of the target object is correct for this action IF TypeOf (apo_target_object) = datawindow! THEN // This action can disable a group of columns. Each column is separated by comma. ldw_target = apo_target_object DO WHILE as_param <> "" ls_column = t_f_get_token(as_param,",") // Make the column's background transparent IF ldw_target.Modify (ls_column + ".Background.Mode='1'") <> "" THEN Return -1 END IF LOOP Return 1 ELSE Return -1 END IF CASE "extended readonly" // Add a specific action //Non compliant code if TypeOf (apo_target_object) <> datawindow! THEN Return -1 ldw_target = apo_target_object IF ldw_target.Modify ("DataWindow.ReadOnly='Yes'") <> "" THEN Return -1 END IF // Unknown action i_colnum = Integer(ldw_target.Describe("datawindow.column.count")) IF i_colnum < 1 THEN Return -1 FOR i = 1 TO i_colnum IF Long(ldw_target.describe("#" + String(i) + ".x")) <> 0 THEN s_modify = s_modify + " #"+String(i)+".background.mode = '1'" END IF NEXT IF ldw_target.Modify(s_modify) <> "" THEN Return -1 END IF // Unknown action Return 1 END CHOOSE // Unknown action Return 2 //Return 1 //Return 11 //Return 21 //Return 31 //Return 41 // Unknown action end event // Unknown action