Guidelines to Adopt when Developing Abstract Data Types for Reuse
This guidelines give you some hints as to what facilities should be provided by abstract data types developed for reuse.
- An operation should be included to create and initialize instances of the abstract data type.
- For each attribute of the abstract type, access and constructor functions should be provided. Access functions return attribute values; constructor functions allow attribute values to be changed.
- Operations to print instances of the type and to read and write instances to and from filestore should be provided.
- Assignment and equality operations should be provided.
- For every possible exception condition which might occur in type operations, a test function should be provided which allows that condition to be checked for before initiating the operation.
- If the abstract type is a composite type, operations to add objects to and to delete objects from the collection should be provided. If the object is ordered, multiple add and delete functions should be provided. For example, for a list type, operations should be available to add and to delete an element to and from the front and the end of the list.
- If the abstract type is a composite type, functions to provide information about attributes of the composition (such as size) should be provided.
- If the abstract type is a composite type, an iterator should be provided which allows each element of the type to be visited.
- Wherever possible, abstract types should be parameterized using generic types.
Sommerville, I.: Software Engineering. 3rd Edition, Addison-Wesley Publishing Company, Workingham/England, 1990.