文档介绍:威廉勃特勒叶芝Willia
摘要
软件构造:从面向过程到面向对象
如何规约对象?--抽象!
Abstract Data Type Specification
形式?
质量?
ADT与软件开发
2022/2/26
2
Inshe relations and commonalities between object types.
How to use object types to structure programs.
14
对象刻画
Consider not a single object but a type of objects with similar properties.
Define each type of objects not by the objects’ physical representation but by their behavior: the services (FEATURES) they offer to the rest of the world.
External, not internal view: ABSTRACT DATA TYPES
15
对象刻画问题
The main issue: How to describe program objects (data structures):
Completely
Unambiguously
Without overspecifying?
(Remember information hiding)
2022/2/26
16
Institute of Computer Software
Nanjing University
A stack, concrete object
count
representation
(array_up)
capacity
representation [count] := x
free
(array_down)
1
representation
n
new
(linked)
item
item
previous
item
previous
previous
“Push” operation:
count := count + 1
representation [free] := x
“Push” operation:
free := free - 1
new (n)
:= x
“Push” operation:
:= last
head := n
17
A stack, concrete object
count
representation
(array_up)
capacity
representation [count] := x
free
(array_down)
1
representation
n
new
(linked)
item
item
previous
item
previous
previous
“Push” operation:
count := count + 1
representation [free] := x
“Push” operation:
free := free - 1
new (n)
:= x
“Push” operation:
:= last
head := n
18
抽象数据类型
一种数学的刻画方式
“类型”? -- (Data type, 简称Type)
值
操作 函数
规律 公理
2022/2/26
19
Institute of Computer Software
Nanjing University
Stack: An abstract data type
Types:
STACK [G] -- G: Formal generic parameter
Functions (Operations):
put: STACK [G] G STACK [G]
remove: STACK [G] STACK [G]
item: STACK [G] G
empty: STACK [G] BOOLEAN
new: STACK [G]
2