Saturday, September 19, 2009

Abstract Data Types

Data abstraction is important because:
  • It allows uns to create data types not otherwise available in a programming language
  • It allows us to produce off-the-shelf-software, pieces of software that can be used over and over again in different programs by any programmer
The primary tool for practicing data abstraction is the abstract data type(ADT), a new data type that is not built into the programming language, concentrating only on its logical properties and deferring the details of its implementation.

An abstract data type has both a specification (the what) and an implementation (the how) 

Properties of abstract data types
  • Attributes
    • Java: fields
    • C++: data members or member variables

  • Oprations
    • Java: methods
    • C++: member functions
Interaction with (usage of) an abstract data type is made through its interface or public interface
  • Public attributes
  • Public operations
TIP: public interface should be built around public operations. 

Example of informal specification

TYPE
    IntList
DOMAIN
    Each IntList value is a collection of up to 100 separate integer numbers
OPERATIONS
    Insert an item into the list
    Delete an item from the list
    Return the current length of the list
    Print the list

Notice the complete absense of implementation details


Reference: wikipedia, google books, thefreedictionary



 

2 comments:

Maroof said...

Nice blog eamon. started reading. but it will be more helpful if could avoid bookish words like interface (because it is a keyword in java or other languages), or at least give a general description. Also please try to give codes as example. :P

eamon said...

Thanks Maroof. I will remember your suggestion and will try to give codes as example.

Post a Comment