An invoice states what a customer owes for services. It begins open when issued and becomes closed when paid, with an invoice date and a due date shaped by payment terms. section 5.1.1
Several details make the apparently simple model more consequential:
- Past-due status depends on the customer's rating: good customers receive a longer grace period, while others incur fees sooner. section 5.1.1
- Invoice numbers belong to a centralized billing service, which allocates the number and delivers the real invoice; the local service acts as an intermediary. section 5.1.1
- A record such as PastDue(Invoice invoice) can wrap what is known about an invoice without pretending that the underlying Invoice is immutable. section 5.4.1
This boundary makes the domain meaning explicit while containing legacy mutability. Data orientation complements object-oriented design here: clarity matters more than enforcing immutable-data purity, and the boundary can be redrawn later. section 5.4.1
Listing 5.21 Creating the PastDue type
record PastDue(Invoice invoice){} #AA compact Java record shows how PastDue can quarantine an Invoice's mutable identity behind a named domain type. section 5.4.1
