An abstract data type, or ADT, specifies a set of operations (or methods)
and the semantics of the operations (what they do), but it does not not specify
the implementation of the operations.
Common ADTs:list, dictionary, stack……(from slices)
Reading from a paragraph about Stack(useful information)
&
Design(class)
&
Implementation(init, push, pop, is_empty)
&
Test(if __name__ == '__main__')
e.g.
class Stack:
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def is_empty(self):
return (self.items == [])
The first lab we just be on time but lack of time check the correctness,
anyway, the cooperation was pleasant :)
25.9. Glossary
(again, for my own convenience:) )
- abstract data type (ADT)
- A data type (usually a collection of objects) that is defined by a set
of operations but that can be implemented in a variety of ways.
- client
- A program (or the person who wrote it) that uses an ADT.
- delimiter
- A character that is used to separate tokens, such as punctuation in a
natural language.
- generic data structure
- A kind of data structure that can contain data of any type.
- implementation
- Code that satisfies the syntactic and semantic requirements of an
interface.
- interface
- The set of operations that define an ADT.
- infix
- A way of writing mathematical expressions with the operators between
the operands.
- parse
- To read a string of characters or tokens and analyze its grammatical
structure.
- postfix
- A way of writing mathematical expressions with the operators after the
operands.
- provider
- The code (or the person who wrote it) that implements an ADT.
- token
- A set of characters that are treated as a unit for purposes of parsing,
such as the words in a natural language.
- veneer
- A class definition that implements an ADT with method definitions that
are invocations of other methods, sometimes with simple
transformations. The veneer does no significant work, but it improves
or standardizes the interface seen by the client.
Code Like a Pythonista: Idiomatic Python:
http://python.net/~goodger/projects/pycon/2007/idiomatic/presentation.html
No comments:
Post a Comment