HMVP design pattern? Help!

15 views
Skip to first unread message

Grary

unread,
Nov 25, 2009, 8:26:55 PM11/25/09
to Google Web Toolkit
Hi,

I'm new to GWT development, but the tutorials and project samples I've
inspected have impressed me with the value of using the MVP pattern
(and associated libraries for that.) Great. But now, as regards
planning the development of my GWT app, do I think about separate
parts of a given page each as having its own MVP structure and
coordinating via the singleton eventbus?

For example, imagine using several shopping carts on a page to shop
concurrently, but impose a rule that none of the carts may contain the
same item. Never having done MVP, I'd say that each shopping cart can
have its own MVP structure with item duplication prevented by checking
proposed additions to a shopping cart against all the others via the
event bus.

Any thoughts?

Thanks,

Grar

SteveS

unread,
Nov 27, 2009, 11:03:29 PM11/27/09
to Google Web Toolkit
> MVP structure with item duplication prevented by checking
> proposed additions to a shopping cart against all the others via the
> event bus.

This is basically what I've done in my first GWT hierarchical MVP
app. One of its functions is to collect two password recovery
question choices, one from each of two listboxes The parent presenter
adds two questionbox presenters which communicate selection choices
via the eventbus. User selections for questions, answers, password
updates, etc. bubble up this way to a level where it can be determined
whether or not the update button can be enabled. At first, I thought
this might be too fine-grained, but it's worked out well to separate
out the logic this way.

The problem I quickly ran into with MVP was that the ratio of
boilerplate to interesting code was very bad. So, I built a quick and
dirty codegen using StringTemplate that reads an XML description of
the presenters/UI (no 2.0 yet) and generates a display impl, a
presenter interface, a presenter impl abstract base class, associated
events, and RPC plumbing (and validation bindings, etc, etc.) So far,
so good....I feel like I'm writing mostly unique code without too many
redundantly expressed ideas. One additional problem was that some of
the presenter logic got very complicated very quickly. I ended up
drawing a state machine and implementing it with SMC (http://
smc.sourceforge.net/). The presenter fires state machine actions
which in return fire presenter methods to modify the display and other
client-side state. With minor modification, the generated SMC code
plays nicely in client-side GWT.

I'm now interested in how hierarchical state machines could be used to
model GWT apps in a more integrated way. How much of client side
behavior can be declared without boxing a developer into a too-rigid
framework? Would the resulting JavaScript be small enough? Has
anyone else experimented with these sorts of things? Anyone
interested enough in what I've done for me to attempt to open source
it (it's corp-owned right now)? Am I completely off my rocker?
Reply all
Reply to author
Forward
0 new messages