ADTs - Abstract data types What does abstract` mean? From...

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

View Full Document Right Arrow Icon
Abstract data types What does ‘abstract’ mean? From Latin: to ‘pull out’—the essentials To defer or hide the details Abstraction emphasizes essentials and defers the details, making engineering artifacts easier to use I don’t need a mechanic’s understanding of what’s under a car’s hood in order to drive it What’s the car’s interface? What’s the implementation?
Background image of page 1

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

View Full DocumentRight Arrow Icon
Floating point numbers You don't need to know how much about floating point arithmetic works to use float Indeed, the details can vary depending on processor, even virtual coprocessor But the compiler hides all the details from you-- some numeric ADTs are built-in All you need to know is the syntax and meaning of operators, +, -, *, /, etc. Hiding the details of implementation is called encapsulation ( data hiding ) See multimedia: ADT for digits (properties)
Background image of page 2
ADT = properties + operations An ADT describes a set of objects sharing the same properties and behaviors The properties of an ADT are its data (representing the internal state of each object double d; -- bits representing exponent & mantissa are its data or state The behaviors of an ADT are its operations or functions (operations on each instance) sqrt(d) / 2; //operators & functions are its behaviors Thus, an ADT couples its data and operations OOP emphasizes data abstraction
Background image of page 3

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

View Full DocumentRight Arrow Icon
Formal, language-independent ADTs An ADT is a formal description, not code; independent of any programming language Why is code independence a good idea? Promotes design by contract : Specify responsibilities of suppliers and clients explicitly, so they can be enforced, if necessary
Background image of page 4
Generic Queue ADT An ADT specification has six parts The first three dealing with syntax… NAME, SETS and SIGNATURES NAME Queue<I> SETS I set of all items (generic type)
Background image of page 5

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

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

Page1 / 15

ADTs - Abstract data types What does abstract` mean? From...

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

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