I am doing my first steps with GWT
.
I have a question after reading:
In the first example the Presenter
defines the interface for the View
.
public class ContactsPresenter implements Presenter {
...
public interface Display extends HasValue<List<String>> {
HasClickHandlers getAddButton();
HasClickHandlers getDeleteButton();
HasClickHandlers getList();
void setData(List<String> data);
int getClickedRow(ClickEvent event);
List<Integer> getSelectedRows();
Widget asWidget();
}
}
And in the second one, the View
defines the interface for the Presenter
.
public interface ContactsView<T> {
public interface Presenter<T> {
void onAddButtonClicked();
void onDeleteButtonClicked();
void onItemClicked(T clickedItem);
void onItemSelected(T selectedItem);
}
void setPresenter(Presenter<T> presenter);
void setColumnDefinitions(List<ColumnDefinition<T>> columnDefinitions);
void setRowData(List<T> rowData);
Widget asWidget();
}
What's the idea of this difference?
Which should I choose?
Overview. MVP is a user interface architectural pattern engineered to facilitate automated unit testing and improve the separation of concerns in presentation logic: The model is an interface defining the data to be displayed or otherwise acted upon in the user interface.
The reason why MVP is widely accepted is that it provides modularity, testability, and a more clean and maintainable codebase. It is composed of the following three components: Model: Layer for storing data.
I think you should have used the word 'defines' in your question instead of 'implements' and if thats the case then it does not matter which class defines the interface.
You could do something different by defining the interfaces in its own files. At the end of the day all that matters is the Presenter implementing the Presenter interface and the View implementing the View interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With