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*

5
  • Should that location be inside a controller How would you test the controller? Commented May 2, 2019 at 14:14
  • not sure I understood your question. I've added sample test pseudocode in my question. Instantiate the controller the way it is written, and test its output. I presume I can do this regardless of the first or the second way I have it written in the question Commented May 2, 2019 at 14:19
  • 1
    Ok, my bad. If the controller initializes the renderer, it means you can not test the controller fully decoupled from the render. If that's ok for you, then fine. In other words. If you consider the Renderer to be an implementation detail of the Controller (something intrinsically involved in the controller implementation), then allow the controller to initialize the render. If both components are complementary, then tell someone else to initialize the render. Commented May 2, 2019 at 14:27
  • thanks, so I see this as a design decision whether or not I want to tightly couple an object to the controller. And whether or not I want to or can afford testing the controller with its hardcoded dependency Commented May 2, 2019 at 14:35
  • Yes, Mainly that. If you ever want to use a different Renderer, you will have to update the controller and redeploy it. If the render is a dependency (injected somehow), you can have the Render implementation in a different place, deploy it separately, without messing with the controller and the rest of the application. Not to mention the gain on testability which is always welcome. Commented May 2, 2019 at 14:38