Abstract Data Types (ADTs)
• Abstract – existing in thought or as an idea but not having a physical or concrete existence
• Data - the quantities, characters, or symbols on which operations are performed by a computer
• Type - a category of people or things having common characteristics
• ADT – a description of data and the operations define on that data
o Ex. list, abstract understanding, different syntax btwn languages
Abstract Data Type: discussion
o The user doesn’t want to know how it works
o The user wants to know how to work it
o Ex. how are python lists implemented? In almost every situation does anyone care?
o What information to record?
o Encapsulates a concept that is common to an entire set of objects Synonyms of “encapsulate”:
encase, contain, envelop, enfold, sheathe, cocoon, surround
• ADT: data + operations on that data
o ex. Pixel (from the media)
Data: a dot with a location and an RGB colour
Operations: get_x(), get_y(), get_color(), set_color(c), etc.
o Ex. Str (a built-in type)
Data: a sequence of characters
Operations: capitalize(), isdigit(), strip(), find(sub), etc.
• ADTs in Python
o Python: you can define a new type by writing a class
Sometimes using the built-in ones like str would be too inconvenient
o Classes encapsulate data and provide methods to operate on that data
Someone wrote python classes for every type used in 108 and in 108 we never care how they did it:
we just called metho