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

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

View Full Document Right Arrow Icon
10/11/2009 1 Abstract Data Types (ADTs) EECS 280 Programming and Introductory Data Structures 1 Remembering Back Types circle5 Recall the role of a type: circle5 The set of values that can be represented by items of the type circle5 The set of operations that can be performed on items of the type. circle5 So far, we've discussed a variety of data types, and all of them have one thing in common: circle5 Every detail of a type is known to all consumers of that type. circle5 This is sometimes called the "concrete implementation". 2 Remembering Back Types circle5 For example, consider the structGame from project 3. circle5 Every function knows the details of exactly how games are represented. circle5 A change to the game definition (for example, a more efficient encoding) requires that we recompile everything, and possibly make changes throughout the program. circle5 Contrast this with the functions that we've written. circle5 A function is given a specification which documents what the function does, but not how it does it. 3 Abstract Data Types Introduction circle5 A function is given a specification which documents what the function does, but not how it does it. circle5 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. circle5 This is a good thing, but so far, we can’t do that for types… circle5 To solve this problem, we'll define abstract data types, or ADTs. circle5 An ADT provides an abstract description of values and operations. circle5 The definition of an ADT must combine both some notion of what the values of that type represent, and how they behave . circle5 However, we can leave off the details of how this actually happens . 4 Abstract Data Types Introduction circle5 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 circle5 Abstract data types have several benefits like we had with functional abstraction: circle5 ADTs are local : you only need to look at the ADT, and nothing else, to understand it. circle5 ADTs are substitutable : you can change the implementation and no users of the type can tell. circle5 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”. circle5 However, only the operations defined for that type should have access to the representation.
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern