Information Hiding:
Abstraction and Information Hiding are inter-related to one another. Abstraction Hiding only the necessary details from the end user,
Example: » consider a school administration, here the privilege of principle and the student in accessing a webpage/database entirely differs. Here they have various levels of abstractions.
while Information Hiding hide the implementation details for security purpose.
Example: » Consider our ATM. All we know is withdrawing the amount. but how it actually works. and how transaction occurs are totally hidden.
Information Hiding is one of the most important principles of OOP Inspired from real life which says that all information should not be accessible to all persons. Private Information should only be accessible to its owner.
“
By Information Hiding we mean "Showing only those details to the outside world which are Necessary for the outside world and hiding all other details from the outside world".
In Object Oriented Programming approach we have objects with their attributes and behaviors that are hidden from other classes, so we can say that object oriented programming follows the principle of information hiding.
Information Hiding first came to public attention in a paper Published by David Parnas in 1972 called "On the Criteria to be Used in Decomposing Systems into Modules." Information hiding is characterized by the idea of Secrets , Design and Implementation decisions that a software developer hides in one place from the rest of a program.
“
Information Hiding is a Particularly Powerful heuristic for Software's Primary Technical Imperative because, beginning with its name and throughout its details, it emphasizes hiding complexity.
Class Designing Strategy:
One Key task in designing a class is deciding which features should be known outside the class and which should remain Secret. A Class Might use 25 routines and expose only 5 of them, using the other 20 Internally, A Class might use several data types and expose no information about them. This aspect of class design is also known as Visibility since it has to do with which features of the class are "visible" or "Exposed" outside the class.
The Interface to a class should reveal as little as possible about its inner workings. As shown in Figure below.
A Class is a lot like an iceberg: Seven-eights is under water, and we can see only one-eighth that's above the surface.
Designing the class interface is an iterative process just like any other aspect of design. if we don't get the interface right the first time, try a few more times until it stabilizes. if it doesn't stabilize, we need to try a different approach.
“
Information Hiding is useful at all levels of design, from the use of named constants instead of literals, to creation of data types, to class design, routine design, and sub system design.