Can the following Domain Entity contain logic for creating/deleting other entities?
- by user702769
a) As far as I understand it, in most cases Domain Model DM doesn't contain code for creating/deleting domain entities, but instead it is the job of layers ( ie service layer or UI layer ) on top of DM to create/delete domain entities?
b) Domain entities are modelled after real world entities. Assuming particular real world entity being abstracted does have the functionality of creating/deleting other real world entities, then I assume the domain entity abstracting this real world entity could also contain logic for creating/deleting other entities?
class RobotDestroyerCreator
{
...
void heavyThinking()
{
...
if(...)
unitOfWork.registerDelete(robot);
...
if(...)
{
var robotNew = new Robot(...);
unitOfWork.registerNew(robotNew);
{
...
}
}
Thank you