-
Notifications
You must be signed in to change notification settings - Fork 0
Generalizations
Here is an example of a generalization relationship.
R38
Bank Level +
Top Bank Level
Middle Bank Level
Bottom Bank Level
<subclass>.(Bank, Floor) -> Bank Level.(Bank, Floor)
--
And here's a snippet from the generated diagram:

Here we are specifying the superclass, subclasses and the referential attribute formalization using this grammar:
// Generalization
gen_rel = superclass subclasses genref // A generalization relationship
superclass = INDENT icaps_name SP? "+" EOL* // A superclass class name
subclasses = subclass+
subclass = INDENT INDENT icaps_name EOL* // A subclass class name
// Genref
genref = single_line_genref / binref+ // Either abbreviated <subclass> source or explicit source for each subclass
single_line_genref = INDENT allsubs_attrs SP '->' (WRAP / SP) target_attrs EOL* // Abbreviated in a single line
...
allsubs_attrs = '<subclass>' attr_set // Abbreviation for same attrs from all subclasses in a generalization
The name of the superclass is at the top followed by a space and a + symbol.
The subclass names are double indented underneath in no particular order.
The formalization can appear in either single line (most common) or as multiple lines depending on whether or not all of the subclass referential attributes share the same naming scheme. The example exhibits the most common case where all subclasses conveniently use the same naming scheme.
Start with the <subclass> keyword followed by .. This tells us that the referential attributes in each subclass
are named identically. You can verify this by looking at the R38 diagram snippet. Then supply the referring attributes
that match all of the subclasses as if you were describing a single source class.
The right hand side of the -> keyword refers to an identifier of the superclass, and in this case there is only
one identifier consisting of two referenced attributes.
There are situations where the model is more meaningful with different naming in each subclass. In that case just use the same approach for binary reference formalization with a separate line per subclass. In fact, the single line formalization is really just a convenient shorthand for that.
If we did that in this example, renaming the Floor attribute in each subclass, we could have done this:
R38
Bank Level +
Top Bank Level
Middle Bank Level
Bottom Bank Level
Bottom Bank Level.(Bank, Bottom floor) -> Bank Level.(Bank, Floor)
Middle Bank Level.(Bank, Middle floor) -> Bank Level.(Bank, Floor)
Top Bank Level.(Bank, Top floor) -> Bank Level.(Bank, Floor)
--
As you can see, the best plan is not to name those subclass referential attributes differently unless you've got a really good reason!
Copyright 2023-2026 © Leon Starr under MIT Open Source License