Chapter 9. Adjusting Visibility

The ideals of object-oriented encapsulation generally steer us toward limiting the visibility of methods and attributes to the greatest extent possible and still satisfying the functional needs of the software. In general, this guidance is good. It lets us essentially virtualize our data elements so that all manipulation of those elements meets uniform expectations. Our most public methods represent the intrinsic behaviors that the outside world associates with the object being modeled. All other methods have lesser visibility motivated by their design purpose. Some methods are only visible to other classes—such as derived classes—of the same type. Different languages have additional variations in access levels. ...

Get Quality Code: Software Testing Principles, Practices, and Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.