3 ms·
> the derived class itself (which has no way of knowing what invariants might be expected of it as part of base class code). In principle, with a sufficiently-
by dragonwriter 7y ago
> the derived class itself (which has no way of knowing what invariants might be expected of it as part of base class code).
In principle, with a sufficiently-robust type system, the invariants expected by the base class would be encoded in the typing, and the derived class would only be able to narrow them.
(Of course, OOP languages tend to either be untyped or have insufficiently robust type systems for this; robust type systems are more frequently associated with functional languages.)
- temac 7y agoIf the type system already trivially enforces your custom invariants, aren't the types defined by your classes already in it?