iesen
iesen

Reputation: 65

ddd - Creating and refactoring identity fields of Entities

We are learning DDD and evaluating its use for a system backed by a legacy system & datastore.

We have been using Anti-Corruption Layer, Bubble Context and Bounded Context without knowing about them, and this approach seems very practical to us.

But we are not certain and confident about identification methods and identity correlation. Legacy data store does not have primary keys, instead uses composite unique indexes to identify information.

We are currently creating our model as Value objects that should be Entities (wishing to add "Long id" field to every one), or we rarely use combination of attributes used in unique indexes as id field. It seems clear to us that Entity models should have id fields.

Here are my concrete questions:

and other questions :

Update:

Upvotes: 0

Views: 875

Answers (1)

Yves Reynhout
Yves Reynhout

Reputation: 2990

Use whatever identifier fits your needs, but be realistic and upfront about the cost and implications of choosing the wrong one. There is merit in assigning identifiers from the outside and just storing them along the other bits of information (regardless of format (guid, long, uuid)). Whether or not to refactor identity mgmt is more about doing a cost/benefit analysis. Is it even an option with the legacy system, and in what kind of timeframe will there be two keys sidebyside? Why are you even reusing the same datastore? Why not partition it so you can have parallel data stores (worst case even syncing data between both of them, preferably in one direction)? Try some vertical slicing instead of horizontal. HTH.

Upvotes: 0

Related Questions