Behavioral Encapsulation

A similar set of considerations occurs with methods and subordinate objects. As the implementation of an object’s behavior grows, the size and complexity of its methods increase, leading to refactoring. This refactoring creates new methods and classes, some of which represent purely internal models of behavior within the object. The Extract Method [REF] refactoring creates restricted methods. The Extract Class [REF] refactoring creates a new representation that may not need to be seen outside of the original context.

Refactoring like this tames the size and complexity of the software. However, the very size and complexity that suggests refactoring also suggests the need for testing. We may simplify a component or unit ...

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.