When to update audit fields? DDD

前端 未结 4 1716
暗喜
暗喜 2021-01-12 13:19

I have a Meeting Object:

Meeting{id, name, time, CreatedBy, UpdatedBy}

and a

MeetingAssignee{id, MeetingID, EmployeeId, CreatedBy

4条回答
  •  长发绾君心
    2021-01-12 14:02

    Auditing and logging are fun as they are usually needed everywhere in the application and they are both requirements (logging is a requirement from the OPs guys).

    Without knowing much of your model, and since auditing must be a requirement, I would pass the current user to AssignEmployee and instead of having a line there that says AuditBlahBlahBlah, I would add an event (maybe MeetingUpdated or AssigneeAdded... you'll find a good name) and that event gets dispatched to the class that does the auditing. In this way the Meeting class has no clue about auditing and dispatches business events for auditing purposes (which, in my view, is very DDDish).

    I wonder what other people might say (hopefully, I can learn something new!)

提交回复
热议问题