I am trying try to implement a MVP-Pattern example in Java but I do not know how the interface connection between the Presenter and the View works! Does someone know a good example of this?
More details: In some sources a class diagram looks like this diagram
The arrow between the Presenter and the View is interrupted by a ball. This is the symbol of a interface, right?
The Presenter knows the View and the View knows the Presenter, so both need references to each other. For testing I don't want to write new ..();
in the constructor.
If I set the View- and the Presentor- reference by constructor it looks like
this:
CentralView myView = new CentralView(myPresenter);
CenterPresenter myPresenter = new CenterPresenter(myView);
I would appreciate an example of how this works, without "new" in constructor, to be testable and without getter and setter.
I find this easiest:
However, if you insist on "no setters", you should really look up on dependency injection. For example, using guice:
Dependency injection can be used both to replace factories and to resolve circular dependencies (guice uses "proxies" for that).