views:

74

answers:

1

In the project I'm working on, we have an aggregate domain object. The factory object handles the creation of the unique id for the object. But there is a separate import process which creates the same object initially without the id. To add the imported object to the system, we are now forced to do a field by field copy to a new object since we can't just set the id for it for obvious reasons. Could anyone suggest a better way of handling this situation?

+1  A: 

Possibilities:

  • If the import process allows it, inject your domain object when it is creating so it actually populates your object.
  • Have your object's implementation be a wrapper around the one created by the import process. Change your factory accordingly.
moffdub