I have a CRUD
class that has the following methods:
- GetConnection ()
- Insert ($ object)
- Update ($ object)
- Delete ($ object)
- Select (object)
Taking into account the SRP
(Principle of Single Responsibility) that 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 Insert
function, I will have to change in class CRUD
, same for other functions.
And then some doubts came up:
1 - According to SRP
my class has more than one reason to change, am I right? or is this not valid for classes type CRUD
?
2 - Following the SRP
what is the best way to create a CRUD
class?
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 would the implementation be done?