Class has too many properties

objectscriptQuality release 
1.0.2
Id 
OS0072
Rule type 
Code Smell
Severity 

Major

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

A long property list can indicate that a new structure should be created to wrap the numerous properties 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 properties:

Class Sample.Foobar
{
    Property a As %String;
    Property b As %String;
    Property c As %String;
    Property d As %String;
    Property e As %String;
    Property f As %String;
    Property g As %String;
    Property h As %String;
    Property i As %String;
    Property j As %String;
    Property k As %String;
}

Compliant Solution

Class Sample.Foobar
{
    Property a As %String;
    Property b As %String;
    Property c As %String;
    Property d As %String;
    Property e As %String;
    Property f As %String;
    Property g As %String;
    Property h As %String;
    Property i As %String;
    Property j As %String;
}

Parameters

NameDescriptionDefault value
nrPropertiesThreshold
Maximum allowed number of properties (inclusive)
10