added working design doc on attribute ordering wrt inheritance

This commit is contained in:
Steve Ebersole 2020-01-12 23:03:12 -06:00
parent a9ee082128
commit ccfa8101c1
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
= Attributes (and inheritance)
[source]
----
class Customer {
Integer id;
String name;
Address address;
int quota;
}
class DomesticCustomer extends Customer {
String taxId;
String attr1;
String attr2;
}
class ForeignCustomer extends Customer {
String vat;
String attr3;
String attr4;
}
----
The general idea is that the attributes are ordered alphabetically, super attributes first. Subtypes are sorted
depth-first and the attributes are sorted alphabetically within each sub-type. So the order of the attributes
depends on where we start.
Starting from Customer we have: `[address, name, quota, attr1, attr2, taxId, attr3, attr4, vat]`
Starting from DomesticCustomer we have: `[address, name, quota, attr1, attr2]`
Starting from ForeignCustomer we have: `[address, name, quota, attr3, attr4, vat]`
This is why we cannot really have the position be an inherent part of the attribute itself - it changes depending on
where we start.