Class has too many parameters

CachéQuality release 
1.0.2
Id 
OS0073
Rule type 
Severity 

Major

Major
SQALE characteristic 
  • Changeability
    • Logic
Tags 
design
Remediation function 
Constant/issue
Remediation cost 
1d

A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the class is doing too many things.

Noncompliant Code Example

The following code snippet illustrates this rule with a maximum number of 10 parameters:

Class Sample.Foobar
{
    Parameter A = "a";
    Parameter B = "b";
    Parameter C = "c";
    Parameter D = "d";
    Parameter E = "e";
    Parameter F = "f";
    Parameter G = "g";
    Parameter H = "h";
    Parameter I = "i";
    Parameter J = "j";
    Parameter K = "k";
}

Compliant Solution

Class Sample.Foobar
{
    Parameter A = "a";
    Parameter B = "b";
    Parameter C = "c";
    Parameter D = "d";
    Parameter E = "e";
    Parameter F = "f";
    Parameter G = "g";
    Parameter H = "h";
    Parameter I = "i";
    Parameter J = "j";
}