Growing Object-Oriented Software, Guided by Tests (Addison-Wesley Signature Series (Beck))
amazon.com
Growing Object-Oriented Software, Guided by Tests (Addison-Wesley Signature Series (Beck))
Our response is to organize the code into two layers: an implementation layer which is the graph of objects, its behavior is the combined result of how its objects respond to events; and, a declarative layer which builds up the objects in the implementation layer, using small “sugar” methods and syntax to describe the purpose of each fragment. The
... See moreAs John Gall wrote in [Gall03], “A complex system that works is invariably found to have evolved from a simple system that works.”
When we want to mark a new domain concept in the code, we often introduce a placeholder type that wraps a single field, or maybe has no fields at all. As the code grows, we fill in more detail in the new type by adding fields and methods. With each type that we add, we’re raising the level of abstraction of the code.
When we notice that a group of values are always used together, we take that as a suggestion that there’s a missing construct.
Break up an object if it becomes too large to test easily, or if its test failures become difficult to interpret. Then unit-test the new parts separately.
Our purpose, in the end, is to achieve more with less code. We aspire to raise ourselves from programming in terms of control flow and data manipulation, to composing programs from smaller programs—where objects form the smallest unit of behavior.
Loosely speaking, we use the message-passing style we’ve just described between objects, but we tend to use a more functional style within an object, building up behavior from methods and values that have no side effects.
Driving an interface from its client avoids leaking excess information about its implementers, which minimizes any implicit coupling between objects
We try to think about objects in terms of roles, responsibilities, and collaborators, as best described by Wirfs-Brock and McKean in [Wirfs-Brock03]. An object is an implementation of one or more roles; a role is a set of related responsibilities; and a responsibility is an obligation to perform a task or know information. A collaboration is an int
... See more