How competently do I get my class trying to follow SOLID principles?

I have an interface for registering clients called IRegistrationService. It contains one method called Register and is implemented through the RegistrationService class. If I wanted to have methods for deleting, updating, restoring, for example, I would create a separate interface for each action, such as IDeletionService, IUpdateService, IRetrieveService or just put all the methods in the IRegistrationService. The reason I'm asking about this is because it seems to be asking for SOLID principles, especially the SRP principle.

+6
oop solid-principles
source share
1 answer

One way to indicate the principle of shared responsibility is that a class should have only one reason for the change. This does not necessarily mean that this is only one thing, but rather that it is only one area of ​​responsibility.

Thus, for your registration service, it’s great to find out all about registered people, and I would include deleting, updating and receiving registrations. If the registration process changes (for example, you decide that all new or updated users will be sent by email) than the class changes. However, implementation details of how email is sent for registration are not relevant to this service - this will be the second reason the class may change (for example, you understand that you want to send emails through an external SMTP server, and not locally, or via SMS, not email, etc.).

+2
source share

All Articles