nestjs-solid icon indicating copy to clipboard operation
nestjs-solid copied to clipboard

SR principle seems to be pretty violated for controllers

Open abaikov opened this issue 7 months ago • 0 comments

For example in the orders controller

https://github.com/ipenywis/nestjs-solid/blob/main/src/modules/SRP/orders/orders.controller.ts#L27C5-L27C67

await this.emailsService.sendOrderEmail(createdOrder.orderId);

Orders use email service, the SR principle is violated, now email service can be changed for two reasons - if something happens with emails or if something happens with orders

Your example seems to do not work, am I wrong? If you'll decide to change email service, for example to split it to smaller services, you'll need to find any usages and fix them one by one (but actually even to fix the only usage from outside is a bad sign, when you work with emails - you don't want to make changes in any other modules) - because you already violated the SR principle

Of course it seems to be impossible to make a completely correct system for SOLID principles, but what's about using facades or events to reduce the impact of changes in one module on another? Isn't it a little bit better?

abaikov avatar Jul 14 '24 02:07 abaikov