data abstraction n.
Skip this Video
Loading SlideShow in 5 Seconds..
Data Abstraction PowerPoint Presentation
Download Presentation
Data Abstraction

Loading in 2 Seconds...

play fullscreen
1 / 18

Data Abstraction - PowerPoint PPT Presentation

  • Uploaded on

Data Abstraction. Chapter 9. Outline. Concept of abstraction Abstract data types with example Encapsulation with example. The Concept of Abstraction. Say what a program does without necessarily saying how it does it

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Data Abstraction' - ellie

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
  • Concept of abstraction
  • Abstract data types with example
  • Encapsulation with example
the concept of abstraction
The Concept of Abstraction
  • Say what a program does without necessarily saying how it does it
  • A process of generalization, removing restrictions, eliminating detail, removing inessential information etc
  • “more potential implementations” – moving to a lower level mans restricting the number of potential implementations
data types
Data types
  • A data type is characterized by:
    • a set of values
    • a data representation, which is common to all these values, and
    • a set of operations, which can be applied uniformly to all these values
abstract data types adts
Abstract Data Types (ADTs)
  • C is not object-oriented, but we can still manage to inject some object-oriented principles into the design of C code.
  • For example, a data structure and its operations can be packaged together into an entity called an ADT.
  • The lower-level implementation details of the data structure are hidden from view of the rest of the program.
  • The implementation details can be changed without altering the ADT interface.
abstract data types adts1
Abstract Data Types (ADTs)

Data abstraction + operation abstraction

  • An abstract data type consists of:
    • Data structure: stores information to represent a certain concept
    • Functionality: set of operations that can be applied to the data type
adt example
ADT : Example
  • As an example the description of the ADT Integer is presented. Let k be an integer expression:
  • ADT Integer is
    • DataA sequence of digits optionally prefixed by a plus or minus sign. We refer to this signed whole number as N.
    • Operations
      • constructor Creates a new integer.
      • add(k) Creates a new integer which is the sum of N and k. Consequently, the postcondition of this operation is sum = N+k. Don't confuse this with assign statements as used in programming languages! It is rather a mathematical equation which yields ``true'' for each value sum, N and k after add has been performed.
      • sub(k) Similar to add, this operation creates a new integer of the difference of both integer values. Therefore the postcondition for this operation is sum = N-k.
      • set(k) Set N to k. The postcondition for this operation is N = k.
  • ...end
properties of abstract data types
Properties of Abstract Data Types
  • The entities define the data structure of a set of items. For example, each administered employee has a name, date of birth and social number.
  • The data structure can only be accessed with defined operations. This set of operations is called interface and is exported by the entity. An entity with the properties just described is called an abstract data type (ADT).
properties of abstract data types con t
Properties of Abstract Data Types (con’t)
  • Figure below shows an ADT which consists of an abstract data structure and operations. Only the operations are viewable from the outside and define the interface. Separate the use of a data structure from the details of its implementation. This is the principle underlying the use of abstract data types.

Here are some examples:

  • stack: operations are "push an item onto the stack", "pop an item from the stack", "ask if the stack is empty"; implementation may be as array or linked list or whatever.
  • queue: operations are "add to the end of the queue", "delete from the beginning of the queue", "ask if the queue is empty"; implementation may be as array or linked list or heap.
  • search structure: operations are "insert an item", "ask if an item is in the structure", and "delete an item"; implementation may be as array, linked list, tree, hash table, ...
implementing an adt
Implementing an ADT
  • To implement an ADT, you need to choose:
    • a data representation that
      • must be able to represent all possible values of the ADT
      • should be private
    • a set of methods that support normal use of the ADT
      • The user must be able to create, possibly modify, and examine the values of the ADT
    • an algorithm for each of the possible operations that
      • must be consistent with the chosen representation
      • all auxiliary (helper) operations that are not in the contract should be private
abstract data types benefits
Abstract Data Types: Benefits
  • Domain concepts are reflected in the code
  • Encapsulation: internal complexity, data and operation details are hidden
  • Specification vs. implementation: usage of data type is independent from its internal implementation
  • Higher modularity
  • Increase ease of maintenance and reuse of code
  • Focus on the external behavior of something and ignores the internal details of how the behavior is produced
  • Different part of the software to be effectively isolated in operation
  • Any component has one or more simple, well-defined external interfaces (defined in a standard)
encapsulation object example
Encapsulation : Object example

Optical and wired

Wheeled and wireless

Optical and wireless

  • Abstraction Data Types
    • Data
    • Operations
  • Benefits of using ADT
  • Encapsulation
    • Implementation in C language
    • Objects
    • Advantages