Topic : Information Hiding in C# Programming Language:

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.



image: Information Hiding

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".



  • Some Real life Example of Information Hiding:

    » My Name and personal Information is stored in My Brain, no body can access this information directly. For getting this information you need to ask me about it and it will be up to myself that how much details i would like to share with you.
    » An Email Server may have account information of millions of people but it will share only my account information with me if i request it to send anyone else accounts information, my request will be refused.
    » Facebook may have millions of user accounts. Facebook is just like an Class, it have Private, Public, and Protected Members. in private, there may be inbox, some personal Photo or video. in Public, it may be some post, or user information like birthday date, where you live, etc. and in Protected there may be some post that only your friend can see, and it's hide from public.



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.



image: Information Hiding

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.

















I Tried my Best to Provide you complete Information regarding this topic in very easy and conceptual way. but still if you have any Problem to understand this topic, or do you have any Questions, Feel Free to Ask Question. i'll do my best to Provide you what you need.

Sardar Omar.
InfoBrother





WRITE FOR INFOBROTHER

Advertising






Advertisement