CS201J: Engineering Software, Fall 2003
|
Notes: Tuesday 9 September 2003
Assignments Due
- 23 September (beginning of class): Problem Set 3.
Notes and Questions
Data abstraction separates what you can do with data from how it is represented.
What are the advantages and disadvantages of using abstract data types?
What are some trade-offs between arrays and linked lists?
Specifying Abstract Data Types
- Overview: what does the type represent. Should always include:
- Mutability/Immutability
- Description of an abstract notation for the data abstraction
- Operations: specifications for constructors and methods clients use described in terms of abstract notation introduced in overview. There are four different kinds of operations:
GroupUsers Specification
- Ways to create objects of the data type
- Creators: create new objects of the ADT from parameters of other types
- Producers: create new objects of the ADT from parameters of the ADT type (and other types)
- Ways to observe properties: observers
- Ways to change properties: mutators (mutable data types only)
public class GroupUsers // OVERVIEW: GroupUsers is a mutable, unbounded group of users // which provides operations to manage a group of users public GroupUsers (String [] userIDs) // EFFECTS: Initializes this to contain a group of users based // on the userIDs public void addUser (String userID) // MODIFIES: this // EFFECTS: Adds x to the elements of this: // this_post = this_pre U { userID } public boolean isIn (String userID) { // EFFECTS: Returns true iff userID is an element of this. public int size () // EFFECTS: Returns the number of elements in this.It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures.
Alan Perlis
University of Virginia Department of Computer Science CS 201J: Engineering Software |
Sponsored by the National Science Foundation |
cs201j-staff@cs.virginia.edu |