CQM-LateAbstraction

An abstract class has a direct or indirect non-abstract parent class

Required inputs: RFG

Any abstract class with a direct or indirect non-abstract superclass is a violation.

Motivation

The tool of abstraction helps to extract commonalities of different specific artifacts. Mapped to inheritance structures, an expectation can be derived from this, where the more abstract classes are superclasses of more specific subclasses. If this preservation attitude is violated ,i.e., there is an abstract class which inherits directly or indirectly from a non-abstract class, this results in great difficulties of understanding.The different characteristics of abstract and non-abstract classes (e.g. the possibility for instantiation) and the special treatment necessary thereby depending upon class hinder the homogeneous view of inheritance subtrees, since e.g. general requirements of the co- and contravariance are hurt ( superclasses can with the late abstraction e.g. something, which subclasses cannot, like e.g. objects produce). Formally, the late abstraction can be understood as a violation of the Liskov Substitution Principle: The concrete class can be instantiated, but not arbitrarily replaced by instances of its derivatives - the abstract class is not instantiable.

This rule is based on the CQM Quality Indicator: späte Abstraktion (p. 288-290).

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

late_abstraction

This abstract class has a direct or indirect non-abstract parent class.

None

False

Options

include_structs

include_structs : bool = False

Whether structs are to be analyzed.
 

include_template_classes

include_template_classes : bool = False

Whether template classes are to be analyzed.