3 ms·
What the article describes as the true meaning of "abstraction" is very close to (if not the same) as "interface contract", and it’s correct that the important
by layer8 5y ago
What the article describes as the true meaning of "abstraction" is very close to (if not the same) as "interface contract", and it’s correct that the important quality is to enable precise reasoning (of which “abstract interpretation” is one possible form) about the program behavior along that abstraction/interface boundary. Functions have an interface contract, classes have an interface contract, data types have an interface contract, things like REST APIs have an interface contract, and so on.
The fact that some languages, as mentioned in the article, have a language feature called “interface” is somewhat unfortunate, because it makes unclear when someone says “interface” whether they refer to the language feature or to the more general meaning. (For example, every Java class has an interface-in-the-general-sense, just like every class has an implementation, regardless of whether the class happens to implement an interface-the-language-feature or not.) Prior to that, it was always understood that “interface” implies a certain contract, usually one that imposes conditions beyond the mere type signature of the respective entity.
Incidentally, that’s also one benefit of nominal typing (as opposed to structural typing), because it expresses the fact that the interface is usually more than its type signature, and therefore two entities having compatible type signatures are not necessarily compatible in terms of their interface contract, and thus shouldn’t be implicitly convertible/assignable to each other.