3 ms·
IMO the arrows point to the right direction, in a sense that in my mental model arrows are typically owned by the pointer, not the pointee. The pointees are typ
by planede 4y ago
IMO the arrows point to the right direction, in a sense that in my mental model arrows are typically owned by the pointer, not the pointee. The pointees are typically unaware of what points to them. A base class "doesn't know" what its derived classes are. Likewise a git commit doesn't know it's descendants either.
So in my mental model a derived class actively "points to" its base class. Likewise a child commit points to its parent/parents.
- masklinn 4y ago> A base class "doesn't know" what its derived classes are. There's a high variability in that, especially when metaclasses get involved and inheritance is itself a protocol (and thus can be hooked into every which way). I do agree with the rest of your comment though, to me it also makes a lot more sense for a derived class to point to its parent than the reverse.
- arethuza 4y ago"derived class actively "points to" its base class" That make sense - pretty much every language I've used that supports inheritance class definitions refer to the class (or classes) they extend rather than the other way about.
- Ensorceled 4y agoI like it ... class Vehicle extendedBy Car, Truck class Car class Truck extendedBy Semi class Semi This would be almost as awesome as "comefrom"[1] [1] https://en.wikipedia.org/wiki/COMEFROM https://en.wikipedia.org/wiki/COMEFROM
- fhars 4y agoLooks like sealed classes in Java https://www.baeldung.com/java-sealed-classes-interfaces https://www.baeldung.com/java-sealed-classes-interfaces
- zozbot234 4y agoYou could use a generic Vehicle<T: VehicleType>, with Vehicle<Car>, Vehicle<Truck>, Vehicle<Semi> implementing specialized interfaces.
- deleted 4y ago[deleted]