Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

What is Information Hiding?

Sumit Rawal answered on May 17, 2023 Popularity 6/10 Helpfulness 1/10

Contents


More Related Answers


What is Information Hiding?

0

Introduction

In OOP, objects and classes are the fundamental entities. Objects are created using classes. One can observe that classes contain properties and that objects are created to manipulate and access these properties. To make this object-oriented system more reliable and error free, it is a good practice to limit access to the class members at times.

Information hiding refers to the concept of hiding the inner workings of a class and simply providing an interface through which the outside world can interact with the class without knowing what’s going on inside.

The purpose is to implement classes in such a way that the instances (objects) of these classes should not be able to cause any unauthorized access or change in the original contents of a class. One class does not need to know anything about the underlying algorithms of another class. However, the two can still communicate.

A real life example

Let’s apply this to a real-world scenario. Take the doctor-patient model. In the case of an illness, the patient consults the doctor, after which he or she is prescribed an appropriate medicine.

The patient only knows the process of going to the doctor. The logic and reasoning behind the doctor’s prescription are unknown to the patient. A patient will not understand the medical details the doctor uses to reach his/her decision on the treatment.

This is a classic example of the patient class interacting with the doctor class without knowing the inner workings of the doctor class.

1 of 5

The transaction shown above seems relatively straightforward. Data hiding is useful because it can apply the same simplicity to transactions between objects of different classes.

Components of data hiding

Data hiding can be divided into two primary components:

Encapsulation

Abstraction

This was pretty much all about information hiding and the related techniques. 

Popularity 6/10 Helpfulness 1/10 Language whatever
Source: Grepper
Tags: whatever
Link to this answer
Share Copy Link
Contributed on May 17 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.