Answer the question
In order to leave comments, you need to log in
Is the MVP pattern only used in .NET?
As I understand MVP is based on events.
View , through its methods on control events ( button1_Click ) raises IView events .
The Presenter has a subscription to IView events . (correct if I'm wrong)
But in some languages there are no events as such (event) (in Java, it seems not). How to apply this pattern without events?
In my opinion, this is impossible ...
PS We'll have to use MVC
Answer the question
In order to leave comments, you need to log in
You have misunderstood what patterns are.
A pattern is not a specific implementation of something, but an approach to organization. What is described in the books is a kind of generalization of the experience of developers. On each PL, patterns can be implemented in different ways. Moreover, since the pattern itself is a generalization of experience, then even in one PL it can be implemented in different ways, depending on the context in which it is used and the specific programmer.
Accordingly, any pattern can be used on any Turing complete PL.
By the way, Events is also a pattern, it's just that in some PLs it is implemented at the language level, in others it is implemented manually. Where they do not exist, you can implement them yourself or use one of the ready-made libraries.
A pattern is a spherical advice in a vacuum on how to solve a particular design problem. It usually boils down to "Here we have something that looks like *pattern name*".
Quite possible. Used, for example, in Swing (Java) or GWT (Java). Events do not have to be built into the language and be first-class citizen in it. For example, in GWT, an event handler is described as follows:
public interface ILoginView {
String getUsername();
String getPassword();
}
public interface ILoginPresenter() {
void onLogin();
}
public final class LoginView extends Composite implements ILoginView {
// ...
@UiField TextBox username;
@UiField PasswordTextBox password;
private final ILoginPresenter loginPresenter = ...;
// ...
@Override public String getUsername() { return username.getText(); }
@Override public String getPassword() { return password.getText(); }
@UiHandler("login") public void onLoginClick(ClickEvent e) { presenter.onLogin(); }
// ...
}
@UiHandler
is processed by the framework. You can, of course, get by with a less declarative approach and register handlers manually through some kind of addXXXListener()
, as is done in Swing. ISummaryView
that simply displays a few lines of text.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question