liveBook · Manning

Coupling

As explained in Data-Oriented Programming in Java

A dependency relationship in which one software component or test relies on the implementation details or behavior of another.

Coupling makes a test depend on implementation details or hidden data owned by another helper. Shared Account factories begin as convenient reuse, then let unrelated changes break many tests. section 11.4

Reduce coupling by making each test’s meaningful inputs explicit:

  • Randomize attributes a test does not constrain, preventing assertions from depending on secret helper values. section 11.4.1
  • Specialize only required attributes with overloads or Withers instead of accumulating combinations of hard-coded factory methods. section 11.4.1
  • Treat randomized values as rigorous universal coverage: assertions must hold across values the test does not constrain. section 11.4.1

Explicit test intent

A test can start with randomized data and state only its business conditions: mkAcnt().withSegment(ENTERPRISE), or mkAcnt().withRegion(region).withSpend(threshold.plus(1)).

How Data-Oriented Programming in Java covers it

How deep it goes
Explains coupling through Account factory examples, consequences, randomization, overloads, and Withers, without descending into framework internals.
Examples
Uses Account factories, enterprise segments, regions, spend thresholds, randomized attributes, and fluent Wither calls.
What you can do after
Apply randomized test data and Withers to make test assumptions explicit and prevent dependencies on hidden values.
How it connects
Connects coupling to test suites, helper functions, hard-coded data, randomized test data, overloads, and Withers.

Also explained in

Compare how 22 books explain coupling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.