We are developing an app using the MVP pattern, as described in this guide:
http://code.google.com/webtoolkit/articles/mvp-architecture.html
When creating the controller instance we do the following:
appController = new AppController(service, eventBus);
appController.go(RootPanel.get("SOME_SLOT"));
Now, when the controller creates a certain presenter, it does something like this:
sthPresenter = new SthPresenter(service, eventBus, new SthView());
sthPresenter.go();
The presenter than saves the eventBus and the service to a private field variable, and uses either as needed.
As the application grows, we have more and more presenters and views, so the question is can we use a different method of obtaining the service and the eventBus in the presenters, without passing a reference via the constructor of each presenter.
For example, creating a static field in the controller and just calling it with something like AppController.getService(). Maybe a singleton pattern.
Would a static field in the controller (or somewhere else) be a bad idea for this design. Keep in mind that the code is compiled to javascript, if that makes any difference.