Reputation: 2124
I was reading an article of Leaky Abstraction Law and I read something saying
All non-trivial abstractions, to some degree, are leaky.
So what does Trivial abstraction means ?
Thank you.
Upvotes: 1
Views: 418
Reputation: 17066
The word trivial is used for its common dictionary definition. It has nothing to do with C++ (or mathematics).
Trivial
- of little value or importance.
- synonyms: unimportant, insignificant, inconsequential, minor.
In programming the word toy is often used to describe trivial applications, as in the phrase a toy program. In this case a trivial abstraction would be a toy abstraction, used for demonstration purposes only: not real or practical.
Upvotes: 2
Reputation: 6269
I have a feeling this question will get flagged as argumentative or something, but I am going to attempt an answer any way:
In the context of the article, a "leak" in the abstraction is not a memory leak, but rather, the abstraction suffering from the limitations of the underlying implementation.
The more you try to hide the underlying implementation, the less "trivial" the abstraction becomes - the more work it does.
So, it seems to me a "trivial" abstraction would be one that doesn't really do anything beyond what the underlying implementation does.
Taking the first example of the article - a trivial abstraction for IP would be some library that would let you easily build IP packets, without putting one together byte by byte your self, but would do nothing else - no retry, no protocol for verifying delivery, no packet numbering to reassemble in order like TCP does.
But in the end, since the article does not provide a clear definition, "trivial" and "non trivial" is in the eye of the beholder. You judge where the line lies, and how much an abstraction needs to add on top of the abstracted implementation before it becomes non-trivial...
By the way, this is not a C++ specific question.
Upvotes: 4