Blogger
Blogger copied to clipboard
Emit Domain Event to leverage SRP and OCP
As a suggestion, emitting a domain event like CommentCreated would be more effective when creating a comment. A handler, such as the MakeCommentCommandHandler, can then manage this event and attempt to send the email. This approach helps separate these two logics, adhering to the Single Responsibility Principle (SRP) and Open/Closed Principle (OCP). It also allows for more straightforward future extensions, such as sending notifications through other channels.