Let's understand how circular dependency can be eliminated by applying the single responsibility principle. Let's assume you are following three modules in a system:
- Salary module
- Employee module
- HR module
The Salary module generates salary and sends it over email. Generating salary depends upon the Employee module. To get a few details, such as the appraisal process, and reward points the Employee module depends upon the HR module. At this moment, the dependency hierarchy will be as shown in the following diagram:
At some point in time, let's say you need email functionality in the HR module. Since email ...