mhinze.com

Matt Hinze, learning in public

Archive for the ‘Domain-Driven Design’ Category

Aggregated specifications

An example from my inversion of control talk involves a message formatter.  It applies formatting rules to a string.
public interface IMessageFomatter
{
string Format(string message);
}

Instead of doing all the work in the implementation of this interface, the message formatter will aggregate several distinct rules.  An inversion of control tool is configured to [...]

More On Value Objects

A few days ago Dylan Beattie wrote a nice post about value objects.  He explains the idea in a more palatable way than my attempt:
If it’s not clear how to model a particular element in your model, try asking “which one?” If the question makes sense within your own scenario then you’re probably dealing with [...]

Adding to a Value Object property always adds to it, never adds another instance to it.  Distinguishing Value Objects by maintaining a collection of them implies identity.
It is a mistake to attempt to maintain a collection of Value Objects.
Let’s take the near-canonical Address, a perfectly valid Value Object as described on page 98 of [...]