11+-+Abstract+Data+Types

11+-+Abstract+Data+Types - 10/11/2009 Remembering Back...

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) EECS 280 Programming and Introductory Data Structures 1 Remembering Back Types c Recall the role of a type: c The set of values that can be represented by items of the type c The set of operations that can be performed on items of the type. c So far, we've discussed a variety of data types, and all of them have one thing in common: c Every detail of a type is known to all consumers of that type. c This is sometimes called the "concrete implementation". 2 Remembering Back Types c For example, consider the struct Game from project 3. c Every function knows the details of exactly how games are represented. c A change to the game definition (for example, a more efficient encoding) requires that we recompile everything, and possibly make changes throughout the program. c Contrast this with the functions that we've written. c A function is given a specification which documents what the function does, but not how it does it. 3 Abstract Data Types Introduction c A function is given a specification which documents what the function does, but not how it does it. c 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. c This is a good thing, but so far, we can’t do that for types… c To solve this problem, we'll define abstract data types, or ADTs. c An ADT provides an abstract description of values and operations. c The definition of an ADT must combine both some notion of what the values of that type represent, and how they behave . c However, we can leave off the details of how this actually happens . 4 Abstract Data Types Introduction c 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 . 2. Encapsulation : the objects and their operations are defined in the same place; the ADT combines both data and operation in one entity. 5 Abstract Data Types Introduction c Abstract data types have several benefits like we had with functional abstraction: c ADTs are local : you only need to look at the ADT, and nothing else, to understand it. c ADTs are substitutable : you can change the implementation and no users of the type can tell. c 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”. c However, only the operations defined for that type should have access to the representation. c Everyone else may access/modify this state only through member functions. 6
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/2010 for the course EECS 280 taught by Professor Noble during the Fall '08 term at University of Michigan.

Page1 / 9

11+-+Abstract+Data+Types - 10/11/2009 Remembering Back...

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