Functions and procedures should not have too many parameters


    The code rule "Functions and procedures should not have too many parameters" states that functions and procedures should be kept as simple as possible, with a limited number of parameters. Having too many parameters can make the code difficult to read, understand, and maintain. It can also lead to increased complexity and a greater chance of errors. When designing functions and procedures, it is important to keep the number of parameters to a minimum, and to use descriptive names for each parameter. This will make the code easier to read and maintain, and will reduce the chances of errors.

Key Benefits

  • Fewer parameters: Less parameters means less complexity and easier to debug.
  • Easier to maintain: With fewer parameters, the code is easier to maintain and update.
  • Better readability: Fewer parameters make the code easier to read and understand.
  • Better performance: Fewer parameters reduce the time it takes to execute the function or procedure.


Non-compliant Code Example

CREATE procedure [DATA].sp_GetEmployee(@fname nvarchar(10), @lname nvarchar(10),@mname nvarchar(10), @city nvarchar(10),@state nvarchar(10), @designation nvarchar(10),@level nvarchar(10), @technology nvarchar(10),@expierence nvarchar(10), @expertise nvarchar(10),@joinSince nvarchar(10))  --Non compliant code (Number of parameters are more then default defined limit 10)
	Select [DATA].[GetEmployee](@fname, @lname,@mname,@city,@state,@designation,@level, @technology,@expierence,@expertise,@joinSince);
Visual Expert 2024