Friday, December 31, 2010

Activity vs Presenter division of responsibility for Data Access/Server communication ?

Lets say we have an Activity which has a number of WidgetPresenters.
[*]

who should be responsible for using RequestFactory for server
communication ?
is it the responsibility of Activity or the Presenters ?

Activity {

WidgetPresenterA wpa;
WidgetPresenterB wpb;
WidgetPresenterC wpc;

}

Two main areas of concern:

1- getting the data into the widgets:
how can this design be improved ?
Server (RequestFactory) ---> Activity ---> WidgetPresenter --->
Widget
here, RequestFactory hands in data to Activity, which then gives it to
the Presenter
which subsequently hands it to the widget.

2- getting the data from the widgets to the server
widget ---> WidgetPresenter ---> Activity ---> Server(RequestFactory)

I am very concerned about the coupling between Presenter and Activity.

can Presenter directly use the RequestFactory to get the data,
or Activity does this and hands in the result to the Presenter ?

what about Presenter to Activity communication ?
who sends the data back to the server ? Presenter sends it directly,
or first sends it to the corresponding Activity which then sends it to
the server,
or does the Presenter do it directly ? or Presenter communicates with
Activity, through the Event Bus ?

the idea behind using a Presenter is this:

[*]
an Activity, is a display region which is related to a place.
Activity has a View, which defines the layout for this display region.
this View has a number of Slots, that are going to be filled with
widgets.
To be in line with MVP, I also apply MVP to widgets, so a Widget has
UI elements,
and a Presenter which responds to Widgets events.
this Presenter therefore is called WidgetPresenter (a Presenter
associated with a particular widget).

therefore an Activity has a View, a number of Widgets that are going
to be used in that View,
these Widgets have associated Presenters.

the Widget and associated WidgetPresenter may be re-used in other
display regions (activities).

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment