The port through which the domain obtains a new identity.
Making an id is not an aggregate's job, any more than opening a database
connection is. The domain asks for one and never decides how it is made:
a use case that creates an aggregate is handed a generator and passes the
result into the factory, Place.register(ids.next(), props).
The implementation lives outside the domain, in an adapter. One adapter
wraps crypto.randomUUID(); another counts up from one, for tests that
want to predict an id rather than parse whatever a library produced; a
third could hand out ids pre-allocated by a client, or minted by the store.
Switching between them changes nothing in the domain, because nothing in
the domain ever looks inside an id.
Why "Domain" is in the name
This port produces the identities that Entity instances carry:
opaque, non-blank strings with no rule of their own. A project will often
have other id-like values — a voucher serial, an invoice number, a share
token — that do carry rules: a range, a prefix, a checksum. Those are
value objects, and whatever generates them is a different port with a
different name. Keeping "Domain" here leaves that vocabulary free.
The port through which the domain obtains a new identity.
Making an id is not an aggregate's job, any more than opening a database connection is. The domain asks for one and never decides how it is made: a use case that creates an aggregate is handed a generator and passes the result into the factory,
Place.register(ids.next(), props).The implementation lives outside the domain, in an adapter. One adapter wraps
crypto.randomUUID(); another counts up from one, for tests that want to predict an id rather than parse whatever a library produced; a third could hand out ids pre-allocated by a client, or minted by the store. Switching between them changes nothing in the domain, because nothing in the domain ever looks inside an id.Why "Domain" is in the name
This port produces the identities that Entity instances carry: opaque, non-blank strings with no rule of their own. A project will often have other id-like values — a voucher serial, an invoice number, a share token — that do carry rules: a range, a prefix, a checksum. Those are value objects, and whatever generates them is a different port with a different name. Keeping "Domain" here leaves that vocabulary free.