Docsity

Data Abstraction and Encapsulation in Programming: Understanding the Basics, Exams of Mathematics

Partial preview of the text

Download Data Abstraction and Encapsulation in Programming: Understanding the Basics and more Exams Mathematics in PDF only on Docsity!

Presented By- KAPIL SHARMA (15CE024) JATIN GANDHI (15CE021) MADHUR SUDAN (15CE028)

 Computer hardware cannot differentiate between a bit string representing an integer, character or real number. Higher language provide a set of basic data types , such as integer , real and character string.  Type Checking is provided to ensure that the operations receives proper number of arguments of proper data types.  A type definition defines the structure of a data objects with its possible value bindings  User defined types provide improved readability

DATA ABSTRACTION

 The importance of abstraction is

derived from its ability to hide

irrelevant details.

 This allows user to use an object

with minimum information.

 It is a weapon against complexity.

 An abstract data type(ADT), is an encapsulation that indicates only the data representation of one specific data types and subprograms that provide the operations for that type.  An abstract data type is defined as a mathematical model of the data objects that make up a data type as well as the functions that operate on these objects.

code using an ADT object may only refer to properties and abilities specified in the interface, changes may be made to the implementation without requiring any changes in code.  Flexibility This gives a great deal of flexibility when using ADT objects in different situations. For example, different implementations of the ADT may be more efficient in different situations; it is possible to use each in the situation where they are preferable, thus increasing overall efficiency.

 The technique of hiding the used data structure and only provide a well- defined interface is known as Encapsulation.  The wrapping up of data and functions into a single unit is known as Encapsulation.  Through encapsulation the data is not accidently corrupted by external world.  The access specifiers defined the accessing of data and member functions.

Benefits of Encapsulation Encapsulation is a very important O-O concept Each object has 2 views. An internal view and an external view Encapsulation is a form of protection Also called Information Hiding The outside world does not have direct access to the internal implementation or representation of an object

As long as the external view does

not change, the internal view can

take on any form without affecting

the outside world

By hiding data and providing

methods to gain access to it, an

object can maintain high data

integrity

Methods have the responsibility of

maintaining data integrity

private visibility offers full

encapsulation

 The hiding of design decisions in a computer program that are most likely to change , thus protecting other parts of the program from change if the decision is changed.  In object oriented programming, access to the private part of object is restricted in the sense that the functions of the object can only access the data. Thus, private parts of the objects are not available outside the object and cannot be altered by external changes. This property of object is called as Information Hiding or Data Hiding.