- Representation Independence means ensuring that
the use of an abstract type is independent of its
representation.
- Changes in the representation should have no effect on the
code outside the abstract type.
Vector v = new Vector();
List l = new List ();
....
v.copyInto (l.elementData);
- This works as long as the List representation does not change.
class List {
public Entry getEntry (int i);
}
Entry e = l.getEntry (i);
e.element = x;
...
e.element = y;
- This is also bad because if the represenation changes
there might no longer be Entry objects.
- The List class should only use Objects.