Skip to content

9618 · 10.4

Introduction to Abstract Data Types (ADT)

An Abstract Data Type is like a blueprint for a data container, focusing on what it does, not how it does it. This separation makes code more organised, reusable, and easier to manage.

Need to know

What you need to know

  • An ADT is a logical description, not a physical one.
  • It focuses on the interface (operations) and behaviour.
  • It hides the implementation details from the user/client code.

Explanation

The Vending Machine of Data

  1. Define the 'What': Specify the type of data to be stored and the set of operations that can be performed on it. For example, a 'list' that can have items added and removed.
  2. Hide the 'How': The internal implementation details are concealed from the user. This principle is called information hiding.
  3. Provide an Interface: A clear set of public functions or procedures is created for the user to interact with the data, such as `AddItem()` or `RemoveItem()`.
  4. Use the ADT: The main program interacts with the data exclusively through this defined interface, making the code independent of the specific implementation.