Contents > C: List of Design Rules > C.1 Class Rules

C.1 Class Rules

Rule: UnnamedCategory: Completeness
Severity: 1-highApplies to: all areas
Class has no name.

Give the class a descriptive name that reflects its purpose. Unnamed classes will cause problems during code generation.


Rule: UnusedCategory: Completeness
Severity: 1-highApplies to: all areas
The class is not used anywhere.

The class has no child classes, dependencies, or associations, and it is not used as parameter or property type. You'll probably still need to model the clients of the class, or else consider deleting the class from the model.

Note: for models that were reverse-engineered from source code, this rule may falsely report many classes as "unused". This happens for classes that are only referenced in method implementations, e.g., via local variables.

  • Suggested in [Rie96] (heuristic #3.7 eliminate irrelevant classes).


Rule: NotCapitalizedCategory: Naming
Severity: 3-lowApplies to: all areas
Class names should start with a capital letter.

This naming convention is a recommended style guideline in the UML standards [OMG03], [OMG05].


Rule: GodClassCategory: Style
Severity: 2-medApplies to: all areas
The class has more than 60 attributes and operations.

Also known as blob classes, large classes are likely maintenance bottlenecks, sources of unreliability, and indicate a lack of (object-oriented) architecture and architecture enforcement.

Consider refactoring the class to split it up into smaller classes.

  • Threshold of 60 cited in [BMM98].
  • See also metrics NumOps and NumAttr
  • Also known as "Large Class" code smell [Fow99].
  • Value reported: number of operations and attributes.


Rule: KeywordCategory: Naming
Severity: 2-medApplies to: design
Class name is a Java or C++ keyword. Using programming language keywords for class names will cause problems during code generation. Find another name for the class. Capitalizing the name will also help, see rule NotCapitalized.


Rule: MultipleInheritanceCategory: Style
Severity: 3-lowApplies to: all areas
Use of multiple inheritance - class has more than one parent.

The use of multiple inheritance is controversial. Some OO programming languages do not support multiple inheritance. Review the class design to confirm that the use of multiple inheritance is justified.


Rule: SpecLeafClassCategory: Correctness
Severity: 1-highApplies to: all areas
Class is marked as leaf, but it has child classes.

Leaf classes cannot have any child classes. This is a WFR of the UML.


Rule: NoSpecCategory: Completeness
Severity: 2-medApplies to: all areas
Abstract class has no child classes.

Abstract classes cannot be instantiated. Without specializations that can be instantiated, the abstract class is useless.

  • Suggested in [Rie96].
  • Violations of this rule would be justified if the class is part of a framework or library, and is meant to be extended by users of the framework/library.


Rule: CyclicInheritanceCategory: Inheritance
Severity: 1-highApplies to: all areas
Class inherits from itself directly or indirectly.

The inheritance graph must be a tree, no cycles are allowed.

  • This is a WFR of the UML.
  • You can view the inheritance graph in the graph structures dialog.
  • Value returned: number of classes in the cycle.


Rule: ConcreteSuperCategory: Style
Severity: 1-highApplies to: all areas
The abstract class has a parent class that is not abstract.

This is bad design. A child class should be substitutable for the parent class. Since the parent class can be instantiated, but not the child class, substitution is not possible anymore.

  • Suggested in [Lan03].
  • Value returned: name of the concrete parent class.


Rule: DupOpsCategory: Correctness
Severity: 1-highApplies to: all areas
Class has duplicate operations.

There are two or more operations with identical signatures (i.e., operation name and list of parameter types). Operation signatures must be unique within the class.

  • This is a WFR of the UML.
  • Value reported: name of the duplicate operation.


Rule: DupAttrNamesCategory: Correctness
Severity: 1-highApplies to: all areas
The class has two or more properties with identical names.

Attribute names must be unique within the class.

  • This is a WFR of the UML.
  • Value reported: name of the duplicate attribute.


Rule: AttrNameOvrCategory: Naming
Severity: 2-medApplies to: all areas
The class defines a property of the same name as an inherited attribute.

During code generation, this may inadvertently hide the attribute of the parent class. Consider changing the name of the attribute in the child class.


Rule: DescendentRefCategory: Style
Severity: 1-highApplies to: all areas
The class references a descendent class via associations, UML dependencies, attribute or parameter types.

This is poor design. A class c should be oblivious of its descendent classes. The reference to the descendent class and the inheritance links back to class c effectively form a dependency cycle between these classes.

Redesign this to eliminate the need for the reference to the descendent class.

  • Suggested in [RVR04], [Rie96].
  • Value reported: name of the referenced descendent class.


Rule: DepCycleCategory: Style
Severity: 2-medApplies to: all areas
The class has circular references.

Circular dependencies should be avoided. The classes participating in the cycle cannot be tested and reused independently. The more classes participate in the cycle, the worse the problem is, especially if the classes reside in different packages (see also rule DepCycle for packages).

Consider revising the design to eliminate the cycle.

  • See also: Dependency Inversion Principle [Mar03].
  • You can view the class dependency graph and its cycles in the Graph Structures View.
  • Value reported: number of classes in the cycle.