Previous      Up      Previous     Course Home   e-mail

3.2 Example: ADT Interface

Example: ADT Interface   

Topic of interest: Developing the ADT interface for a Book.

Analysis:   

The developer looks at the above diagram and notes that each book can have multiple authors, so the interface must provide some way to access an unknown number of author objects.

Design:   

The developer suggests using an iterator for this purpose, knowing this to be a common idiom in C++ for accessing an unknown number of "contained" objects.

Implementation:   

The developer adds the lines


typedef ... AuthorIterator ;
and

AuthorIterator begin () const ;
AuthorIterator end () const ;
to the class declaration for Book.

Validation:   

The developer looks at some of the proposed algorithms that will work with books and authors, checking to see if those algorithms could be coded using an iterator style.

Satisfied that it will do so, the developer distributes the new class declaration to the rest of the development team for their approval.

 Previous      Up      Previous     Course Home   e-mail