The Three Benefits of Access Protection

Access protection has three main benefits:

  1. It allows you to enforce constraints on an object's state.
  2. It provides a simpler client interface. Client programmers don't need to know everything that's in the class, only the public parts.
  3. It separates interface from implementation, allowing them to vary independently. For instance consider making the licensePlate field of Car an instance of a new LicensePlate class instead of a String.

Previous | Next | Top | Cafe au Lait

Copyright 1997-1998 Elliotte Rusty Harold
Last Modified October 16, 1998