Is there any smell associated with having say a File.IO library being loosely coupled to the logging library? Or should they be kept separate and only combined in the application services?
2 Answers
Loosely coupling is beneficial in all circumstances, but you should also be aware of the additional complexity it may introduce. If you apply the Dependency Inversion principle (read Robert C. Martin's book on Agile Principles for an excellent discussion), you might consider the File.IO library to define an abstraction (e.g. an interface) that it needs for logging. You can then provide an implementation of that abstraction using your preferred logging library. To be clear, that's not the same as using the abstraction offered by the logging library in the File.IO library. Then you would still be locking them together.

- 8,368
- 1
- 32
- 44
Loose coupling is a meaningless term without high cohesion. In your domain, you log in domain specific terms. Take a look at the blog of Isaiah Perumalla, especially test-driven-design-using-mocks

- 15,847
- 1
- 38
- 65