Abstract Data Types (Adts)

Abstract Data Types (Adts)

Abstract Data Types (ADTs)

[abstract data types] [Hello. This is Rachel Cardell-Oliver from the University of Western Australia]

This video outlines what an abstract data type is and what it is for.

Abstract Data Types allow the user to abstract away from implementation detail.

Consider the statement: I put my lunch in my bag and went to work. What is meant by the term bag in this context? Most likely it is a backpack, or satchel, but it could also be a hand bag, shopping bag, sleeping bag, body bag . . . (but probably not a bean bag).

It doesn’t actually matter. To understand this statement, we simply need to understand that a bag is something that we can:

1. put things in,

2. carry places, and

3. take things out.

Such a specification is an Abstract Data Type.

Object-oriented programming is based around the concept of abstract data types. Java is an object-oriented programming language and Java classes are ideal for implementing ADTs.

ADTs require:

- Some references (variables) for holding the data. These are usually hidden from the user. and

- Some operations that can be performed on the data. These must be available to the user. [example code]

Let's look at an example: a Matrix Class A class in Java has the general structure ...

class declaration then variable declarations defining the data held then method declarations defining the operations on the data There are many reasons to use ADTs for designing programs.

ADTs support information hiding.

Variables can be made private, meaning there is no access to the variables by users of a class.

Methods can be made public. This is used to create and manipulate data structures.

This style of encapsulation is a good programming practice because we can change

the way the data is stored and the way the methods are implemented without changing the (external) functionality.

ADTs provide modularity which supports independent development, re-use, porting, maintaining, and upgrading software. You can delay decisions about the final implementation while you are still developing an application. It separates the concerns of an application from that of data structure design. Information hiding encapsulation ensures access through a well-defined interface. Information hiding is a key technique for avoiding bugs (that is, errors) in software.

In object oriented languages, such as Java, ADTs also provide other benefits such as:

- polymorphism where the same operation can be applied to different types, and

- inheritance where subclasses adopt from parent classes. We will see these features in more detail later in the course.

Abstract Data Types are a useful tool. I hope you will enjoy learning more about them.

[ Presentation by Rachel Cardell-Oliver based on DSA lecture notes from the University of Western Australia ]