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.

7
  • Can you post some brief code that illustrates your model? There are ways to "soft-wire" dependencies (i.e. setting up the event handlers at runtime); if you look at the code-behind for a typical Winforms form, this is exactly what it does in the partial class constructor. There's no such thing as complete decoupling; your application is still going to need to know which form to open eventually, so unless you're building some sort of application generator, hard-wiring the name of the form to open is perfectly normal. Commented Feb 2, 2016 at 23:03
  • @RobertHarvey Let me see what sort of sample I can come up with. I suppose the big difference is I have an object with centralized "window opening events." Commented Feb 2, 2016 at 23:08
  • The use case for that sort of thing would be a "plugin" system where you could modularize the form components and swap them out at runtime. If the design of the application is intended to be static (i.e. the form will always be the same form that opens for its use cases), I don't see the need. Commented Feb 2, 2016 at 23:10
  • @RobertHarvey Well, the presenters can raise the events without knowing about any of the forms. Wouldn't that not be the case if I were just listening for events on the forms themselves? Commented Feb 2, 2016 at 23:18
  • 1
    I'm always skeptical about adding an additional level of indirection unless you derive some tangible benefit. What happens when you need to troubleshoot the thing? Do you have to suffer through a debugger session jumping through a new level of indirection until it gets to the real form/event? Is that even possible, if your Singleton appears in an assembly whose project source isn't loaded into Visual Studio? Commented Feb 2, 2016 at 23:32