3
I have a class CRUD which has the following methods:
- Get connection()
- Insert($object)
- Update($object)
- Delete($object)
- Select($object)
Taking into consideration the SRP (Principle of Sole Responsibility) which says:
A class should only have one reason to change.
My class CRUD from my point of view has more than one reason to change, because if I need to change the function Insert, I’ll have to change in class CRUD, the same occurs for other functions.
And then some doubts arose:
1 - According to the SRP my class has more than one reason to change, am I right? or this is not valid for type classes CRUD?
2 - Following the SRP what is the best way to create a class CRUD?
3 - Would it be ideal to have a class for each operation? or would it be better to use interfaces?
4 - In the case of interfaces, how the implementation would be made?