Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 1.15 KB

NumberOfOptionalParams.md

File metadata and controls

31 lines (22 loc) · 1.15 KB

Limit number of optional parameters in method (NumberOfOptionalParams)

Description

It is not recommended to declare many parameters in functions (best practice to use not more than seven parameters). Meanwhile there should not be many parameters with default values set (best practice to have not more than three such parameters). Otherwise code readability decreases. For example it is easy to make a mistake in number of commas passing optional parameters.
If need to pass many parameters to a function, it is recommended to group same-type parameters into one or more composite parameters of type Structure.

Examples

Incorrect:

// Create an item in catalog "Goods"
Procedure CreateSKU(Name, Goods, Units, Weight, Check = True)
// ... 
EndProcedure

Correct:
Group parameters, having goods item properties into Structure Values.

// Create item in catalog "Goods"
Procedure CreateNewGoods(Values, Check = True)
EndProcedure

Sources