How to apply the principle of single responsibility to a class of service

Suppose we are developing a UserServiceImpl class that performs CRUD operations (create, read, update, and delete). In my opinion, creating, reading, updating, and deleting are four reasons for changing a class. Is this class a violation of the principle of shared responsibility? If it breaks, then we should have four classes, such as CreateUserServiceImpl, ReadUserServiceImpl, UpdateUserServiceImpland DeleteUserServiceImpl. Isn't it too much to classes?

Suppose I define 4 interfaces for the create, read, update, and delete operations, and the service class implements all four interfaces. Now I can have only one implementation class, but, having separated their interfaces, I divided the concepts of how much this concerns the rest of the application. Is this right, or do you see some problems in it?

+5
source share
3 answers

This is what I like about templates and principles - they are a way for everyone to disagree with software development just as they agree :-)

, , - , . . , SRP, CRUD-. , , , , 4 , CRUD, . , .

- , , , .

+4

, , , - .

?

Stack, Push Pop ?

. , . CRUD, , , .

. , CRUD MS SQL 6.0, SRP, .

4 , SOLID, ISP, . , , Read . , . , , , - , .

+2

This does not violate the principle of uniform responsibility until the service is responsible for the same type of data service or business information.

+1
source

All Articles