If I break my objects to “Single Responsibilities”, is there a fundamental thought, should such objects live together or separately, for example, if I have
class Employee_DataProvider() : IEmployee_DataProvider { ... }; class Employee_Details() : IEmployee_Details { ... }; class Employee_Payroll() : IPayroll() { ... }; class Employee_LeaveProcessing() : ILeaveProcessing_Client { ... }; ...
It smells bad that they all live inside, but are loosely connected to interfaces that own the Employee class:
class Employee { IEmployee_DataProvider _dataProvider; IEmployee_Details _details; IPayroll _payroll; ILeaveProcessing_Client _leaveProcessing;
or thinks more about these classes to be completely separate (or at least as separate as possible) in the code? Or are both of these methods a valid use of SRP?
EDIT: I don’t want to critically evaluate the possibility of the object shown in the example, I just did it to illustrate the question. I agree that data processing, vacation and payroll is not an employee class domain.
It appears, although SRP asks me to move away from the object as a representation of the real world to the object as properties and methods around one functional concept.
source share