Encapsulation, Observability, and Testability

All in all, conventional guidance about object-oriented encapsulation creates a tension between good design and testability. The testability of a class directly relates to your ability to verify its state, hidden behind getters and setters, and its behavior, hidden in restricted methods.

In an ideal world, our programming languages would support testability needs. Increasingly, frameworks make provisions for testability and tools leverage language features to increase our ability to test. In the meantime, our job is to find a balance between the rules of good design and the need for verification.

This book advocates using language and tool features where possible to test our code. Where standard language features are unavailable, we will examine the ways in which you might relax design constraints with the least violation of the spirit and purpose of encapsulation.

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

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