I was reading this question recently: ID properties on Domain objects in DDD
The question talks about having an surrogate key in the infrastructure layer, which is a database ID. I use a Guid for this:
Guid id = Guid.NewId();
The answers then talk about having a natural key in the domain layer that identifies the entities. A great example of this in my mind is a bank account i.e. the Guid identifies the bank account in the database (and Data Model) and the account number and sort code identify the bank account in the domain layer i.e. there is no database id in the domain layer.
Say I have a product entity and I want to generate a product code in the domain layer. How would I do this? The question I have linked to talks about using algorithms. What algorithms are there?