CQM-SignatureLikeClasses

Two unrelated classes should not have most of their routines in common

Required inputs: IR

Two classes that do not inherit from each other or have a common superclass are considered a violation if more than 10 routines or more than 50 percent of the routines from both have the same signatures.

Motivation

Inheritance is an important concept for making similarities between different classes explicit. Once this is done, it creates higher-level class clusters, each of which can be understood, maintained, and tested cohesively. An important aspect of similarity is identical signatures of routines.

If classes exist that have no direct or indirect relation to inheritance, but nevertheless have many similarities, the advantages of inheritance are not used for this class. Rather, this results in risks of repeated maintenance, repeated testing, and duplication with subsequent variant construction. In particular, the lack of explicitly made class clusters has a significant negative impact on understanding and modifying large systems.

This rule is based on the CQM Quality Indicator: signaturähnliche Klassen (p. 281-284).

Reference

Simon, Frank/ Seng, Olaf/ Mohaupt, Thomas (2006): Code-Quality-Management: Technische Qualität industrieller Softwaresysteme transparent und vergleichbar gemacht, 1st ed., Heidelberg, Germany: dpunkt.verlag GmbH.

Possible Messages

Key

Text

Severity

Disabled

signature_like_classes

These classes share {num} routines with the same signatures.

None

False

Options

max_number_routines

max_number_routines : int = 10

Maximal number of fields with the same name allowed across subclasses.
 

max_percentage_routines

max_percentage_routines : float = 50.0

Maximal percentile of subclasses allowed to contain a field with the same name.