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.

For all the thought that has gone into the design of access levels in languages and the use of them to implement perfectly encapsulated software, very little of that thought addresses questions of testability. This leaves us with a situation in which we need to leverage the existing language features and relax the ideal encapsulations to enhance the testability of our software. This chapter introduces several techniques for adjusting visibility to improve testability.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.254.118