Tamilnadu Samacheer Kalvi 12th Computer Science Notes Chapter 2 Data Abstraction Notes
Data abstraction is a powerful concept in computer science that allows programmers to treat code as objects.
- Abstraction provides modularity (modularity means splitting a program into many modules). Classes (structures) are the representation for “Abstract Data Types”, (ADT).
- Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of value and a set of operations.
- The definition of ADT only mentions what operations are to be performed but not how these operations will be implemented.
- The process of providing only the essentials and hiding the details is known as abstraction.
Constructors and Selectors:
- To facilitate data abstraction, we need to create two types of functions: constructors and selectors.
- Constructors are functions that build the abstract data type.
- Selectors are functions that retrieve information from the data type.
- The basic idea of data abstraction is to structure programs so that they operate on abstract data.
- A concrete data representation is defined as an independent part of the program.
Two parts of a program:
The two parts of a program are, the part that operates on abstract data and the part that defines a concrete representation.
Concrete data type Vs Abstract data type :
- A concrete data type is a data type whose representation is known
- In abstract data type the representation of a data type is unknown
Tuple & List:
To enable us to implement the concrete level of our data abstraction, some languages like Python provides a compound structure called Pair which is made up of list or Tuple.
- List is constructed by placing expressions within square brackets separated by commas.
- Example: List := [10,20]
- A tuple is a comma-separated sequence of values surrounded with parentheses.
- Example: colour= (‘red’, ‘blue’, ‘Green’)
Difference between List & Tuple :
In a list, elements can be changed.