| 6.170 | Laboratory in Software Engineering
Spring 2000 Amendments to Problem Set 3 Due: February 24, 2000 Handout 9 |
| This is an important issue: exposing the representation is not just something that happens when you write the spec (though that is a place where it can occur). Giving the user the ability to alter the internal structure of your object without using the mutator operations that you provide is also considered exposing the representation. Please note that the default JDK-style Iterator provides a remove() operation that actually changes the state of the data structure that the Iterator is traversing. The Iterator abstraction used in 6.170 does not provide this operation (thus it is not mentioned in the text). This is why we have given you the UnmodifiableIterator class to use in your implementations: by extending the class and using the default implementation of remove() that UnmodifiableIterator provides, you can ensure that the Iterator you are making does not allow access to the underlying state. |