Whenever we have a business concept that has data but no identity, we often choose to represent it using the Value Object pattern. A value object is any domain object that is uniquely identified by the data it holds; we usually make them immutable: OrderLine is a value object @dataclass( frozen = True) class OrderLine: orderid: OrderReference sku: ProductReference qty: Quantity One of the nice things that dataclasses (or namedtuples) give us is value equality, which is the fancy way of saying, “Two lines with the same orderid, sku, and qty are equal.”580 ↱
Architecture Patterns with Python
Enabling Test-Driven Development, Domain-Driven Design, and Event-Driven Microservices
Harry Percival, Bob Gregory