In section
[1.1.8], we noted that a
function
used as an element in creating a more complex
function
could be regarded not only as a collection of particular operations but
also as a
functional
abstraction. That is, the details of how the
function
was implemented could be suppressed, and the particular
function
itself could be replaced by any other
function
with the same overall behavior. In other words, we could make an
abstraction that would separate the way the
function
would be used from the details of how the
function
would be implemented in terms of more primitive
functions.
The analogous notion for compound data is called
data abstraction. Data abstraction is a methodology that enables
us to isolate how a compound data object is used from the details of how it
is constructed from more primitive data objects.
[1.1.8]節で、より複雑な関数を作る要素として使われる関数は、特定の操作の集まりとしてだけでなく、関数的抽象としても見なせることを述べました。つまり、関数がどのように実装されているかの詳細は隠蔽でき、その関数自体を同じ全体的な振る舞いを持つ別の関数に置き換えることもできます。言い換えれば、関数の使い方と、それがより基本的な関数でどのように実装されるかの詳細を分離する抽象を作ることができるのです。複合データに対する同様の概念は
データ抽象と呼ばれます。データ抽象は、複合データオブジェクトがどのように使われるかを、それがより基本的なデータオブジェクトからどのように構築されるかの詳細から分離することを可能にする方法論です。
The basic idea of data abstraction is to structure the programs that are
to use compound data objects so that they operate on
abstract data.
That is, our programs should use data in such
a way as to make no assumptions about the data that are not strictly
necessary for performing the task at hand. At the same time, a
concrete
data representation is defined independent of the
programs that use the data. The interface between these two parts of our
system will be a set of
functions,
called
selectors and
constructors, that implement the abstract data in terms of the
concrete representation. To illustrate this technique, we will consider
how to design a set of
functions
for manipulating rational numbers.
データ抽象の基本的な考え方は、複合データオブジェクトを使うプログラムを、
抽象データ
に対して操作するように構造化することです。つまり、プログラムはデータについて、手元のタスクの実行に厳密に必要でない仮定を置かないようにデータを使うべきです。同時に、
具体的な
データ表現は、データを使うプログラムとは独立に定義されます。このシステムの2つの部分の間のインターフェースは、
セレクタと
コンストラクタと呼ばれる関数の集合であり、具体的な表現に基づいて抽象データを実装します。この手法を説明するために、有理数を操作する関数の集合をどのように設計するかを考えます。
2.1
Introduction to Data Abstraction
データ抽象入門