New answers tagged

0

Since the FileCreator class requires the StreamWriter in order to work correctly, that means that a FileCreator without a StreamWriter makes no sense, which in turn means that it should require the StreamWriter in its constructor. (Your [3] solution.) There are now a few problems left to solve: The Dependency Inversion Principle states that "details should ...


3

Passing the StreamWriter as a constructor argument to FileCreator is the preferred approach if the stream writer is indeed a shared resource between all method calls against any one particular FileCreator object. If you need to specify different stream writers for different method invocations on FileCreator, then you need to pass the StreamWriter as an ...


Top 50 recent answers are included