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

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

View Full Document Right Arrow Icon
5/17/2009 1 Abstract Data Types (ADTs) Ve 280 Programming and Introductory Data Structures 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 structGame 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 . 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 implemented. This is referred to as the “concrete representation” or just the “representation”. y However, only the operations defined for that type should have access to the representation. y Everyone else may access/modify this state only through member functions.
Image of page 1

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

View Full Document Right Arrow Icon
5/17/2009 2 Abstract Data Types Example y The closest example of an ADT that we've seen so far has been a list_t : y Information Hiding : In the list_t data type, you never knew the precise implementation of the list t structure list_t (except by looking in recursive.cpp ).
Image of page 2
Image of page 3
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