4 ms·
> The purpose of abstraction is to hide implementation detail Technically, that's encapsulation, though the sentiment is close, I think. I rather view it as a
by zdragnar 2y ago
> The purpose of abstraction is to hide implementation detail
Technically, that's encapsulation, though the sentiment is close, I think.
I rather view it as a matter of semantics. At one low level, you have operations that deal with some concrete interface or API, etc. You bundle those operations up behind an abstraction, providing methods whose names involve your application domain. Perhaps they are still at a technical level, and you bundle those up behind another abstraction, whose method names involve your business domain.
Yes, the lower level details are hidden from the higher levels, but the hiding is not the point. The point is to be able to write code that readily corresponds to the problem you are trying to solve.
- danparsonson 2y agoHmmm I prefer Wikipedia's definition: > In object-oriented programming languages, and other related fields, encapsulation refers to one of two related but distinct notions, and sometimes to the combination thereof:[5][6] > - A language mechanism for restricting direct access to some of the object's components.[7][8] > - A language construct that facilitates the bundling of data with the methods (or other functions) operating on those data The hiding is absolutely the point of abstraction, in the sense that caller can manipulate the subsystem without knowing about (important) inner details of it. As I said, graphics drivers are a great example - I just want to put a triangle on the screen, I don't want to care about the registers I have to set on an NVidia card vs those on an AMD card, or what their memory maps look like, and I don't want to have to rewrite my code when they release a new generation of hardware. Drawing a triangle is an abstraction, hiding away the details of how a specific graphics card achieves that. Think about what the word 'abstract' means - the idea of a 'human' is an abstraction for bundles of molecules conforming to a general pattern with broadly similar qualities but almost infinite variability. The word conveniently hides a wealth of detail that we usually don't need to think about; if I tell you there are three humans in a room, you can make use of that information without knowing anything about their exact physical attributes or who they are. I would refer to what you're describing as 'modelling' - these are related topics but I don't see them as the same thing.
- voiceofunreason 2y agoBerard 1993 offers a good survey of the meanings of Abstrasction, Encapsulation, and Information Hiding https://web.archive.org/web/20071214085409/http://www.itmweb.com/essay550.htm https://web.archive.org/web/20071214085409/http://www.itmweb...