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*

2
  • 1
    method injection...as if we already had less of estoric terms coined for every quirk of code structure. Anyhow, in simplest terms: The dependencies that stay same for lifetime of an object should ideally be passed via constructor, while the dependencies that are local per method usage, should be provided as method parameters, together. Commented Apr 20, 2023 at 8:14
  • 1
    @candied_orange said, "It's all about the using code" I.e., all about the client of your TextWriter class. Suppose I'm building a big system that uses a TextWriter. You're offering two choices; Either (a) the code site that constructs the TextWriter is responsible to decide where/how the text should be saved, or (b) the site that knows when to save must accept that responsibility. Those two sites could be far from each other in an architecture diagram, It's two different ways of thinking about what TextWriter does. IMO (a) feels like it should be called DI, but (b) does not. Commented Apr 20, 2023 at 14:40