11+-+Abstract+Data+Types - Remembering Back Types Ve 280...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Abstract Data Types (ADTs Ve 280 Programming and Introductory Data Structures Abstract Data Types (ADTs) Remembering Back Types y Recall the role of a type: y The set of values that can be represented by items of the type y The set of operations that can be performed on items of the type. y So far, we've discussed a variety of data types, and all of them have one thing in common: y Every detail of a type is known to all consumers of that type. y This is sometimes called the "concrete implementation". Remembering Back Types y For example, consider the struct Game from project 3. y Every function knows the details of exactly how games are represented. y A change to the game definition (for example, a more efficient encoding) requires that we recompile everything, and possibly make changes throughout the program. y Contrast this with the functions that we've written. y A function is given a specification which documents what the function does, but not how it does it. Abstract Data Types Introduction y A function is given a specification which documents what the function does, but not how it does it. y For example, if we find a faster way to compute factorial, we can just replace the old implementation with the new one, and no other component of the program needs to know this. y To solve this problem, we'll define abstract data types, or ADTs. y An ADT provides an abstract description of values and operations. y The definition of an ADT must combine both some notion of what values of that type represent, and how they behave. y However, we can leave off the details of how this actually happens. Abstract Data Types Introduction y Abstract data types provide the following two advantages: 1. Information hiding : we don't need to know the details of how the object is represented , nor do we need to know how the operations on those objects are implemented how the operations on those objects are . 2. Encapsulation : the objects and their operations are defined in the same place; the ADT combines both data and operation in one entity. Abstract Data Types Introduction y Abstract data types have several benefits like we had with functional abstraction: y ADTs are local: you only need to look at the ADT, and nothing else, to understand it. y ADTs are substitutable: you can change the implementation and no users of the type can tell. y Someone still needs to know the details of how the type is Someone still needs to know the details of how the type is implemented. This is referred to as the “concrete representation” or just the “representation”. y However, only the operations defined for that type should have Everyone else may access/modify this state only through member functions.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/26/2009 for the course EECS 280 taught by Professor Jeff during the Summer '09 term at University of Michigan-Dearborn.

Page1 / 9

11+-+Abstract+Data+Types - Remembering Back Types Ve 280...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online