Home Segments Top Top Previous Next

274: Mainline

Some benefits of data abstraction disappear if you write methods that include direct instance-variable accesses or assignments.

If, for example, you decide to switch from a minutes-based definition to an hours-based definition, then Java no longer can compile any expression that attempts to access the minutes instance variable directly. On the other hand, if you prevent direct access to the minutes instance variable, no one can accidentally come to rely on expressions that include such access.