A dependency is a relationship in which one software element relies on another element’s data, behavior, or availability. In a domain workflow, dependencies may be entities, databases, APIs, services, or environmental values. The design problem is not eliminating dependencies, but keeping their retrieval concerns from obscuring the work the application claims to perform. section 5.5.1
A draft builder with too many dependencies
A method named buildDraft may read the current date, call a contracts API, query a fee repository, inspect a customer database, and perform other lookups before constructing a draft. Its implementation then spends more effort managing data acquisition than building the draft itself. Separating those concerns makes the method’s domain behavior easier to read and trust. section 5.5.1
Analyze dependencies explicitly before deciding how to combine them:
- Record what each operation reads or writes, including databases, APIs, entities, environment values, and outputs from earlier operations. section 5.5.1
- Keep the application’s semantic data and core decisions distinct from the mechanisms that retrieve or submit them. section 5.5.1
- Expect dependencies to influence design: a repository may know that primary-key lookup is fast while scanning is flexible but slow. section 10.4.7
- Create wrappers deliberately when they add a semantic application boundary; avoid merely repackaging an underlying API. section 10.7
Listing 5.42 Analyzing the dependencies of our methods
collectPastDue
DependsOn:
List<Invoice> (Entity / Database (read))
CurrentDate (Environment (read))
CustomerRating (API (read))
Output:
List<PastDueInvoice>
buildDraft
DependsOn:
List<PastDue> (Output from collectPastDue)
CurrentDate (Environment (read))
PaymentTerms (API (read))
FeePercentage (Database (read))
Customer (Database (read))
Output:
Latefee<Draft>
assessDraft
DependsOn:
LateFee<Draft> (Output from buildDraft)
Rules (Database (read))
Customer (Database (read))
ApprovalStatus (API (read))
Output:
Billable
OR NeedsApproval
OR NotBillable
submitBill
DependsOn:
Billable (output from AssessDraft)
BillingService (API write)
Output:
BilledLateFee
OR RejectedLateFee
startApproval
DependsOn:
NeedsApproval (output from AssessDraft)
CustomerID (database (read))
ApprovalsService (API read/write)Maps each workflow operation to its dependencies, their read or write source, and its output, making hidden coupling visible. section 5.5.1
Integration tests expose whether real dependencies behave as the application expects. Unlike mocked unit tests, they exercise interactions with systems outside the code’s direct control, such as database guarantees and access patterns. Their difficulty comes from needing a mental model of several systems at once. section 12.1


































