Talk:Information hiding/Archive 1
|This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page.|
I think this definition of encapsulation is wrong. Encapsulation is the ability to hide the internal workings of objects, so that the other objects don't need to care about them. Usually this is achieved by simply allowing objects to contain other objects. Data hiding, when objects are actually not allowed to access internals of other objects, is something different.
- That seems very very wrong, since the normal meanings of 'hiding' are to stay out of sight so others don't notice or care, and 'capsule' is a hard object to protect things from others not allowed to contain them. By the way for novices a good way to distinguish the (correct meanings of) the two is that data hiding is an unadvertised URL, and encapsulation is putting a password on that same URL.
The important part is that encapsulation, in the way I described it, is usually considered a requirement for OO. Data hiding is not. -- Lament
- other than having the words the other way around, I would agree with you... OO says nothing about hiding information without restricting access to those who know it's there. It says a lot about restricting the access in ways that will make the component ultimately more useful.
- By this definition would Python, which doesn't have any data hiding (or as you call it, encapsulation), not be considered an OO language?
The theory of component software says much more about this though, and clears up the mess left behind by OO's often inexact conceptions.