In my code, I have the the following objects:
- ErrorManager – controls how errors
are logged in the application - ConfigManager – controls how the
configuration information is obtained
On the project I’m working on, the ErrorManager needs to pull configuration information using the ConfigManager instance while the ConfigManager uses the ErrorManager incase an error occurs.
At the moment, I’m doing the following in code:
ErrorManager _errorManager = new CustomErrorManager();
ConfigManager _configManager = new CustomConfigManager(_errorManager);
_errorManager.SetConfigurationManager(_configManager);
Is there a way for me to clean up this circular reference of dependencies?
I would create the following:
Now, the
ConfigManagercan can use the ready-to-run ErrorManager without a bootstrapping problem where theErrorManageris not ready to handle errors.