Receiving Helpdesk

what is information hiding in oop

by Isabell Donnelly Published 3 years ago Updated 2 years ago

Information hiding concept restricts direct exposure of data. Data is accessed indirectly using safe mechanism, methods in case of programming object. Taking bike as an example, we have no access to the piston directly, we can use 'start button' to run the piston.

What is the difference between OOP and information hiding?

When referring to OOP, we use the term abstraction rather than information hiding. Abstraction relates to the way in which it is not necessary to know the underlying storage mechanism of a class, nor its implementation details, in order to make use of a class.

What is information hiding in programming?

Information hiding is the process of hiding the details of an object or function. The hiding of these details results in an abstraction, which reduces the external complexity and makes the object or function easier to use. Encapsulation is a common technique programmers use to implement information hiding.

Which technique is used to implement information hiding?

Encapsulation is a common technique programmers use to implement information hiding. Furthermore, which leads to information hiding? Encapsulation is a powerful feature that leads to information hiding and abstract data type. They encapsulate all the essential properties of the object that are to be created.

Who first described the concept of information hiding?

The concept of information hiding was first described by David Parnas in Parnas (1972).

Real World Example

Encapsulation and information hiding are actually all around us. Take for example, a soda vending machine. There are many internal parts to the machine. However, as a user, we care little about how the machine works or what it does inside.

Private and Public

To implement information hiding in our classes, we use visibility. In general, attributes and methods can either be public or private. If we want and attribute or method to be part of the class interface, we define them as public. If we want to hide a attribute or method from external objects, we defined them as private.

Best Practices

To implement information hiding, we recommend that you declare all attributes of a class as private. Any attribute whose value should be able to be read or changed by an external object should create special “getter” and “setter” methods that access those private variables.

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9