ACR Rules

⌘K
  1. Home
  2. Docs
  3. ACR Rules
  4. Architecture (16)
  5. Minimize the use of self-relations

Minimize the use of self-relations

Introduced in version 2.5 (released May 2021), extended in version 2.7 (release September 2021)

Self-relations are harder to understand in the domain model and especially in xpath queries. Mendix even introduced a reversed() function to determine the direction of the xpath association to be used in a self-relation. The advice therefore is to minimize the use. And if self relations are needed, document them well, test them well and use the allow list for the violation.

Non-compliant examples

Case 1: The basic self relation

Case 2: Child entity refering to parent it inherits from

Case 3: Rare case of a parent entity refering to a child entity

Compliant example

Any domain model entity not fitting in the above cases.

Configuration

This rule can check self-relations in two ways, direct and also relations to parent or child entities. The latter are sometimes wanted in complex architectures with tree-like data structures. In that case you can configure this rule or annotate to exclude violations.