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.

5
  • 5
    Why would you not just load the data once and pass the configuration object as needed? Commented Sep 28, 2016 at 23:05
  • 1
    what is with the passing around??? If I had to pass around every object I need I would have constructors with 20 arguments... Commented Apr 18, 2018 at 17:12
  • @Enerccio If you have objects that rely on 20 different others with no encapsulation, you already have major design issues. Commented Jan 23, 2020 at 15:45
  • @spectras Do I? If I implement gui dialog I will need: repository, localization, session data, application data, widget parent, client data, permission manager and probably more. Sure, you can aggregate some, but why? Personally I use spring and aspects to just autowire all these dependencies into the widget class and that decouples everything. Commented Jan 25, 2020 at 23:24
  • If you have that much state, you could consider implementing a facade, giving a view of relevant aspects to the specific context. Why? Because it would allow a clean design without either of the singleton or 29-arg constructor antipatterns. Actually the very fact your gui dialog accesses all those things yells "violation of the single responsibility principle". Commented Jan 26, 2020 at 12:03