Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

12
  • why would log service need printing details? to do formatting? if yes, it shouldn't, that's the print service's job. if for the call in 1 - pass all necessary data, or pass a reference to the print service object, so the log service can question it. but I don't see for what it would need that. Commented Nov 17, 2018 at 21:58
  • Thanks for your attention. I get your point. Maybe this example is not good enough. I just want to bring out how do I handle such circular dependency case. I try to use a better example instead. Commented Nov 17, 2018 at 22:02
  • 2
    The most simple solution seems to have an interface. Commented Nov 17, 2018 at 23:48
  • 1
    I think solution would be remove Print dependency from the Log service. Print service required Log and will provide all details to the Log, without Log service knowing about Print Commented Nov 18, 2018 at 0:37
  • 2
    Another approach is to follow "rule" that when you have circular dependency you will introduce third separated library which will combine two others. Commented Nov 18, 2018 at 1:01